question

Dje avatar image
Dje asked

Unable to start receiver

I implemented the amazaon in app purchase in my application. I try to check if a user bought some entitlement. So I call a static function : public static void CheckInAppPurchases(Context context) { cAmazonPurchase a = new cAmazonPurchase(context); AmazonPurchasingObserver purchasingObserver = new AmazonPurchasingObserver(a); PurchasingManager.registerObserver(purchasingObserver); PurchasingManager.initiateGetUserIdRequest(); } It works well when the context is an activity, but I have to check it from a remote service. When calling this function from my service (passing the service as the context parameter), I have got a : exception=java.lang.RuntimeException: Unable to start receiver com.amazon.inapp.purchasing.ResponseReceiver: java.lang.NullPointerException My question, is, is it possible to check if a user bought some entitlement from a remote service, and how ? Thanks in advance. Best regards,
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 Dje, Thank you for posting. Our IAP sdk is always used from activities and not from remote services (at least never tested!). Could you please let me know why do you need to register observer from a remote service and query IAP server to know whether given entitlements are bought by user or not? If you do the same from activity, there is well defined and documented way there to do the same. Before raising this issue to concern team I need to have a convincing reason. Please explain. 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.

Dje avatar image
Dje answered
Hi, Thank you for your answer :) My Application is RecForge an audio recorder : a previous release (without in app purchase) is available on the Amazon App store, else the RecForge II release (the one I'm working on) is only available on the play store for the moment. In the "free" version, the recording time is limited to 3 minutes. User can unlock it by purchasing an untitlement. All the audio part is handled in a service. The problem is that you can start the service either by launching an activity, or by a widget. In the second case, no activity is started. So I thought that checking the in app purchase in the service was the best solution. Thanks in advance, Best 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 Dje, Can't you have an activity to start the Audio service and that activity would be started from both your widget and launcher activity? The activity in the middle would initiate IAP calls. e.g. register the observer, initiatePurchaseUpdatesRequest and check whether the entitlement is bought by the user or not in PurchasingObserver.onPurchaseUpdatesResponse(PurchaseUpdatesResponse) callback asynchronously. You have to force user waiting in this activity until the response is received (please add a waiting view in this activity while checking the purchase status). Once the response is received in onItemDataResponse in the observer (the derived class you write by extending BasePurchasingObserver), you should start the service if the user has already purchased the item or show a catalog view (in the same activity) where user could get a link to buy the item. If user buys the item you should start the service in PurchasingObserver.onPurchaseResponse(PurchaseResponse) callback. To optimize, you could persist the purchase record after receiving for first time in the local memory so that you can start the service without starting the "middle" activity if record is found in memory. Hope it makes sense. 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.

Dje avatar image
Dje answered
Hi, Thank you for the reply. I will try to implement your solution. Best regards, Dje073.
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
Sure. Let me know the result. Good luck.
10 |5000

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

Dje avatar image
Dje answered
Hi, Would it be dificult to add the possibility to use the IAP sdk from a remote service ? I implemented your solution, but I'm not satisfied with it. This activity shouldn't exist, it's just a workarround but that is not a clean method to developp an Android application. More, the Google IAP sdk doesn't need it, and it's more dificult to maintain 2 versions of the application when there are such diferences. I would really like that you add this feature in a next release of the IAP SDK. Thanks in advance, Best regards, Dje073.
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 Dje, I'm going to forward this feedback/suggestion to the concern team. Please stay tuned on Mobile App Distribution Portal or Blogs ( https://developer.amazon.com/blog/index.html) for any updates related to this. 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.

Dje avatar image
Dje answered
Thank you very much :)
10 |5000

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

Dje avatar image
Dje answered
Hi, Is there some good news about this ? Best regards, Dje073.
10 |5000

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

Dje avatar image
Dje answered
I have still no news (here + twitter ...) Without this update I won't be able to publish my application on Amazon. Should I give up ?
10 |5000

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