Solved

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

  • 18 August 2021
  • 2 replies
  • 34 views

Badge

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

2 replies

Userlevel 3
Badge +7

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) {
//...
});
}

 

Badge

Hi @cody,

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

Thank you very much!!

 

 

Reply