question

101apps avatar image
101apps asked

help with Offset, please!

hi appreciate some help regarding Offset. okay, i understand that i need to call [b]initiatePurchaseUpdatesRequest[/b] passing the offset as parameter. i do this in the activity's onResume(). i understand that this invokes [b]onPurchaseUpdatesResponse[/b]. so in my app, i am able to get the user ID and request ID here. but i should also be able to get a set of receipts here, from which i would like to retrieve the purchase SKU's so as to update my apps shared preferences for the entitlements. now, even though i make a"purchase" in the test environment, and everything works OK,
iap
10 |5000 characters needed characters left characters exceeded

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
seems i was "kicked" out before i could finish my post.... here's the rest of it! i get an empty set of receipts in onPurchaseUpdatesResponse. is this because i may have put the incorrect Offset as the parameter when calling initiatePurchaseUpdatesRequest? here's my code, called in activity's onResume(): String requestID = PurchasingManager.initiatePurchaseUpdatesRequest(Offset.fromString(getApplicationContext() .getSharedPreferences(getCurrentUser(), Context.MODE_PRIVATE) .getString(OFFSET, Offset.BEGINNING.toString()))); finally, i'd apprecite some more info on Offset. what is it, where is it created, and where is it saved? how will i be able to determine an offset when calling initiatePurchaseUpdatesRequest? is the only way as per my code above? thanks much appreciated 101apps
10 |5000 characters needed characters left characters exceeded

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. Basically, Offset marks the beginning of the data set. It represents a position in a set of paginated results. Operations that take an Offset as input will ultimately provide an Offset as output that you can use to get the next set of results, if more results are available. In ButtonClicker example we have called it in first time as below. PurchasingManager.initiatePurchaseUpdatesRequest(Offset.fromString(baseActivity.getSharedPreferences(baseActivity.getCurrentUser(), Context.MODE_PRIVATE).getString(OFFSET, Offset.BEGINNING.toString()))); initiatePurchaseUpdatesRequest() initiates a request to retrieve updates about items the customer has purchased and/or revoked since last time you checked based on offset. A good use of this operation is to invoke it once per application run to make sure your view of ownership is consistent across devices. This operation works with paginated data. The beginning of the data set is specified by the Offset you provide here. The response will contain an Offset marking the beginning of the next data set, if more is available. PurchaseUpdatesResponse contains a method named isMore(), it returns true if more results are available. The default value (first time) of offset should be Offset.BEGINNING.toString(). Use getOffset() of PurchaseUpdatesResponse instance what you receive in first call to retrieve the offset which you can pass toPurchasingManager.initiatePurchaseUpdatesRequest(Offset) to retrieve more results. Javadoc is available here for more information, https://images-na.ssl-images-amazon.com/images/G/01/mobile-apps/devportal2/content/sdk/javadoc-v104/com/amazon/inapp/purchasing/PurchasingManager.html#initiatePurchaseUpdatesRequest%28com.amazon.inapp.purchasing.Offset%29 https://images-na.ssl-images-amazon.com/images/G/01/mobile-apps/devportal2/content/sdk/javadoc-v104/com/amazon/inapp/purchasing/Offset.html https://images-na.ssl-images-amazon.com/images/G/01/mobile-apps/devportal2/content/sdk/javadoc-v104/com/amazon/inapp/purchasing/PurchaseUpdatesResponse.html#isMore%28%29 Please note above thing is applicable only for [b]Entitlement and Subscriptions[/b] type of IAP items. It’s important to note that receipts for consumables will only be send to the “purcahseResponse” handler.
10 |5000 characters needed characters left characters exceeded

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