Skip to main content
Solved

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


Forum|alt.badge.img+1
  • New Member
  • 1 reply

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

Best answer by cody

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

 

View original
Did this post help you find an answer to your question?

3 replies

cody
RevenueCat Staff
Forum|alt.badge.img+8
  • RevenueCat Staff
  • 497 replies
  • Answer
  • August 19, 2021

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

 


Forum|alt.badge.img+1
  • Author
  • New Member
  • 1 reply
  • August 19, 2021

Hi @cody,

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

Thank you very much!!

 

 


Forum|alt.badge.img+1
  • New Member
  • 1 reply
  • December 19, 2021

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


Did this post help you find an answer to your question?

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings