question

skyzoneentertainment avatar image
skyzoneentertainment asked

Sending a Message.

Hi, Amazon support team. Thanks to you, I can get a access token. and send the message. I used the source code that you gave me. The source code is in this address ( https://forums.developer.amazon.com/forums/thread.jspa?threadID=1452&tstart=0) [ the number of the parameters is incorrect, In "public void sendMessageToDevice(String regId, String registrationId, String accessToken) throws Exception" there are three parameters, but we just need 2 parameters] I know the message is { firstkey firstValue secondKey secondValue ..}. because this, JSONObject data = new JSONObject(); data.put("firstKey", "firstValue"); data.put("secondKey", "secondValue"); payload.put("data", data); => Is right? If It is not correct, how to send the message that i want. I got the Registeration ID when i run the sample ADMMessenger project through Logcat. so, when i used the source code(in this address ( https://forums.developer.amazon.com/forums/thread.jspa?threadID=1452&tstart=0)) I input the registerationId directly.!!! ============================================================ anyway, I succeeded in sending the message But, I can not receive the message. when i run the sample ADMMessenger, there are error. like this, http://98.109.64.40/ADMAdmin:8080/register?device=amzn1.adm-registration.v2.Y29tLmFtYXpvbi5EZXZpY2VNZXNzYWdpbmcuUmVnaXN0cmF0aW9uSWRFbmNyeXB0aW9uS2V5ITEhYk9YMjJjR0xDR3NCMDFWcSs4MVMwbTlON1RhOHRWUEdnWWY0MXF5eWlTSHdIS0F2bXhrRnl0UVFFRm55bDVSYW9HOS96N2thc3NOTGNNcHNuUDJEZk1OdDgzZnZxWW55d1dBUGFtbGtkTU5xN1pnWlM1a1dHZGg4SlpoOTFOZXdmbUVBbjN4QmdyVlJwZjNCck1Od2hxdE5yRnlhWTlyTE1iQ2ZIeU9taVM4aFNUUk1EcHE2cEFBaHB0a3R6bXd1TGpWOE9ZTWN1bk1UTGJuejE1Tm9LTUhub0FubXkvbS83UUI3WEZJbGdZL0N5amFxRHpTQWdKWWpzOXN0eThWc0tmTUsvK3NHaWZTZ2tVTVdWVWJBUzd6d1NpUHV1Um9hRk1Yd05kc1lnL0U9IUM3MmtWbm5oZmQ4UHpONkpEVU9DREE9PQ java.io.FileNotFoundException: http://98.109.64.40/ADMAdmin:8080/register?device=amzn1.adm-registration.v2.Y29tLmFtYXpvbi5EZXZpY2VNZXNzYWdpbmcuUmVnaXN0cmF0aW9uSWRFbmNyeXB0aW9uS2V5ITEhYk9YMjJjR0xDR3NCMDFWcSs4MVMwbTlON1RhOHRWUEdnWWY0MXF5eWlTSHdIS0F2bXhrRnl0UVFFRm55bDVSYW9HOS96N2thc3NOTGNNcHNuUDJEZk1OdDgzZnZxWW55d1dBUGFtbGtkTU5xN1pnWlM1a1dHZGg4SlpoOTFOZXdmbUVBbjN4QmdyVlJwZjNCck1Od2hxdE5yRnlhWTlyTE1iQ2ZIeU9taVM4aFNUUk1EcHE2cEFBaHB0a3R6bXd1TGpWOE9ZTWN1bk1UTGJuejE1Tm9LTUhub0FubXkvbS83UUI3WEZJbGdZL0N5amFxRHpTQWdKWWpzOXN0eThWc0tmTUsvK3NHaWZTZ2tVTVdWVWJBUzd6d1NpUHV1Um9hRk1Yd05kc1lnL0U9IUM3MmtWbm5oZmQ4UHpONkpEVU9DREE9PQ at libcore.net.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:177) at com.amazon.sample.admmessenger.MyServerMsgHandler$1.doInBackground(MyServerMsgHandler.java:63) at com.amazon.sample.admmessenger.MyServerMsgHandler$1.doInBackground(MyServerMsgHandler.java:1) ...... ======================================================================================= Actually I am not sure the server_address and server_port in the strings.xml of the sample ADMMessenger projects. I input , http://98.109.64.40/ADMAdmin 8080 Is right?
amazon device messaging
10 |5000 characters needed characters left characters exceeded

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
10 |5000 characters needed characters left characters exceeded

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

skyzoneentertainment avatar image
skyzoneentertainment answered
I really appreciate you helping so. Q1. When i test the sample app (ADMMessenger), I send the message using my app server and then I see the warning through Logcat of eclipse. like this, "SampleADMMessageHandler:onMessage Unable to extract message data.Make sure that msgKey and timeKey values match data elements of your JSON message" => i don't understand this warning. because, I input my app server, JSONObject payload = new JSONObject(); // Define the key/value pairs for your message content and add them to the // message payload. JSONObject data = new JSONObject(); data.put("firstKey", "firstValue"); data.put("secondKey", "secondValue"); payload.put("data", data); So, there are Not empty. !!! Q2. when i run the sample app, i saw the error through the Logcat of eclipse. java.io.FileNotFoundException: http://98.109.64.40/ADMAdmin:8080/register?device=amzn1.adm-registration.v2.Y29tLmFtYXpvbi5EZXZpY2VNZXNzYWdpbmcuUmVnaXN0cmF0aW9uSWRFbmNyeXB0aW9uS2V5ITEhWUQ4NWRjYTk2VHU1aXRvT2lZYU9jNGlHRTdHTU9oSHRiaTMzcjFOcUZCdkZUOVp6endBT0hoRmYreVdMNEZuQjlsUDhtWDkxSnR3RVVONEZFV2o1Qm9QM2FTZjV0RTdkYmMydDd3ZUNGRE9DSG11NUsyd1llNmttYnR5TzhFNmxMTXMzS3pBRzF1eXB1WVNsb1RqRmVEaE1YazQwdldITmQyN0J2NDZXc3JlUXpmVnRzWERHSjZmYWhXd2lONWVoVE04bFdXZ3gwaVpWTW9ZdFl2dFhXVTlpZkpOcEZNUHBmOGZrU3FXSEVpM2pUUUg1ZTZocHVtOGhxdTUzU043UC8yUEpMZ3dzSlIycGN4NnJub2VtY0RwUncxUEVqTEhOOGpoREthOC9BTDg9IXNCbTJMRVhETGJHZTM1REIwaWlBY3c9PQ [b][/b] at libcore.net.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:177) at com.amazon.sample.admmessenger.MyServerMsgHandler$1.doInBackground(MyServerMsgHandler.java:63) at com.amazon.sample.admmessenger.MyServerMsgHandler$1.doInBackground(MyServerMsgHandler.java:1) ..... why this error is occurred ??
10 |5000 characters needed characters left characters exceeded

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

skyzoneentertainment avatar image
skyzoneentertainment answered
and when I test, I thought server address is not correct, i changed the server address. and then there are error. like this, threadid=1: thread exiting with uncaught exception (group=0x40b111f8) FATAL EXCEPTION: main java.lang.RuntimeException: Unable to start activity ComponentInfo{com.amazon.sample.admmessenger/com.amazon.sample.admmessenger.MainActivity}: java.lang.RuntimeException: Stub! at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2035) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2060) at android.app.ActivityThread.access$600(ActivityThread.java:127) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1181) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4558) at java.lang.reflect.Method.invokeNative(Native Method) Caused by: java.lang.RuntimeException: Stub! at com.amazon.device.messaging.ADM. (Unknown Source) at com.amazon.sample.admmessenger.MainActivity.register(MainActivity.java:175) at com.amazon.sample.admmessenger.MainActivity.onCreate(MainActivity.java:50) at android.app.Activity.performCreate(Activity.java:4635) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1999) ....11more Shutting down VM why this error is occurred? How to delete the existing thread?
10 |5000 characters needed characters left characters exceeded

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
RuntimeException: Stub! error occurs when the ADM jar is exported to the apk. Please set up the dependency correctly in the project. Please go through this: https://developer.amazon.com/sdk/adm/setup.html#IDE In the above section, it's mentioned [b]Note: In the Properties window, there is also an "Order and Export" tab for the Java Build Path for your project. Do NOT mark the ADM .jar file as exported in this tab. Marking the .jar file as an exported entry causes your APK to use the stub implementations of the ADM API from the .jar file, rather than the actual implementations of the ADM classes that are on the device itself.[/b]
10 |5000 characters needed characters left characters exceeded

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
Your other questions are answered in this thread : https://forums.developer.amazon.com/forums/thread.jspa?threadID=1452&tstart=0
10 |5000 characters needed characters left characters exceeded

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

