TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Dec 2014 |
Maintained by Unclaimed.
SimplePurchase is a lightweight wrapper for in-app purchases on the iOS platform. It is inspired by Parse's in-app purchase API. However, unlike Parse, SimplePurchase:
Although Parse felt a little too heavy for the project from which this library was extracted, I strongly suggest checking them out. Here's a link to Parse's in-app purchase documentation.
Add the following to your Podfile and run the pod
command to install:
pod 'SimplePurchase', '~> 0.0.1'
If you're not using CocoaPods, copy all of the files inside the Classes subdirectory into your project.
First, register an observer for your product. This should be done right after the app has launched:
[SimplePurchase addObserverForProduct:@"com.example.MyApp.pro"
block:^(SKPaymentTransaction *transaction)
{
// the purchase has been made; make a record of it and perform whatever
// changes neccessary in the app.
}];
Second, when the user has requested to make the purchase, initiate the purchase and notify the user of any error:
[SimplePurchase buyProduct:@"com.example.MyApp.pro" block:^(NSError *error)
{
if (error)
{
[[[UIAlertView alloc] initWithTitle:@"Purchase Error"
message:error.localizedDescription
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil] show];
}
}];