maurouy avatar image
maurouy asked

What is the offline behaviour of the IAP API?

Hi, My question is the following: Suppose the device hasn't got a network connection. Will the initiateGetUserIdRequest FAIL? If not, will the initiatePurchaseUpdatesRequest FAIL? I'll expand a little bit, just to make clear why I'm interested in those questions. First of all, I've been working in the sandbox environment, which (I assume) doesn't let me test the offline behaviour. So, going back to my question, I'm interested in the situation because purchases are tied to a specific UserId. Then, if I can't get the userId, there is no way I could enable features because I won't be able to know what he has purchased. The second part of the question (whether the initiatePurchaseUpdatesRequest will fail or not) will let me know if it is required for my app to store the purchases made locally in order to make them available while offline. Final comment/suggestion: It would be great if this info was available in the documentation. Perhaps it is there but I couldn't find it? Thanks!
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Sorry for delayed response. Below are answers of your queries. 1. PurchasingManager.registerObserver() does not need internet connection and will work without any issue. OnSdkAvailable() will be called as expected. 2. PurchasingManager.initiateGetUserIdRequest() will work most of the time without internet connection. Following scenarios, it will require internet connection. a) If the user has cleared the appstore data after going offline. User needs to login before the getUserId can work. b) The user has not used the device for more than 30 days and license token of the app expires locally. Appstore needs to contact the server to get the license token for the app purchased by the user. 3.The SDK sends SUCCESSFUL PurchaseUpdatesResponse in the offline mode. The app doesn't have to check for internet connection for initiatePurchaseUpdatesRequest().
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.