gpt4 book ai didi

objective-c - MKStoreKit 自动更新订阅

转载 作者:可可西里 更新时间:2023-11-01 05:46:19 25 4
gpt4 key购买 nike

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

[[MKStoreManager sharedManager] isSubscriptionActive:kSubscriptionMonthlyIdentifier]

这会像我预期的那样返回 false。但是,由于它是自动续订的,我希望 MKStoreKit 届时会联系 Apple 以重新验证订阅。也许我用错了 MKStoreKit,但根据 docsblog 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:^
{
...
}

我的问题是,当订阅在 Apple 端仍然有效时,为什么 MKStoreKit 不让我知道?

最佳答案

documentation说:

For the sake of testing, there are some differences in behavior between auto-renewable subscriptions in the production environment and in the test environment.

Renewal happens at an accelerated rate, and auto-renewable subscriptions renew a maximum of six times per day. This lets you test how your app handles subscription renewal and how it handles a renewal after a lapse and how it handles a subscription history that includes gaps.

Because of the accelerated expiration and renewal rate, the subscription can expire before the system starts trying to renew the subscription, leaving a small lapse in the subscription period. Such lapses are also possible in production for a variety of reasons—make sure your app handles them correctly.

你能不能试试:

  1. 测试更长的订阅期,以便“系统”有更多时间续订(6mo = 30min,1y = 1h)?
  2. 运行计时器以持续检查订阅是否在延长的时间后续订?
  3. 通过恢复购买来强制续订?

另外,详见here确保您在检查之前等待的时间没有超过订阅期的六倍,因为订阅每天只能为单个测试帐户续订六次。

我正准备开始在我自己的应用程序中实现它,所以如果我遇到同样的情况,我会回信。

更新:

我(在某处)读到,当应用程序在到期前 24 小时后的一段时间内启动时,就会发生自动续订。这可能很难在沙箱中复制。也可以通过刷新应用收据 (>= iOS 7) 或重新验证最近购买的收据 (< iOS 7) 来强制续订。

我已经在 github 上发布了我的实现供您阅读。

关于objective-c - MKStoreKit 自动更新订阅,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12430994/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com