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/...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...
=========== Update 1:
On different testing devices the result is different. On Amazon Fire 7 Tablet all is dead. But on Xiaomi Redmi S2 PurchasingListener is alive but gives empty data for products. Here is the logs:
... D/IAPListener: onUserDataResponse: get user id (l3HL7XppEMhrOGDnur9-ulvqomrSg6qyODKmah76lJU=, marketplace (US)
... D/IAPListener: onProductDataResponse: RequestStatus (SUCCESSFUL)
.... D/IAPListener: onProductDataResponse: successful. The item data map in this response includes the valid SKUs
.... D/IAPListener: onProductDataResponse: response.getProductData(): {}
.... D/IAPListener: onProductDataResponse: 0 unavailable skus
.... D/IAPListener: onPurchaseUpdatesResponse: requestId (a5db322e-d894-4ebf-896a-9007140c91d2) purchaseUpdatesResponseStatus (SUCCESSFUL) userId ()
The same is on Samsung Galaxy Tab A
For future reference, double-check the following:
Make sure amazon.sdktester.json
is in the right location. Open Amazon App Tester, expand the "IAP Items in JSON File" section to ensure it can read your IAP items
As per your discovery, double-check the configuration in Amazon App Tester and reset everything back to default as needed
Set your app to sandbox mode:
adb shell setprop debug.amazon.sandboxmode debug
Ensure ProGuard is setup properly (or temporary disable it to help isolate the issue)
Test with one of the IAP samples to isolate any configuration issue with Amazon App Tester. The sample apps should work as is without any modification (step 1-3 above is still relevant).
Hope that helps~