question

leotx avatar image
leotx asked

onMessage not firing

I'm able to register via onRegistered. And able to send a push to the Amazon server. But onMessage never fires. Below are my manifest and class. Any insight appreciated, thanks. ... public class WCADMMessageHandler extends ADMMessageHandlerBase { static final String TAG = "WCADMMessageHandler"; public static class WCADMReceiver extends ADMMessageReceiver { public WCADMReceiver() { super(WCADMMessageHandler.class); Log.i("wcadmmess", "wcADMReceiver constructor " ); } } public WCADMMessageHandler() { super(WCADMMessageHandler.class.getName()); Log.i("wcadmmess", "WCADMMessageHandler constructor " ); } public WCADMMessageHandler(final String className) { super(className); Log.i("wcadmmess", "WCADMMessageHandler(className) constructor " ); } @Override protected void onRegistered(final String newRegistrationId) { Log.i(TAG, "adm onRegistered = " + newRegistrationId); Engine.onDeviceID(newRegistrationId); } @Override protected void onMessage(final Intent intent) { Log.i(TAG, "Received ADM PUSH: " + intent.getExtras().toString()); } @Override protected void onUnregistered(final String registrationId) { Log.i(TAG, "onUnregistered " + registrationId); } @Override protected void onRegistrationError(final String errorId) { Log.i(TAG, "Registration FAILED. errorID " + errorId); } }
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.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi Leotx, Thank you for writing to us. I have couple of followup questions. 1. What the response code you are receiving while sending message from server? The response codes are discussed here : https://developer.amazon.com/sdk/adm/sending-message.html#ResponseFormat 2. While you are waiting for the message to be delivered in the device, have you tried pressing sync in the device top menu? 3. Which device you are using to test? 4. What are the versions of "Amazon Device Messaging", "Amazon Device Messaging Internal SDK" and "Amazon Device Messaging SDK" installed in your device?
10 |5000

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

LeonTx avatar image
LeonTx answered
Thanks. #1 -- looks like i'm getting a 400, reason "unregistered". i don't see Unregistered in the document you referred me to? #2 -- I will try the sync, but it looks like the error above makes it look like it's a registrationID issue? #3 -- Kindle Fire HD 7", Dolby Audio, Dual-Band Wi-Fi, 32 GB #4 -- I think all the latest, but I'll verify that and respond with that in a separate message.
10 |5000

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

LeonTx avatar image
LeonTx answered
I'm sure the reason I'm getting the Unregistered server-side error is because I'm now getting a App Client-side registration error. I know this has succeeded at least once, so not sure what's changed. Stack trace below, thanks... I/WORDCHUMS(26613): madm.startRegister called E/ActivityThread(24970): Service com.amazon.device.messaging.PrivateADMRegistrationService has leaked ServiceConnection com.amazon.identity.auth.device.authorization.api.AmazonCredentialManager$CredentialManagerServiceConnection@415c2c40 that was originally bound here E/ActivityThread(24970): android.app.ServiceConnectionLeaked: Service com.amazon.device.messaging.PrivateADMRegistrationService has leaked ServiceConnection com.amazon.identity.auth.device.authorization.api.AmazonCredentialManager$CredentialManagerServiceConnection@415c2c40 that was originally bound here E/ActivityThread(24970): at android.app.LoadedApk$ServiceDispatcher. (LoadedApk.java:980) E/ActivityThread(24970): at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:874) E/ActivityThread(24970): at android.app.ContextImpl.bindService(ContextImpl.java:1404) E/ActivityThread(24970): at android.content.ContextWrapper.bindService(ContextWrapper.java:387) E/ActivityThread(24970): at com.amazon.identity.auth.device.authorization.api.AmazonCredentialManager.synBindService(AmazonCredentialManager.java:409) E/ActivityThread(24970): at com.amazon.identity.auth.device.authorization.api.AmazonCredentialManager.access$2(AmazonCredentialManager.java:375) E/ActivityThread(24970): at com.amazon.identity.auth.device.authorization.api.AmazonCredentialManager$BindAndDoTask.doInBackground(AmazonCredentialManager.java:527) E/ActivityThread(24970): at com.amazon.identity.auth.device.authorization.api.AmazonCredentialManager$BindAndDoTask.doInBackground(AmazonCredentialManager.java:1) E/ActivityThread(24970): at com.amazon.identity.auth.device.authorization.api.AbstractCredentialManagerAsyncTask.doInBackground(AbstractCredentialManagerAsyncTask.java:1) E/ActivityThread(24970): at android.os.AsyncTask$2.call(AsyncTask.java:264) E/ActivityThread(24970): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305) E/ActivityThread(24970): at java.util.concurrent.FutureTask.run(FutureTask.java:137) E/ActivityThread(24970): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) E/ActivityThread(24970): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) E/ActivityThread(24970): at java.lang.Thread.run(Thread.java:856) I/wcadmmess(26613): wcADMReceiver constructor = I/wcadmmess(26613): WCADMMessageHandler constructor = I/WCADMMessageHandler(26613): Registration FAILED. errorID INVALID_SENDER
10 |5000

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

leotx avatar image
leotx answered
Ok, I'm finally receiving push notifications. By the time I had my server communicating with the ADM service, my api_key.txt file had gotten deleted, causing the registrations to start failing app-side, and thus the push http requests were failing server-side. So the code above is working as posted. 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.

Bipin@Amazon avatar image
Bipin@Amazon answered
For a pre-release or "debug" version of your app, you must create an API Key and store it as the only data in a file named api_key.txt . The api_key.txt file must be located inside the assets folder for your project. Note: ADM cannot recognize your API Key if it contains any spaces or line breaks. For a release or "production" version of your app, you may not need to create an API Key. Only if you sign the release version of your app using your own certificate, must you create an additional API Key for the release version of your app. Otherwise, if you allow Amazon to sign your app on your behalf, you do not need to create an additional API Key.
10 |5000

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