question

101apps avatar image
101apps asked

Are Shared Preferences necessary for Entitled products?

hi i am a bit confused as to whether or not i need to save details of purchased Entitled products or whether Amazon keeps a record? my app scenario: a webview displays a webpage with a number of items for purchase (which i will update by adding new items to). the user clicks a button to purchase an item (a zip file containing a number of images). as i understand it, each of these items that i have for sale should have a unique SKU (which i enter in the Amazon app portal). now, i intend adding new items to the catalog (webpage) so i assume all i need to do is to add the new item's SKU to the Amazon app portal? (my second question) as i understand the Entitle option, the user purchases the item and they are now entitled to use this item on any of their registered devices. my question is, do i need to save on the device (in shared preference file) a list of these items (should they purchase more than one "package") which is then "somehow" updated if another device purchases an item? - or does amazon keep a record of these entitled purchases (like kindle books) so if a user were to delete my app from all their devices, and then re install it, they would then once again have access to the "packages" or items that they have already bought and to which they have entitlement? appreciate some help thanks regards clive Message was edited by: 101apps
iap
10 |5000

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

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi 101apps, Thank you for your post. You should have a persistence mechanism (permanent) to keep track of all entitled items of your app. Shared Preferences are not recommended way to do this since all the Shared Preferences are gone if someone clears data from app setting. You can use device's file system, sql lite or remote database for the persistence of the entitled items so that you can keep unlock the items with every app launch. There is method provided in PurchasingManager named as initiatePurchaseUpdatesRequest(), if you call it, you should receive a callback on onPurchaseUpdatesResponse() in your PurchasingObserver, that would help you to be notified for the user who logged in other devices in the same app in case of item purchase by that user in other device. Or if some one deletes and re-installs the app, you would receive the list of already entitled items by the current user for the current app in onPurchaseUpdatesResponse() in your PurchasingObserver. The list contains the items that are revoked (in case) from back end by user. So you should check if the listed items (returned by onPurchaseUpdatesResponse()) are not delivered to the current user, you should deliver them. Or some items are revoked, so you should lock them in app. This way you could sync the entitlements for the same user and same app across the devices. If you intend to add new purchasable items in you app, you should define the IAPs in portal in the app settings, submit them and configure those items in the catalog in your app with correct SKU. Hope this helps. Please let us know if you have further query.
10 |5000

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

101apps avatar image
101apps answered
hi thanks for the reply. two more questions: 1) i would like to access the shared preferences file (as per the ButtonClicker sample app) in the main activity's onCreate() but calling getSharedPreferencesForCurrentUser() returns null because the currentUser is null at this stage (even calling getCurrentUser() returns null here). so how do i get the currently logged in user in the activity's onCreate() because i would like to check the values of the shared preferences for the current user here 2) if a record of the user's purchases are only stored on the device (in a file, shared preferences, database or whatever), what happens if they lose the device (stolen, broken or whatever) and they get a new device? does amazon not keep a record of these purchase? where does getPurchaseRequestStatus get it's information from? the documentation states that PurchasingManager.initiatePurchaseUpdatesRequest(Offset) will list all entitlements for this customer - so am i right in thinking that amazon does keep a record of all entitlement products? appreciate your help thanks regards
10 |5000

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

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi 101apps, Thanks for the queries. Below are the answers, 1. You cannot directly get the user in onCreate() since you have to ask PurchasingManager for it and PurchasingManager would give it back to you asynchronously. The call flow should be like this, Activity.onCreate() --> PurchasingManager.initiateGetUserIdRequest() --> ButtonClickerObserver.onGetUserIdResponse(getUserIdResponse) In your BasePurchasingObserver's derived class you should override the method named onGetUserIdResponse. public void onGetUserIdResponse(final GetUserIdResponse getUserIdResponse) { String userId = getUserIdResponse.getRequestId(); baseActivity.setCurrentUser(userId); //You can not (should not) access the user before this point. now getCurrentUser() would return a valid string in your activity } 2. Yes. Amazon certainly does keep records of all the in-app transactions. As I mentioned in the previous post, initiatePurchaseUpdatesRequest would help you to be notified in the app for the user who logged in other devices in the same app in case of item purchase by that user in other device. Or if some one deletes and re-installs the app, you would receive the list of already entitled items by the current user for the current app in onPurchaseUpdatesResponse() in your PurchasingObserver. So if the current device is lost, when user would use same account for the same app, in onPurchaseUpdatesResponse() you would notified about all the entitled and revoked items for that user. Please not that would happen only for [b]Entitlement and Subscription[/b] type of items.
10 |5000

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