Purchases from iOS in-app messages
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.
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;@end
Successful transaction
@protocol PWPurchaseDelegate <NSObject>// A successfully processed transaction<strong>-(void)onPWInAppPurchaseHelperPaymentComplete:(NSString* _Nullable)identifier;</strong>@end
Failed transaction
@protocol PWPurchaseDelegate <NSObject><strong>// A failed transaction</strong>-(void)onPWInAppPurchaseHelperPaymentFailedProductIdentifier:(NSString* _Nullable)identifier error:(NSError* _Nullable)error;@end
Promoted from App Store
@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;@end
Failed restoring completed transactions
@protocol PWPurchaseDelegate <NSObject>// An error occurred while restoring transactions-(void)onPWInAppPurchaseHelperRestoreCompletedTransactionsFailed:(NSError * _Nullable)error;@end