I tried to play around with the gcm demo but I had some troubles to figure out why my server can't send message. I used the project number as sender ID for the android app and the server generated API key for the server side. I see that the app has registered to the server but once I send one message, the server crashes and shows :
message HTTP Status Code: 401
com.google.android.gcm.server.InvalidRequestException: HTTP Status Code: 401
com.google.android.gcm.server.Sender.sendNoRetry(Sender.java:177)
com.google.android.gcm.server.Sender.send(Sender.java:121)
com.google.android.gcm.demo.server.SendAllMessagesServlet.doPost(SendAllMessagesServlet.java:82)
javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
Any ideas how to fix that?
Related
This is complicated but I'll try to be as concise as possible. I am using FCM to send push notifications to Android devices. My backend is parse server. I can successfully send pushes from the FCM console to the device. And when I send pushes from parse to https://mybackend/parse/push, it says {"result": "true" } as the response. I have checked the server logs, and it (predictably) says all http post requests to /parse/push were 200 success.
However when sending from parse (using curl or the parse push console), the pushes do NOT show up in FCM console. There is some issue between parse server and FCM then.
In my index.js, I have:
push: {
android: {
senderId: "XXXXX",
apiKey: "YYYYYY"
}
}
I have the keys, and done everything according to here: http://parseplatform.org/docs/parse-server/guide/#push-notifications
what else am I missing? Why can't I get this to actually appear on the device? Any help is greatly appreciated, thanks.
Setting up a Parse Server for an Android app, I remember having to double check this to get it right. The key for me was this: when I logged into Firebase console and selected the app I was working on, and clicked on the gear [or cog or whatever] and then Project Settings, I had to make sure to click on the Cloud Messaging tab and grab the Legacy server key [under project credentials] NOT the web api key that appears on the General tab. Also the sender ID that you want to use appears on that page.
I'm not sure when they will deprecate the Legacy server key, you might try the Server key instead, but definitely make sure you get the info off of the Cloud Messaging tab.
I don't know why FCM (and APNs) don't send a different message when the key (or cert) is not set up right [that would be more developer-friendly at least] and instead just send a 200 but my guess is that they evaluate the key [or cert] after receiving the intended notification and sending a response.
I'm trying to send REST messages from ServiceNow tool to FCM, but getting "Invalid username/password combo" message. Firstly wanted to test this in POSTMAN, but still getting [JSON_PARSING_ERROR: Unexpected token END OF FILE at position 0.].
The full error message I get from ServiceNow is as following:
DEBUG: origin=push auth="MTdhMzhhNTJmZGMxNGQwMGJjNjY4Mjc5YTEzNDBiMWM6U1d0Y1RjOUE1T2paQWd2NTdmVUg=" Adding authorization header
SEVERE * ERROR * app="[APP_NAME]" request=b819e5c92ea4b2006ead1a337b41f078 origin=push elapsed=41 status=401 rest error message: Method failed: (/fcm/send) with code: 401 - Invalid username/password combo
As we're not using any login/password for REST message, I assume there must be an issue with Server Key. I've read many threads here about 401 error, but still could not fix an issue. I'm using the long one (not legacy) server key from FCM console cloud messaging tab.
Kindly help, if someone has any ideas
i am trying to send FCM push notification to my android app
on from postman i have on my developer console two api keys when i try to use the first one i get this response from FCM :
Unauthorized
Error 401
and when i try the second one i get this response from FCM :
Error=MissingRegistration
and i have this data in the body :
{ "data":{
"score":"5x1",
"time":"15:10"
}
,
"to":"*******"
}
the token is working fine and i have test it in the firebase console
what the problem could be and what is the solution
Error 401 Unauthorized comes beacuse of wrong server key.
To solve this error:
Go to your project settings in firebase console.
Click on Cloud Messaging and copy Server Key mentioned in that page.
Let me know, if more help is required.
I am working on an android app that will recieve push notifications from the GCM server.
I am using php as the 3rd-party server.
I've a few questions.
When I send request to gcm server from my php script it gives me the following response
{"multicast_id":8799227316277290616,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1341388064110557%5d17b789f9fd7ecd"}]}
Now the response seems fine but you can see a % sign in the message_id. Is that ok? if it's not than how am I able to recieve the correct message_ID?
When I use json_decode in my php script and echo this multicastid it gives me something like this
8.7992273162773E+18
and I am sure it will give the same type of value when I'll echo message_id also. So why it is not echoing the correct value?
My last question is that when I send this request which seems right and open my android application there is no notification there. Is it caused by the above errors or there is some other problem?
I had a similar issue with C2DM. The reason was that the android app name was not the same for which I requested the quota. It got fixed once the corrected the package name.
In my case, android application was not running so the push notifications can't be received. I started the app and then I could receive messages.
I am working with a messaging application using c2dm.. I get registered my app with c2dm..But the time am sending message to any particular id who is using my app, getting errors saying that "Sender Id mismatch".. What it will be ? can anyone help me ?
you need to set the sender_id in the client code with the email
address you registered to the c2dm servers (the one you use in the
http post to send messages).
usedintent.putExtra("sender","yourMail#gmail.com");