PurchaseHelper 1.6.1.3

PurchaseHelper 1.6.1.3

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Jan 2019

Maintained by Paul Schifferer.



Build Status Carthage compatible Cocoapods compatible License: MIT

PurchaseHelper

In-app purchase helper and UI elements

Usage

Integration

CocoaPods

To use PurchaseHelper with CocoaPods, add the following line to your Podfile:

pod 'PurchaseHelper'

Carthage

To use PurchaseHelper with Carthage, add the following line to your Cartfile:

github "paulyhedral/PurchaseHelper"

Helper

Instantiate the helper once, and keep a strong reference to it somewhere.

NSSet<NSString*>* productIds = [NSSet setWithObjects:@"product1", @"product2", @"product3", nil];
PurchaseHelper* helper = [[PurchaseHelper alloc] initWithProductIdentifiers:productIds keychainAccount:@"MyIAPs"];

Buy a product:

[helper buyProduct:@"product2"];

And check if a product was bought:

if([helper productPurchased:@"product3"]) {
    // show some feature
}
else {
    // encourage the user to buy this feature
}

Restore completed transactions:

[helper restoreCompletedTransactions];

UI

Create the view controller, providing it a reference to the helper. Customize its appearance, then display it.

PurchasesViewController* vc = [PurchasesViewController new];
vc.purchaseHelper = helper;

vc.titleFont = appTitleFont;
vc.buttonFont = appButtonFont;
...

[self presentViewController:purchasesVC animated:YES completion:nil];

If your app needs to know when the purchase completed, setup a notification observer:

[[NSNotificationCenter defaultCenter] addObserverForName:ProductPurchasedNotification object:nil queue:nil usingBlock:^(NSNotification* note){
    NSString* productId = note.userInfo[ProductPurchasedNotificationProductIdentifierKey];
    // do something with the notification
}];

Test mode

Place the helper in test mode when testing the application's in-app purchase functionality.

helper.testMode = YES;

Copyright

Copyright © 2016-8 Pilgrimage Software

License

See LICENSE for details.