Purchases from iOS In-App Messages

How to implement in-app purchases from Rich Media displayed to iOS app users

To let your users make purchases right from the in-app messages displayed in your iOS app, you can implement the out-of-the-box solution for your Rich Medias and add callbacks to get more info about in-app purchases.

Available for the 6.4.5 iOS SDK version and further.

Rich Media JavaScript implementation

To implement in-app purchases in your Rich Medias, use a simple JavaScript function call:

pushwooshImpl.makePurchaseWithIdentifier("Premium"); // product identifier specified in your App Store product information

AppDelegate methods for callbacks

If you need callbacks to be executed on a purchase, implement the PWPurchaseDelegate protocol as follows:

1. Make your project’s AppDelegate conform to the PWPurchaseDelegate protocol:

@interface AppDelegate : PWAppDelegate <PushNotificationDelegate, PWPurchaseDelegate>

2. Implement methods of PWPurchaseDelegate in your AppDelegate:

#pragma mark - Purchase delegate methods
- (void) onPWInAppPurchaseHelperPaymentComplete:(NSString*) identifier {
    NSLog(@“Custom purchase delegate -- payment complete for identifier: %@“, identifier);
-(void)onPWInAppPurchaseHelperProducts:(NSArray<SKProduct *>* _Nullable)products {
    NSLog(@“Custom purchase delegate -- retrieved list of products”);
-(void)onPWInAppPurchaseHelperPaymentFailedProductIdentifier:(NSString* _Nullable)identifier error:(NSError* _Nullable)error {
    NSLog(@“Custom purchase delegate -- payment failed with identifier %@ and error %@“, identifier, error.description);

List of available PWPurchaseDelegate methods

List of products

@protocol PWPurchaseDelegate <NSObject>
// Detailed information about list of products in your app 
-(void)onPWInAppPurchaseHelperProducts:(NSArray<SKProduct *>* _Nullable)products;

Successful transaction

@protocol PWPurchaseDelegate <NSObject>
// A successfully processed transaction 
-(void)onPWInAppPurchaseHelperPaymentComplete:(NSString* _Nullable)identifier;

Failed transaction

@protocol PWPurchaseDelegate <NSObject>
// A failed transaction 
-(void)onPWInAppPurchaseHelperPaymentFailedProductIdentifier:(NSString* _Nullable)identifier error:(NSError* _Nullable)error;
@protocol PWPurchaseDelegate <NSObject>
// An in-app purchase is initiated from the App Store, and the transaction continues in your app.
-(void)onPWInAppPurchaseHelperCallPromotedPurchase:(NSString* _Nullable)identifier;

Failed restoring completed transactions

@protocol PWPurchaseDelegate <NSObject>
// An error occurred while restoring transactions
-(void)onPWInAppPurchaseHelperRestoreCompletedTransactionsFailed:(NSError * _Nullable)error;

If your needs are not covered with the methods specified in this guide, please reach out to our Customer Support team, and we’ll be happy to provide you with further guidance.

Last updated