jeh*_*jeh 5 in-app-purchase ios rmstore
我正在使用RMStore库- 这就是我目前所拥有的.
1)购买自动续订订阅并验证退回的收据.
[[RMStore defaultStore]addPayment:[Environment environment].premiumProductIAPId success:^(SKPaymentTransaction *transaction) {
[[RMStore defaultStore].receiptVerificator verifyTransaction:transaction success:^{
//enable premium service
} failure:^(NSError *error) {
}];
} failure:^(SKPaymentTransaction *transaction, NSError *error) {
}];
Run Code Online (Sandbox Code Playgroud)
2)在每次应用程序启动时,检查订阅是否为该日期的活动,如果是,则启用高级服务
RMAppReceipt *appReceipt = [RMAppReceipt bundleReceipt];
if (appReceipt){
NSInteger isActive = [appReceipt containsActiveAutoRenewableSubscriptionOfProductIdentifier:[Environment environment].premiumProductIAPId forDate:[NSDate date]];
//enable premium service if active
}
Run Code Online (Sandbox Code Playgroud)
3)如果用户在另一台设备上启动应用程序,则允许他们通过刷新收据来恢复购买(如果存在,并检查购买中是否存在有效订阅).
"In most cases, all your app needs to do is refresh its receipt and deliver the products in its receipt."
Run Code Online (Sandbox Code Playgroud)
- 那是来自指南.这是代码:
[[RMStore defaultStore]refreshReceiptOnSuccess:^{
if ([receipt containsActiveAutoRenewableSubscriptionOfProductIdentifier:[Environment environment].premiumProductIAPId forDate:[NSDate date]]){
//enable
}else{
//no longer active
}
} failure:^(NSError *error) {
}];
Run Code Online (Sandbox Code Playgroud)
我的问题:
我将尝试回答我的问题。
可能存在在启动时未检测到的续订,因此订阅显示为非活动状态。
我添加了一个观察者来监听已完成的事务(RMStore 扩展了此 StoreKit 功能)。
每次收到此通知时,我都会检查有效订阅的(现已更新)收据,并启用高级服务(如果有)。
- (void)storePaymentTransactionFinished:(NSNotification*)notification
{
BOOL isActive = [[RMAppReceipt bundleReceipt] containsActiveAutoRenewableSubscriptionOfProductIdentifier:[Environment environment].premiumProductIAPId forDate:[NSDate date]];
if (isActive){
//enable premium
}
}
Run Code Online (Sandbox Code Playgroud)
这似乎有效。如果有人有任何其他建议请告诉我。
| 归档时间: |
|
| 查看次数: |
767 次 |
| 最近记录: |