Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/118.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
Objective c MKStoreKit自动恢复订阅_Objective C_Ios_In App Purchase_Mkstorekit - Fatal编程技术网

Objective c MKStoreKit自动恢复订阅

Objective c MKStoreKit自动恢复订阅,objective-c,ios,in-app-purchase,mkstorekit,Objective C,Ios,In App Purchase,Mkstorekit,我正在使用MKStoreKit处理自动恢复订阅。我目前正在测试一个1个月的订阅(在测试中,订阅持续5分钟)。购买订阅后,我会等待它过期。一旦到期,我会检查订阅是否仍然有效 [[MKStoreManager sharedManager] isSubscriptionActive:kSubscriptionMonthlyIdentifier] 这会像我预期的那样返回false。然而,由于它是自动续费的,我希望届时MKStoreKit会联系苹果公司重新验证订阅。也许我用错了MKStoreKit,但根

我正在使用MKStoreKit处理自动恢复订阅。我目前正在测试一个1个月的订阅(在测试中,订阅持续5分钟)。购买订阅后,我会等待它过期。一旦到期,我会检查订阅是否仍然有效

[[MKStoreManager sharedManager] isSubscriptionActive:kSubscriptionMonthlyIdentifier]
这会像我预期的那样返回false。然而,由于它是自动续费的,我希望届时MKStoreKit会联系苹果公司重新验证订阅。也许我用错了MKStoreKit,但根据和,它应该简单到:

//App Delegate
[MKStoreManager sharedManager];
//lets me know when the subscription was purchased
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(subscriptionPurchased:) name:kSubscriptionsPurchasedNotification object:nil];    
//lets me know when the subscription expires
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(subscriptionFailed:) name:kSubscriptionsInvalidNotification object:nil];

//In a view with subscription feature
if([[MKStoreManager sharedManager] isSubscriptionActive:kSubscriptionMonthlyIdentifier]){
    //access to subscription feature
}

//Where the user would purchase the subscription
[[MKStoreManager sharedManager] buyFeature:subscriptionId onComplete:^(NSString* purchasedFeature, NSData* receiptData)
{
...
}
 onCancelled:^
{
...
}
我的问题是,为什么当苹果端的订阅仍然活跃时,MKStoreKit不让我知道呢?

上面说:

为了进行测试,在生产环境和测试环境中自动更新订阅之间的行为存在一些差异

续费速度加快,自动续费订阅每天最多续费六次。这可以让您测试应用程序如何处理订阅续订,以及它如何处理过期后的续订,以及它如何处理包含间隙的订阅历史记录

由于到期和续订速度加快,订阅可能会在系统开始尝试续订订阅之前过期,从而在订阅期内留下一小段时间间隔。由于各种原因,生产中也可能出现此类失误。请确保应用程序正确处理这些失误。

你能试着:

  • 测试更长的订阅周期,以便“系统”有更多的时间续订(6mo=30min,1y=1h)
  • 运行计时器以持续检查订阅是否在延长时间后续订
  • 通过恢复购买来强制续订
  • 此外,请确保您在检查之前等待的时间不超过订阅期的六倍,因为订阅一天只能为单个测试帐户续订六次

    我正要开始在我自己的应用程序中实现这一点,所以如果遇到同样的情况,我会回信

    更新:

    我(在某处)读到,当一个应用程序在到期前24小时后启动时,会发生自动恢复。这可能很难在沙箱中复制。还可以通过刷新应用程序收据(>=iOS 7)或重新验证最近购买的收据( 我已将我的实现发布在上供您阅读