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.
Purchases is available through CocoaPods and Carthage
pod "Purchases"
github "revenuecat/purchases-ios"
Go to RevenueCat, create an account, and obtain an API key for your application.
import Purchases
let purchases = RCPurchases(apiKey: "myappapikey")!
purchases.delegate = self;
@import Purchases
RCPurchases *purchases = [[RCPurchases alloc] initWithAPIKey:@"myappAPIKey"];
purchases.delegate = self;
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];
}];
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"];
}