SDK configuration

Paywall API Usage

Fetch Paywall

Fetch the paywall view controller associated with a remote configuration and present it.
Optionally you can preload the paywall view controller as soon as your main view controller loads and
display it when the user select the show paywall action.

Glassfy.paywall(id: "remote_configuration_identifier") { [weak self] vc, err in
    if let vc = vc {
        // optional customization
        // customizePaywall(vc)

        self?.present(vc, animated: true, completion: nil)
    }
}
__typeof(self) __weak weakSelf = self;
[Glassfy paywallWithId:@"remote_configuration_identifier" completion:^(GYPaywallViewController *vc, NSError *err) {
    if (vc) {
        // optional customization
        // [weakSelf customizePaywall:vc];
        
        [weakSelf presentViewController:vc animated:YES completion:nil];
    }
}];

Customize Paywall actions

By Tapping on Close, Link, Purchase or Restore Glassfy will perform a default automatic action that can eventually changed by setting a custom handler as in the code below.

private func customizePaywall(_ vc: Glassfy.PaywallViewController) {
    vc.setPurchaseHandler { sku in
        // user tap on purchase button
    }

    vc.setRestoreHandler {
        // user tap on restore button
    }

    vc.setLinkHandler { url in
        // user tap on a link
    }

    vc.setCloseHandler { transaction, err in
        // user tap on close or a purchase/restore complete
    }
}
- (void)customizePaywall:(GYPaywallViewController *)vc {
    [vc setPurchaseHandler:^(GYSku * sku) {
        // user tap on purchase button
    }];
    
    [vc setRestoreHandler:^{
        // user tap on restore button
    }];

    [vc setLinkHandler:^(NSURL *url) {
        // user tap on a link
    }];
    
    [vc setCloseHandler:^(GYTransaction *transaction, NSError *err) {
        // user tap on close or a purchase/restore complete
    }];
}

Did this page help you?