我正在使用MKStoreKit处理可自动续订的订阅。我目前正在测试一个月的订阅(在测试中,订阅持续5分钟)。在我购买订阅后,我等待它过期。一旦过期,我会检查订阅是否仍然有效。
[[MKStoreManager sharedManager] isSubscriptionActive:kSubscriptionMonthlyIdentifier]正如我所期望的那样,这将返回false。然而,由于它是自动续费的,我预计届时MKStoreKit会联系苹果重新验证订阅。也许我用错了MKStoreKit,但根据docs和blog post的说法,它应该很简单:
//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不让我知道呢?
发布于 2013-10-17 07:29:47
为了便于测试,在生产环境和测试环境中,自动可更新订阅之间的行为存在一些差异。
续费速度加快,自动续费订阅每天最多续费6次。这让您可以测试应用程序如何处理订阅续订,以及如何处理过期后的续订,以及如何处理包含差距的订阅历史记录。
由于过期和续订速度加快,订阅可能会在系统开始尝试续订之前过期,从而在订阅期间留下较小的间隔。这样的失误在生产中也是可能的,原因多种多样--确保你的应用程序正确地处理它们。
你能试着:
此外,作为详细的here,请确保您在检查之前没有等待超过订阅周期的六次,因为订阅一天只能续订单个测试帐户六次。
我正要开始在我自己的应用程序中实现这一点,所以如果我遇到同样的情况,我会回信的。
更新:
我读到(在某个地方),当应用程序在到期前24小时后启动时,就会发生自动续费。这可能很难在沙箱中复制。也可以通过刷新应用收据(>= iOS 7)或重新验证最近购买的收据(< iOS 7)来强制续订。
我已经在github上发布了我的实现,供您阅读。
https://stackoverflow.com/questions/12430994
复制相似问题