Actually,i have used ramachandru6#gmail.com as a "sender id" in my app and that same id and same password used for getting authentication tocken.but still am getting 401 error.
i have spent more than two days.please any one guide me.what i have to do?
IN GCM there is nothing like using id and password for authentication. When you set up your app in GCM it will give one server side token. Use that as a key
Related
I’m implementing Firebase Cloud Messaging (FCM) and am experiencing a problem that I’m unable to solve. I have implemented FirebaseMessagingService and FirebaseInstanceIdService according to the guide(s). When I go to Firebase Console for my app, and use the Notification function, I can successfully send a message to ALL my app instances (using the package name).
Now, in the code I have fetched the Firebase Instance Id (token) by use of the following code:
String token = FirebaseInstanceId.getInstance().getToken();
SendFirebaseTokenToServer(token);
(note that currently I’m using HTTP protocol, as my server does not yet have a cert). Anyway using the token I get from the call above, I go back to the Firebase Console and try to send a message to one (1) installed instance of my app. I grab the token from our server DB where it is stored as "varchar(max)". When I do that I get the following error message:
Invalid registration token. Check the token format.
I have googled that and found only one hit (having to do with Firebase and iOS):
http://stackoverflow.com/questions/41343520/ios-invalid-registration-token-check-the-token-format
That issue indicates that a cert was required (I think I’m reading it correctly). I’m not sure what I’m doing wrong. I need to get this to work using the Firebase Console first, then my server guy can start on his end knowing that it should work.
Turns out i was programatically encoding all POST or PUT parameters prior to sending to our server. the FCM token had a semicolon in it, which got encoded to a "%3A", seemingly causing the problem.
do NOT encode the FCM token.
I am using Node GCM.
The notifications are working fine in certain devices of my customer. Some phones have this issue where they do not get the notifications after a certain time period.
After checking the logs I saw the below error in some calls.
{"multicast_id":7040074623564131000,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"NotRegistered"}]
I do not get canonical_ids as 1 or above, for this response or on any responses before it.
I followed the steps mentioned in Canonical Registration ID and message ID format and I did not get any canonical ids in the response.
In some phones, the GCM works just fine so I'm not sure how to proceed from here and where to debug.
NotRegistered - is a message, which say, that there is no any GCM device registered with passed id. Just check id.
You must send push notifications only on devices, which are registered in GCM and in your app (via developer console).
You can test it with different Rest clients like postman. Just send your data on special url using json.
This generally happen if your device token not registered properly may be due to storage length ..so always use text instead of varchar and if use varchar then give the size above 200 .. ..
Thanks
I spended some days try to figure out how to resolve a similar problem and when I tried something I thought stupid it worked. In Android, when generating the token, I changed the scope from "GCM" to "" and after that i didn't receive NotRegistered anymore.
Change:
String token = instanceID.getToken(getString(R.string.gcm_defaultSenderId),
GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
To:
String token = instanceID.getToken(getString(R.string.gcm_defaultSenderId),
"", null);
I don't know why but it works to me.
Created two projects one for Android and another for iOS. Works total fine if using separated project number and api key. But my problem is that I want to use one pair project number and api key on my Server side, so if I change the sender id in iOS plist, it returns that the operation couldn't be completed with an error 401 when asking for a registration_id to GCM.
Anyone has ideas?
Thanks
Hmm sounds like maybe you generated the sender ID from the wrong developer console. It has to be a sender ID generated from the same project.
I am getting exception from google saying:
java.io.IOException: Received authentication challenge is null
I read that this is reproducing 401 error. So this
Indicates that the ClientLogin AUTH_TOKEN used to validate the sender is invalid.
But i have everything registreted and logined with ClientLogin successfully.
So what wrong could be?
Also do i need to reigstrate my app here ?
Sing up for C2DM
Because i haven't
Thanks
Have u register your app on the given link . Also you should get mail from C2DM on mail id which you have mention in Contact email address.
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");