Promoting App Store In-App Purchases

Promoting In-App Purchases

Starting in iOS 11, you can promote in-app purchases on the App Store. Promoted in-app purchases appear on your product page, can be displayed in search results, and may be featured on an appropriate tab on the App Store. Users can start an in-app purchase on the App Store and be taken into your app to continue the transaction. If your app is not yet installed, they are prompted to download it.
More info on Apple Documentation

Promoting in-app purchases requires two steps:

  1. Set up in-app purchases in App Store Connect by uploading promotional images for the in-app purchases you’d like to promote. You can then use the App Store Promotions tool in App Store Connect to manage their order and visibility on the App Store
  2. Implement PurchaseDelegate methods as in the following sample code:
@main
class AppDelegate: [...], Glassfy.PurchaseDelegate {
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        Glassfy.initialize(apiKey: "YOUR_API_KEY")
        Glassfy.setPurchaseDelegate(self)
        [...]
    }

    func handlePromoted(productId productid: String, promotionalId promoid: String?, purchaseHandler purchase: @escaping (Glassfy.PaymentTransactionBlock?) -> Void) {
        // custom logic
        // start the purchase calling the handler
        purchase() { transaction, error in
            // check any permission update as usual
        }
    }
}
@interface AppDelegate () <GYPurchaseDelegate>
@end

@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [Glassfy initializeWithAPIKey:@"YOUR_API_KEY"];
    [Glassfy setPurchaseDelegate:self];

    [...]
}

#pragma mark - GYPurchaseDelegate delegate
- (void)handlePromotedProductId:(NSString *)productid
              withPromotionalId:(NSString *_Nullable)promoid
                purchaseHandler:(void (^)(GYPaymentTransactionBlock _Nullable))purchase
{
    // custom logic
    // start the purchase calling the handler
    purchase(^(GYTransaction *transaction, NSError *err) {
        // check any permission update as usual
    });
}
@end

To test your code, follow Apple instructions.


Did this page help you?