【问题标题】:Auto renewable IAP subscription user flow & refreshing receipts自动更新 IAP 订阅用户流和刷新收据
【发布时间】:2015-11-16 13:37:15
【问题描述】:

我正在使用库 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) {

}];

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 收到一条消息,说我已经订阅了。在随后的启动中,我看到了新收据。这表明收据需要在启动时刷新,但我不想刷新它,因为它会弹出用户名和密码,这是不必要的。这里的最佳做法是什么?
  • 我是否以正确的方式恢复另一台设备的订阅?有时似乎需要多次尝试才能恢复订阅。
  • 除了记录保存之外,是否需要在我的服务器上存储订阅?

【问题讨论】:

    标签: ios in-app-purchase rmstore


    【解决方案1】:

    我会试着回答我的问题。

    可能存在在启动时未检测到的续订,因此订阅显示为非活动状态。

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

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

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

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

    【讨论】:

    • 我有一个疑问,当他取消并再次激活订阅时,主收据会发生什么?是否会生成新收据或会发生什么?
    • @Yohan 我想你会在下次该人启动应用程序时收到通知,这将触发上述方法。
    猜你喜欢
    • 2014-11-10
    • 1970-01-01
    • 2015-09-15
    • 2021-02-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-16
    相关资源
    最近更新 更多