且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

通知取消应用内购买的自动续订

更新时间:2022-12-31 13:30:54

您可以通过向Apple的服务器发送收据验证来查找用户订阅的到期日期。请查看 In-App Purchase Programming Guide

You can find the expiration date of a user's subscription by sending a receipt verification to Apple's servers. Check out figure 1-3 on the In-App Purchase Programming Guide.

基本上步骤是:


  1. 在设备上,获取应用内购买的交易收据。您在交易过程中保存的或通过调用 [SKPaymentQueue restoreCompletedTransactions]

  2. 将该收据发送到您的服务器。 (这比尝试直接从应用程序对苹果服务器进行收据验证更为可取,因为这将要求您在设备上存储共享密钥。)

  3. 将收据发送到Apple的服务器,并在响应中查找名为 expires_date 的密钥(表示为自1970年1月1日以来的毫秒秒)。

  1. On the device, get a transaction receipt for an in-app-purchase. Either one you've saved during a transaction or by calling [SKPaymentQueue restoreCompletedTransactions].
  2. Send that receipt to your server. (This is preferred over trying to do a receipt verification with Apple's servers directly from the app, since that would require you to store your shared secret on the device.)
  3. Send the receipt to Apple's servers from your server, and in the response look for a key named expires_date (expressed in milli seconds since Jan 1, 1970 GMT).

我使用本指南帮助我在服务器端:使用PHP和cURL验证App App Purchase的Apple App Store收据

I used this guide to help me on the server side: Verifying Apple App Store Receipts For In App Purchases With PHP and cURL.

无法确定用户是否已启用或关闭自动续订。 Apple不允许您访问此信息。唯一的方法是等到有效日期过期而没有续订。

There is no way to determine if the user has auto-renewal turned on or off. Apple doesn't give you access to this information. The only way is to wait until the expiration date passes without a renewal.