skyzoneentertainment avatar image
skyzoneentertainment answered
Hi ^^ I want to send message to users that installed the app (my app). Not specific just one user. How can I send message to users? I already try to search, but, I can't find this.
10 |5000 characters needed characters left characters exceeded

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

skyzoneentertainment avatar image
skyzoneentertainment answered
How to know the Many "REGISTRATION_ID_FOR_DESTINATION_APP_INSTANCE" ??? I can know the registration id of my device. I want to the Many [REGISTRATION_ID_FOR_DESTINATION_APP_INSTANCE]. How to do this? POST /messaging/registrations/(REGISTRATION_ID_FOR_DESTINATION_APP_INSTANCE)/messages HTTP/1.1 Host: api.amazon.com Authorization: Bearer (YOUR_ACCESS_TOKEN) Content-Type: application/json X-Amzn-Type-Version: com.amazon.device.messaging.ADMMessage@1.0 Accept: application/json X-Amzn-Accept-Type: com.amazon.device.messaging.ADMSendResult@1.0 { "data":{"key1":"value1","key2":"value2"}, "consolidationKey":"Some Key", "expiresAfter":86400 }[[b][/b][u][/u]
10 |5000 characters needed characters left characters exceeded

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

skyzoneentertainment avatar image
skyzoneentertainment answered
When I construct third party server(app server), 1. Should I receive the 'Register ID" in App server??? 2. Should I send the "Register ID" from app to External DB ??? Which one is better? Message was edited by: skyzoneentertainment
10 |5000 characters needed characters left characters exceeded

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, Sorry for the delay to respond. When you receive a registration id in app client in device you are supposed to send it to your app server and persist in DB (internal to your app server or external - running in some other host) against of your app users id. You can do it only for one time when the user starts the app for the first time (might be from onCreate). So when your app would have few users (or more), you are going to have all the reg id persisted in your db against the user id (the id you maintain in your app to identify the user). Now for sending ADM message to all of your users, we do not have any direct way to send message more than one reg id at a time. At this moment, you have to do it in a loop. POST /messaging/registrations/(REGISTRATION_ID1)/messages HTTP/1.1 POST /messaging/registrations/(REGISTRATION_ID2)/messages HTTP/1.1 POST /messaging/registrations/(REGISTRATION_ID3)/messages HTTP/1.1 So you have to call sendMessage() method from server for the sets of reg ids. Hope this is clear to you now.
10 |5000 characters needed characters left characters exceeded

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
Did you get answer of your question?
10 |5000 characters needed characters left characters exceeded

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