harsh-chhatwani avatar image
harsh-chhatwani asked

AMD- onRegistered called twice

Hi, I have integrated ADM with my app and I notice that the onRegistered of ADMMessageHandler is called twice. I checked the logcat for this. First it says "Registration state is stale, refreshing state" and calles onRegistered(). Then it says "Spurious call for registration of package " and calls the onRegistered() again. What might be the possible issue? I have double checked the implementation from
amazon device messaging
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

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi Harsh, Thanks for bringing this up. Repro steps: 1. Install the apk for the first time. 2. launch the app, register the device from onCreate (or from anywhere else). You should receive callback to onRegistered() of derived instance of ADMMessageHandlerBase. There is no problem so far. 3. Uninstall the app 4. Install the apk again. 5. Now from onCreate we need to check adm.getRegistrationId() before making a call to startRegister(). The problem starts now. Calling adm.getRegistrationId() would force onRegistered() to be called once (That should not happen) though adm.getRegistrationId() would return a null but onRegistered() would receive a non null reg id. Since adm.getRegistrationId() returns null, we would make a call to adm.startRegister() and that would result a second callback to onRegistered() with same registration id. if(adm.getRegistrationId() == null) // { adm.startRegister(); } else { } Please note this only happens after reinstalling (uninstall-install) the apk. The issue is reported to concerned team here and it would be fixed in the subsequent SDK release.
10 |5000

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