使用Parse iOS SDK检查用户是否有有效的自动续订订阅

我正尝试使用自动更新订阅来实现应用程序。 用户应该支付访问我的应用程序的所有function。 我已经使用Parse作为我的应用程序的后端。 它为inAppPurchases提供了一些API方法,但没有提到有关自动更新types。 我发现的唯一的东西是博客中的一些两年前的线程,据说接收validation只能用于可下载的购买。

我曾尝试使用它在文档中调用“简单购买”,它工作正常,但我不知道如何检查如果我的用户已经购买订阅或不。

有谁知道是否有办法通过parsingAPI或者这应该以另一种方式实现?

如前所述,接收validation仅内置于可下载内容的Parse SDK中,但创build云代码function非常简单,该function会将应用收据发布到iTunes Store进行validation。 以下是用于服务器端validation的Apple文档: 使用App Storevalidation收据

以下是一个基本的function:

Parse.Cloud.define('validateReceipt', function (request, response) { var receiptAsBase64EncodedString = request.params.receiptData; var postData = { method: 'POST', url: 'http://buy.itunes.apple.com/verifyReceipt', body: { 'receipt-data': receiptAsBase64EncodedString, 'password': SHARED_SECRET } } Parse.Cloud.httpRequest(postData).then(function (httpResponse) { // httpResponse is a Parse.Cloud.HTTPResponse var json = httpResponse.data; // Response body as a JavaScript object. var validationStatus = json.status; // App Store validation status code var receiptJSON = json.receipt; // Receipt data as a JSON object // TODO: You'll need to check the IAP receipts to retrieve the // expiration date of the auto-renewing subscription, and // determine if it is expired yet. var subscriptionIsActive = true; if (subscriptionIsActive) { return response.success('Subscription Active'); } else { return response.error('Subscription Expired'); } }); }); 

有关解释收据JSON的详细信息,请参阅收据字段 。 这对于iOS 7+来说是相当直接的,但是对于iOS 6和更早版本的自动更新订阅收据却是单调乏味的。