Solved

How to use purchases:shouldPurchasePromoProduct:defermentBlock: in Objective-C?

  • 18 August 2021
  • 3 replies
  • 258 views

Badge +1

I’ve tried to use `-purchases:shouldPurchasePromoProduct:defermentBlock:` in Objective-C,

But I don’t know how to call it in Objective-C.

 

Please add the way to write it in objc to the docs?

Thanks.

 

https://sdk.revenuecat.com/ios/Protocols/RCPurchasesDelegate.html

icon

Best answer by cody 19 August 2021, 03:34

View original

3 replies

Badge +1

Hi guys,

I’m stuck in the same place as toco trying to integrate RC into an iOS app. It’s a real shame there is no sample app or video walkthrough available for Objective C - would make my life a lot easier - everything is set up on RC and App Store.

If anyone can help in any way, my email is paul.denheyer@gmail.com

A thousand thanks in advance

 

paul

Badge +1

Hi @cody,

Thanks for your reply. It works by using your code :)

Thank you very much!!

 

 

Userlevel 6
Badge +8

Hey @toco! 👋

In Objective-C, you’ll want to be sure your RCPurchases delegate class conforms to RCPurchasesDelegate. If you are using AppDelegate as your RCPurchases delegate, it might look like this in your AppDelegate.h file:

#import "RCPurchases.h"

@interface AppDelegate : UIResponder <UIApplicationDelegate, RCPurchasesDelegate>

 

In AppDelegate.m, your shouldPurchasePromoProduct method might look like this:

- (void)purchases:(RCPurchases *)purchases shouldPurchasePromoProduct:(SKProduct *)product defermentBlock:(RCDeferredPromotionalPurchaseBlock)makeDeferredPurchase {

makeDeferredPurchase(^(SKPaymentTransaction * transaction, RCPurchaserInfo *info, NSError *error, BOOL userCancelled) {
//...
});
}

 

Reply