IAP auto-renewable subscription flow and renewal receipts

I use the RMStore library - here, what I have.

1) Purchase an automatic renewable subscription and confirm the return receipt.

[[RMStore defaultStore]addPayment:[Environment environment].premiumProductIAPId success:^(SKPaymentTransaction *transaction) { [[RMStore defaultStore].receiptVerificator verifyTransaction:transaction success:^{ //enable premium service } failure:^(NSError *error) { }]; } failure:^(SKPaymentTransaction *transaction, NSError *error) { }]; 

2). Each time the application starts, the subscription check is active for the date and includes a premium service, if it is

 RMAppReceipt *appReceipt = [RMAppReceipt bundleReceipt]; if (appReceipt){ NSInteger isActive = [appReceipt containsActiveAutoRenewableSubscriptionOfProductIdentifier:[Environment environment].premiumProductIAPId forDate:[NSDate date]]; //enable premium service if active } 

3) If the user launches the application on another device, he allows them to restore purchases, updating the receipt, if it exists, and checks if there is an active subscription for purchases.

 "In most cases, all your app needs to do is refresh its receipt and deliver the products in its receipt." 

- This is from the manual. Here is the code:

 [[RMStore defaultStore]refreshReceiptOnSuccess:^{ if ([receipt containsActiveAutoRenewableSubscriptionOfProductIdentifier:[Environment environment].premiumProductIAPId forDate:[NSDate date]]){ //enable }else{ //no longer active } } failure:^(NSError *error) { }]; 

My questions:

  • When RMStore checks if the subscription is active, it can return no, I look at the receipts, and that’s right, and I assume that it was not automatically updated. When I go to buy another subscription, I get a message from itunes that I have already signed up. The next time I start, I see a new receipt. This means that the receipt must be updated at startup, but I do not want to update it, because it causes a username and password that are not needed. What is the best practice here?
  • Am I restoring subscriptions to another device correctly? It seems that sometimes it takes several attempts to restore a subscription.
  • Is there a need, besides keeping records, to store the subscription on my server?
+5
source share
1 answer

I will try to answer my question.

There may be an update that was not detected primarily at startup, so the subscription looks inactive.

I added an observer to listen to ready-made transactions (RMStore extends this functionality of StoreKit).

Each time I receive this notification, I check the (updated) receipt for the active subscription and turn on the premium service, if any.

 - (void)storePaymentTransactionFinished:(NSNotification*)notification { BOOL isActive = [[RMAppReceipt bundleReceipt] containsActiveAutoRenewableSubscriptionOfProductIdentifier:[Environment environment].premiumProductIAPId forDate:[NSDate date]]; if (isActive){ //enable premium } } 

It seems to work. If anyone has any other suggestions, let me know.

+3
source

All Articles