Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/117.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 自动更新IAP订阅用户流&;刷新收据_Ios_In App Purchase_Rmstore - Fatal编程技术网

Ios 自动更新IAP订阅用户流&;刷新收据

Ios 自动更新IAP订阅用户流&;刷新收据,ios,in-app-purchase,rmstore,Ios,In App Purchase,Rmstore,我正在使用图书馆-以下是我目前拥有的 1) 购买自动续费订阅并验证返回的收据 [[RMStore defaultStore]addPayment:[Environment environment].premiumProductIAPId success:^(SKPaymentTransaction *transaction) { [[RMStore defaultStore].receiptVerificator verifyTransaction:transaction success:^

我正在使用图书馆-以下是我目前拥有的

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) {

}];
2) 在每次应用程序启动时,检查订阅是否在该日期处于活动状态,如果是,则启用高级服务

RMAppReceipt *appReceipt = [RMAppReceipt bundleReceipt];
if (appReceipt){
  NSInteger isActive = [appReceipt containsActiveAutoRenewableSubscriptionOfProductIdentifier:[Environment environment].premiumProductIAPId forDate:[NSDate date]];
  //enable premium service if active
}
3) 如果用户在另一台设备上启动应用程序,则允许他们通过刷新收据(如果存在)并检查购买中是否有活动订阅来恢复购买

"In most cases, all your app needs to do is refresh its receipt and deliver the products in its receipt."
-那是指南上的。代码如下:

[[RMStore defaultStore]refreshReceiptOnSuccess:^{

  if ([receipt containsActiveAutoRenewableSubscriptionOfProductIdentifier:[Environment environment].premiumProductIAPId forDate:[NSDate date]]){
   //enable
  }else{ 
   //no longer active
  }
} failure:^(NSError *error) {

}];
我的问题是:

  • 当RMStore检查订阅是否处于活动状态时,它可以返回否,我查看收据,它是正确的,我假设它没有自动续订。当我去购买另一个订阅时,我从itunes收到一条消息,说我已经订阅了。在随后的发布中,我看到了新的收据。这表示需要在启动时刷新收据,但我不想刷新它,因为它会弹出用户名和密码弹出窗口,这是不必要的。这里的最佳实践是什么
  • 我是否以正确的方式还原其他设备的订阅?有时似乎需要多次尝试才能恢复订阅
  • 除了保存记录外,是否还需要在我的服务器上存储订阅

    • 我将尝试回答我的问题

      可能有一个在启动时第一件事就没有检测到的续订,因此订阅似乎处于非活动状态

      我添加了一个观察者来监听完成的事务(RMStore扩展了这个StoreKit功能)

      每次收到此通知时,我都会检查(现在已更新)活动订阅的收据,如果有,则启用高级服务

      - (void)storePaymentTransactionFinished:(NSNotification*)notification
      {
        BOOL isActive = [[RMAppReceipt bundleReceipt] containsActiveAutoRenewableSubscriptionOfProductIdentifier:[Environment environment].premiumProductIAPId forDate:[NSDate date]];
        if (isActive){
          //enable premium
        }
      }  
      

      这似乎奏效了。如果有人有任何其他建议,请告诉我。

      我有一个疑问,当他取消并再次激活订阅时,主收据会发生什么情况?是否会生成新的收据,或者会发生什么?@Yohan我想下次此人启动应用程序时,您会收到一个通知,该通知将触发上述方法。