Purchases.framework
Purchases is a client for the RevenueCat subscription and purchase tracking system. It is an open source framework that provides a wrapper around StoreKit
and the RevenueCat backend to make implementing iOS in app purchases easy.
Check out the getting started guide.
Installation
Purchases is available through CocoaPods and Carthage
CocoaPods
pod "Purchases"
Carthage
github "revenuecat/purchases-ios"
Getting Started
1. Create a RevenueCat Account
Go to RevenueCat, create an account, and obtain an API key for your application.
RCPurchases
object with your secret.
2. In your app instantiate an import Purchases
let purchases = RCPurchases(apiKey: "myappapikey")!
purchases.delegate = self;
@import Purchases
RCPurchases *purchases = [[RCPurchases alloc] initWithAPIKey:@"myappAPIKey"];
purchases.delegate = self;
3. Make a purchase
purchases.entitlements({ (entitlements) in
let product = entitlements["pro"].offerings["monthly"]!.activeProduct
purchases.makePurchase(product)
})
[purchases entitlements:^(NSDictionary *entitlements) {
SKProduct *product = entitlements[@"pro"].offerings[@"monthly"].activeProduct;
[purchases makePurchase:product];
}];
4. Unlock Entitlements
func purchases(_ purchases: RCPurchases, completedTransaction transaction: SKPaymentTransaction, withUpdatedInfo purchaserInfo: RCPurchaserInfo) {
if (purchaseInfo.activeEntitlements.contains("pro")) {
// Unlock that great "pro" content.
}
}
- (void)purchases:(RCPurchases *)purchases
completedTransaction:(SKPaymentTransaction *)transaction
withUpdatedInfo:(RCPurchaserInfo *)purchaserInfo {
[purchaserInfo.activeEntitlements containsObject:@"pro"];
}