Latest 1.5
Homepage https://github.com/paulyhedral/PurchaseHelper
License MIT
Platforms ios 9.3, osx 10.11, requires ARC
Dependencies SAMKeychain
Authors

Build Status Carthage compatible Cocoapods compatible License: MIT

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 "exsortis/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-7 Pilgrimage Software

License

See LICENSE for details.

Latest podspec

{
    "name": "PurchaseHelper",
    "version": "1.5",
    "summary": "In-app purchase helper and UI elements",
    "description": "Some helper classes for managing in-app purchases,nincluding some UI elements.",
    "homepage": "https://github.com/paulyhedral/PurchaseHelper",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Paul Schifferer": "[email protected]"
    },
    "social_media_url": "https://twitter.com/paulyhedral",
    "platforms": {
        "ios": "9.3",
        "osx": "10.11"
    },
    "source": {
        "git": "https://github.com/paulyhedral/PurchaseHelper.git",
        "tag": "1.5"
    },
    "source_files": "PurchaseHelper/**/*.{h,m}",
    "resources": [
        "PurchaseHelper/**/*.strings"
    ],
    "ios": {
        "resources": [
            "PurchaseHelper/**/*.xib"
        ]
    },
    "exclude_files": "Classes/Exclude",
    "public_header_files": "PurchaseHelper/*.h",
    "private_header_files": "PurchaseHelper/Private/*.h",
    "requires_arc": true,
    "dependencies": {
        "SAMKeychain": []
    }
}

Pin It on Pinterest

Share This