Adding iTunes subscriptions

Pugpig comes with support for auto-renewing subscriptions through iTunes when correctly configured.

Enabling in-app purchases for your app

You must ensure that your app has “In App Purchase” enabled on the iOS provisioning portal here, and that you are using the correct provisioning profile.

Adding products to iTunes

Your app must be configured in iTunes connect. You will also need to create your products here. The iTunes Connect Developer's Guidedescribes how to do this. It is your responsibility to test in-app purchasing, so you will need to create test iTunes users to do so. The Developer's Guide gives more details on the process.

If you intend to support the purchase of single products, they will need product IDs that do not conflict with any of your subscriptions. Pugpig expects your product IDs to conform to a regular pattern. Please see Adding in-app purchasing through iTunes for more information on supporting other in-app purchases, and more troubleshooting information.

Configuring your CMS

Your CMS must include a Pugpig iTunes authorisation endpoint. Pugpig uses this endpoint to confirm that you have permissions to download a specific document. You can find more information about authorisation endpoints in our Pugpig API

You will also need to configure your CMS to mark certain products as paid in the OPDS feed that Pugpig uses to track available content. You can find more information in our Pugpig API

If you are using one of our existing Pugpig Connectors, this functionality should already be available; you should just need to configure it correctly.

Configuring Pugpig to support subscription purchasing

Pugpig needs to know your Pugpig iTunes authorisation endpoint, how to identify your subscription, and how long your subscription should run for. In your AppDelegate.m, look for code similar to this:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  // TODO: If you need to support paid content, this is where you set up your authorisation providers.
  NSURL *appStoreAuthURL = [NSURL URLWithString:@""];
  // self.appStoreSingleAuth = [[[KGAppStoreAuthorisation alloc] initWithEndpointURL:appStoreAuthURL identifierPrefix:@""] autorelease];
  // [dm addAuthorisation:appStoreSingleAuth];
  self.appStoreSubsAuth = [[[KGAppStoreSubscriptionAuthorisation alloc] initWithEndpointURL:appStoreAuthURL productIdentifier:@"example.subscription.productid" duration:(31*24*60*60)] autorelease];
  [dm addAuthorisation:appStoreSubsAuth];  

The lines will be commented out in the template - uncomment them to enable in-app purchasing. You must provide your authorisation endpoint in the appStoreAuthURL variable, and your product id prefix as the productIdentifier parameter of the initWithEndpointURL function. Theduration parameter should be set to the length of your subscription, in seconds (so, the above example is 31 days, or 1 month).

Please note that while you are testing your subscriptions in the iTunes Connect sandbox, the duration parameter should be set to the length of time that the test subscription will be valid for, which is not the same as the actual length of the subscription. The “Testing Your In-App Purchase” section of The iTunes Connect Developer Guide explains the process in detail.

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request


Powered by Zendesk