question

Sargius avatar image
Sargius asked

Amazon IAP Android PurchasingListener never called

I am trying to implement a subscription IAP on Android using the Amazon SDK (3.0.3). I made all things as described in Amazon appropriate documentation and their sample app and configured Amazon App Tester properly. However have no luck, I am getting no responses from PurchasingListener.


The ResponseReceiver has following structure in Manifest:



<receiver android:name = "com.amazon.device.iap.ResponseReceiver"

android:permission = "com.amazon.inapp.purchasing.Permission.NOTIFY"

android:exported="true">

<intent-filter>

<action android:name = "com.amazon.inapp.purchasing.NOTIFY" />

</intent-filter>

</receiver>


I register PurchaseListener in onCreate():


PurchasingService.registerListener(this.getApplicationContext(), purchasingListener);


Then make this call in onStart()


final Set<String> productSkus = new HashSet<String>();

for (final MySku mySku : MySku.values()) {

productSkus.add(mySku.getSku());

Log.d(TAG, "onStart: call getProductData for skus: " + mySku.getSku());

}


PurchasingService.getProductData(productSkus);



and finally in onResume():


PurchasingService.getUserData();

PurchasingService.getPurchaseUpdates(false);


Nothing from these call had returned any response. The Listener itself is registeres, as I can see in logs:


2022-07-27 18:50:14.791 11790-11790/......amazon D/d: Appstore SDK - Sandbox Mode: PurchasingListener registered: ......amazon.iap.SamplePurchasingListener@b3c6192



It is important to say, that if I am using old style receiver structure in Manifest (without "android:permission = "com.amazon.inapp.purchasing.Permission.NOTIFY" under <receiver tag), like here:


<receiver android:name = "com.amazon.device.iap.ResponseReceiver"

android:exported="true">

<intent-filter>

<action android:name = "com.amazon.inapp.purchasing.NOTIFY"

android:permission = "com.amazon.inapp.purchasing.Permission.NOTIFY"/>

</intent-filter>

</receiver>


, I am getting some responses, but very frustrating, since it is not what is expected to be, and this permission is highlighted with err:


Protecting an unsupported element with a permission is a no-op and potentially dangerous


The logs in this case show:


2022-07-27 19:07:11.673 12723-12723/.....amazon D/e: Appstore SDK - Sandbox Mode: sendGetUserDataRequest

2022-07-27 19:07:11.684 12723-12723/.....amazon D/e: Appstore SDK - Sandbox Mode: sendPurchaseUpdatesRequest/sendGetUserData first:e0656912-440d-4c7d-a864-0548028a803d

2022-07-27 19:07:11.743 12723-12723/.....amazon D/e: Appstore SDK - Sandbox Mode: handleResponse

2022-07-27 19:07:11.895 12723-12723/......amazon D/IAPListener: onProductDataResponse: RequestStatus (SUCCESSFUL)

2022-07-27 19:07:11.897 12723-12723/.....amazon D/IAPListener: onProductDataResponse: successful. The item data map in this response includes the valid SKUs

2022-07-27 19:07:11.897 12723-12723/antivirus.cleaner.fire.tablet.security.applock.booster.amazon D/IAPListener: onProductDataResponse: 0 unavailable skus


... and no other things are out there. Button for puchasing is dead and no other responses!



I don't minify the code with Proguard.


Testing device Amazon Fire 7 Tablet.


Target SDK - 32.



I stuck here for a long time, will be highly grateful if anyone could help me with this question!


Thank you in advance...


iapamazon appstoreandroidsdk
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

Levon@Amazon avatar image
Levon@Amazon answered

Hi Sargius,

I assume it's some sort of a setup / configuration error? I would suggest running a sample app included in the SDK to ensure that IAP works at all for you (it should).

As for your specific case:
- in the manifest, the permission should be attached to the receiver, and not to action. So the correct way is to have it just like it's described in the documentation:

<application>
  ...
  <receiver android:name = "com.amazon.device.iap.ResponseReceiver"
      android:permission = "com.amazon.inapp.purchasing.Permission.NOTIFY">
    <intent-filter>
      <action android:name = "com.amazon.inapp.purchasing.NOTIFY" />
    </intent-filter>
  </receiver>
  ...
</application>

- ensure that you exported correct IAP items from your Developer Portal account, for the app that you are testing.
- could you please try to reduce the targetSdkVersion to something like 28, and see if it works for you?

10 |5000

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