How to get Auto-renewable in-app purchase status? - ios

I am implementing auto-renewable in app-purchase. Here user can access application on difrent devices either iOS or android. when user is in app and allow purchase a auto-renewable subscription Then
1). is he will get a transaction success method or something same?
if yes
Then i submit a success bool and subscription end-time on local-server by hit a api-url. but my problem is
2). how can i get to know that money has been deducted from itunes (in automatically renew process)?
3).how can i get subscriptions state to save it on local server, if user never use that app on that device, or he changed his device from iOS to android?

Related

How to Handle Canceled iOS In App Purchase Auto-Renewing Subscription

I'm wondering, if a user cancels a subscription and are trying to resubscribe am I supposed to present the management portal from within the App Store to this user and let them resubscribe from within the App Store or am I supposed to allow them to purchase a new subscription from within the App itself? It seems as if once a user has purchased the initial subscription from within the app itself Apple wants all other management to be done using the App Store.
I'm not exactly sure how this works and because I cannot access the 'Manage Subscriptions' portal for a sandbox App Store account I can't tell exactly how subscriptions are handled when they expire.
Thank you!
From the App Store subscription management page a user will be able to:
Change their auto-renew status
Upgrade or downgrade to a different subscription in the same group (e.g. change from a monthly to yearly subscription)
Resubscibe to an expired subscription
Paulw11’s comment is correct that you handle a re-subscribe exactly as a purchase in your app (the user won't receive a free trial if they had before). The purchase will go through as a normal subscription and it will be less confusing to your users.

Offering auto-renew subscriptions to multiple apps

As is confirmed by Apple here it should be possible to add the same auto-renew iap to multiple apps. I have an iPhone and an iPad app in which I want to offer one auto-renew iap, which when purchased once will unlock both apps.
To handle the subscription across both apps, I've setup a server where the auto-renew receipt is uploaded to once it's been purchased by the user. Each time a user opens one of these apps, a connection is made to the server to check if there is an active subscription, if there is one the app is unlocked, if not the 'buy a subscription' screen should pop up.
Now the question I am facing is how do I identify each user on the server when he checks for an active subscription ? How do I know when a user has bought a subscription before in on of the other apps ?
I have an iPhone and an iPad app in which I want to offer one auto-renew iap, which when purchased once will unlock both apps
I assume the iPhone and iPad app is not an universal app. Meaning, they do not share the same bundle ID. If it is an universal app, the receipt containing renewable subscriptions will be delivered as part of the App Store download.
how do I identify each user on the server
Since you don't want to bother the user with signing up for yet another account, you can persist the most recent active subscription date in iCloud. NSUbiquitousKeyValueStore is perfect for this. From a quick network inspection, this is how Ulysses seems to be handling universal subscriptions (they seem to be using a combination of iCloud KVS and CloudKit to determine if a user has already purchased a subscription on their Mac or iOS app). However, it now becomes an issue of whether your users have iCloud accounts.

Restore purchases in auto renewable app

In my Cocoa app, there is only auto-renewing subscription.
I check all the purchases when app starts and load the data only for purchased items.
I am also checking if there is any change(especially discontinuing the subscription) in the purchases every hour.(i.e I am not serializing user subscription in NSUserDefaults for security. They are always loaded from server when app starts)
Is it still necessary to put a Restore Purchases button in app ?
IMHO Restore button does not make any sense in app where you have only auto-renewing subscription.
Also is there any notification from apple when auto-renewable subscription ends ? Or what is the right way to check if the auto-renewing subscription has ended. Presently I am polling every hour for latest valid subscriptions.
You must need to provide a Restore Purchases option or functionality unless it will be reject by apple reviewer.
If you delete the app and again try to install this app then how to validate this user already having valid subscription.
Please check below what apple document says -
https://developer.apple.com/in-app-purchase/In-App-Purchase-Guidelines.pdf

iOS Auto-Renewable Subscriptions with sandbox test account

I have changed my client's current non renewable subscription in app purchase to an auto-renewable one, and when I test it on my iPhone with a test sandbox account it shows the "" message and goes through successfully. I receive all the content I would normally get, but I noticed the amount of days that gets returned from the "daysRemainingOnSubscriptionForProductWithIdentifier: productIdentifier" increases by ~1400 every time i try to purchase it again. Also, it doesn't seem to show if it auto renews or not (6 months -> 30 minutes)... The subscriptions remain paid even when I close the app out and delete it. Is this all part of the sandbox testing and how it functions? Because the in app purchase is/was working fine, I just created a new auto-renewable in app purchase product in itunes connect and replaced the productID of the non renewing subscription with the new auto-renewable one in the .plist file. Does anyone have any experience with this?

iOS InApp Purchase

I just wonder if there is anyway to check if a user(email) already buy an in app purchase item in my application.
For example I buy an item on my iPhone, then I log in on my iPad with same itune account. the application will know that this user did buy the item.
Thanks,
Huy
The same thing is happening when you use the restore purchased option in many applications.
SKPaymentTransactionStateRestored
is the constant retrieved from server when you tries to purchase an already purchased item.
Please check this nice tutorial about inApp purchase : inApp purchases
From the In-App Purchase Programming Guide:
Store Kit provides built-in functionality to restore transactions for
non-consumable products, auto-renewable subscriptions and free
subscriptions.
You can restore purchases with the StoreKit framework by calling the restoreCompletedTransactions method of the SKPaymentQueue. Your app will then receive a transaction for each product the user has previously purchased. Simply handle these transaction and unlock the features and/or download content on the new device.
If your product is a consumable (gold coins for your game, health packs etc.) this would not apply and you have to keep track of the purchases on your own.
You will need to set up a server that will keep track of each transaction. And you need to implement a method to authenticate the user across devices (signup via e-mail, Facebook login etc.). Once the user logs in on a new device, your server can tell the app what it should unlock/download.

Resources