Promoting App Store In-App Purchases

Since the emergence of iOS 11, developers and app owners can promote in-app purchases of their app in the App Store.

Promoted in-app purchases appear on your product page, they are either displayed in search results or contrastingly they may feature on an appropriate tab in the App Store.

A user 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, the user is prompted to download it.

Promoting in-app purchases requires two steps:

  1. The first step requires you to 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 displayed 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
    });
}

To test your code, follow the Apple instructions.