I'm getting the error:
Android: Error: Invalid Registration
What could be the possible reason for this? I've followed all the steps given by CleverTap for integration but not sure why the error is still there...
Using GCM.
Based on the error code response, if you receive the error InvalidRegistration try to check the format of the registration token you pass to the server. Make sure it matches the registration token the client app receives from registering with GCM. Do not truncate or add additional characters.
For more information, you can also check this SO question.
The error "Invalid Registration" typically pops up if either the GCM Sender ID that has been used in the project is incorrect, or if the Server API key you have added to your CleverTap dashboard (i.e., in your Android Push Notification settings) is incorrect.
To solve this, please re-confirm if the GCM Sender ID in your application matches its Project Number from your GCM Console, then please generate a new Server API key, whitelist the required IP addresses (mentioned on the Android Push Notification settings page on the CleverTap dashboard), then go to your Android Push Notification settings on the CleverTap dashboard to re-add the key.
Related
I am building an push notification service using https://github.com/geeknam/python-gcm
this requires an API_KEY and Registation ID of device to send message.
I have created an app on console.developers.google.com and have got the API_KEY.
Now i have no clue how to get the Registration ID.
Are there dummy app(s) on installation of which it will return registration ID or something like that ?
I have created an app on console.developers.google.com and have got the API_KEY.
You'll only be able to get a valid Server Key when you create a project in Firebase Console. API Keys (recently) generated in the Developer's Console would not work for GCM (and FCM). From the note in the docs (under Server Key):
Starting from September 2016, you can create new server keys only in the Firebase Console using the Cloud Messaging tab of the Settings panel. Existing projects that need to create a new server key can be imported in the Firebase console without affecting their existing configuration.
Are there dummy app(s) on installation of which it will return registration ID or something like that?
You'll have to create your own dummy app where you'll have to call the getToken() to generate a Registration token (aka Registration ID). See the FCM Quickstart in GitHub.
I have a self hosted parse-server, when i create a new android user the device token in the database doesn't get set. as a note i am using fcm for push
has anyone got FCM to work with parse server?
I dont think this is possible. Reading from the Pushwoosh website who replaced Parse (since Parse was acquired by Facebook):
GCM Android Push notifications, which are being replaced by FCM now,
require you to create a Project in Google Developer Console and use
your own Sender ID and Server Key. In order to simplify the
configuration process, Parse offered to use their internal Sender ID
and Server Key to send push notifications. If you used the default
Parse Android push configuration settings and didn’t register your own
GCM sender ID and GCM Server key, all your GCM tokens belong to Parse.
This is what we never did at Pushwoosh and we always asked our users
to register their own GCM Sender ID and GCM Server Key. What is
important to understand is that Parse will never share his Private
Server Key as it would compromise all Android push tokens from any
Parse-based project.
What Does It Mean?
It means that you can use the default Sender ID and API key registered
in Parse only to send push notifications via Parse. You can’t migrate
these device tokens to another push service since you don’t have
Parse’s Server Key. In that way these tokens can be considered gone.
The only solution – you should start collecting new push tokens as
soon as you can.
In short you have to use only one.
i actually found a solution.
via https://firebase.google.com/support/guides/parse-android#firebase-notifications
so effectively there is a fix, parse uses the old way of collecting the token via gcm request token method, fcm now auto calls for a token at the time the application first installs. this creates a mismatch hence parse doesn't actually work well with fcm sdk.
but you can actually use them together and although both gcm and fcm get different tokens both these tokens actually point to the same device. i have tested this and it does work well using both tokens from a private parse server.
you must ensure you are using the "ParsePushBroadcastReceiver" or either you use a custom class as the link says. thing is you "FirebaseMessagingService" class and you custom gcm receiver class will both fire when a message comes in. so what i did was receive messages with the FirebaseMessagingService class and filter as required.
I'm trying to create a Xamarin android app with GCM push notifications using this plugin:
https://github.com/rdelrosario/xamarin-plugins/tree/master/PushNotification
I followed the instructions in the readme page and changed ANDROID SENDER ID with my google project number (obtained from the google developer console).
I can successfully register the device using the Register function (the OnRegisteredfunction on the CrossPushNotificationListener class is fired and a valid registration token is returned).
To send a notification I used this tool (because i don't have a backend up and running):
http://apns-gcm.bryantan.info/
I filled:
The Device Token field either with the token obtained with the
previous device registration or with "/topics/global"
The Message field with a random message
The Api Key with a Server API Key generated from the google
developer console
The app never reaches the OnMessage and nothing seems to be received.
What am I doing wrong?
Thanks in advance
I have used gcm demo code for viewing working of different features of gcm.But unfortunately it is showing some error.My client side is gcm quickstart code ,which is working finely,successfully sent notification using command code(gcm sender) .But i have few doubts-
Is it possible to send message/notification from gcm demo code to gcm quickstart?
2.I have used sender id and api key of gcm quickstart for sending notification from gcm demo.
3.Is there any correction required in gcm demo?
As GCM Reference 401 is authentication issue and possible problems are explained below;
The sender account used to send a message couldn't be authenticated.
Possible causes are:
Authorization header missing or with invalid syntax in HTTP request.
Invalid project number sent as key.
Key valid but with GCM service disabled.
Request originated from a server not whitelisted in the Server Key IPs.
Check that the token you're sending inside the Authentication header
is the correct API key associated with your project. See Checking the
validity of an API Key for details.
I am working on push notifications with Google Cloud Messaging(GCM). I am able to setup server and client side following this tutorial.
The server runs on Apache Tomcat6.0 (localhost) and Android emulator on Google APIs (API level 17). I have a sender id and API key. When run from the emulator, I get a successful device connection message. Sooner after that, upon sending message from server shows the following error.
com.google.android.gcm.server.InvalidRequestException: HTTP Status Code: 401()
com.google.android.gcm.server.Sender.sendNoRetry(Sender.java:211)
com.google.android.gcm.server.Sender.send(Sender.java:125)
com.google.android.gcm.demo.server.SendAllMessagesServlet.doPost(SendAllMessagesServlet.java:83)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
From other posts, I understand wrong API key is the culprit. But in my case, I made sure I am using the right one from the API console.
By the way, when I run the emulator, I saw a message 'sending regId to server'. What is the registration id? It is not same as sender id; looks like an encoded one.
Any break through?
EDIT
The issue is finally solved! Ant was not properly building the WAR file. So API key hardly gets updated. It was hell of a nightmare to spot the bug. Thanks all for the inputs!
I suggest you to read the GCM guide:
GCM guide for Android
The sender ID is a constant that is going to be used in the comunication between GCM and your server. The regsitratiomID (regID) is managed by the GCM service when your phone registers to his service.
A better definition:
http://developer.android.com/google/gcm/gcm.html
Sender ID:
A project number you acquire from the API console, as described in Getting Started. The sender ID is used in the registration process to identify an Android application that is permitted to send messages to the device.
Registration ID:
An ID issued by the GCM servers to the Android application that allows it to receive messages. Once the Android application has the registration ID, it sends it to the 3rd-party application server, which uses it to identify each device that has registered to receive messages for a given Android application. In other words, a registration ID is tied to a particular Android application running on a particular device.
The sender account that you're trying to use to send a message couldn't be authenticated. Possible causes are:
Authorization header missing or with invalid syntax.
Invalid project number sent as key.
Key valid but with GCM service disabled.
Request originated from a server not whitelisted in the Server Key
IPs.
Check that the token you're sending inside the Authorization header is the correct API key associated with your project. You can check the validity of your API key by running the following command:
api_key=YOUR_API_KEY
curl --header "Authorization: key=$api_key" --header Content-Type:"application/json" https://android.googleapis.com/gcm/send -d "{\"registration_ids\":[\"ABC\"]}"
If you want to confirm the validity of a registration ID, you can do so by replacing "ABC" with the registration ID.
Happens when the HTTP status code is 401.
The Sender ID is the project number what you have created under Google console.
Registration ID
When your application registers to the GCM it gets the registration ID. To deliver the message this registration ID will be used by the GCM to identify your device + your application.
Your android app should send this registration ID to your server so that when server want to send you a message it can tag it with the registration ID, and hence the GCM can deliver it to the right device & right app.
Diagnose whether the registration ID is successfully shared with the server (Get/Post), unless you won't receive any message.