I am writing and Android SDK which should receive GCM push messages from the SDK server side. After a few hours of successful push message sending, the GCM server returns an NotRegistered
error:
{
"multicast_id":6205350692941230304,
"success":0,
"failure":1,
"canonical_ids":0,
"results":
[
{
"error":"NotRegistered"
}
]
}
The registrationId
at the client has not changed, and the server side is updated with that token.
How can I fix the registrationId
problem? Is having two listeners - one in the SDK, one in the app - a problem?
My Android SDK registers a GCM regId
upon initialization, and sends that id to the server supporting the SDK.
The embracing app might (and usually do) register a GCM regId
of its own. The other regId
is probably sent to the embracing app's server.
The senderId
of the SDK and app are different.
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> ...
<receiver
android:name="com.xxxx.xxxxx.xxxxx"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</receiver>
protected String doInBackground(Void... params) {
String msg = "";
try {
if (gcm == null) {
gcm = GoogleCloudMessaging.getInstance(mContext);
}
regid = gcm.register(SENDER_ID);
msg = "Device registered, registration ID=" + regid;
storeRegistrationId(mContext, regid);
listener.onGCMRegisterFinish(regid);
}
catch (IOException ex)
{
msg = "Error :" + ex.getMessage();
}
return msg;
}
This code gets the regId
from the GCM Server and send it to our backend server. It is executed at the SDK initialization, and the regId
is sent every time the app returns from background.
unregister()
is not called, neither from server or client side2015-08-02 12:31:22,383 INFO - request_2145354041215926507
update push token for user: XXXXXXXX,
push_token: ...me1GttmSRipnWsCGVUueK7e0nk
The Not Registered happens when GCM thinks the device could not handle the message. This happens if the app is uninstalled or misconfigured to handle the message: Make sure you have <receiver> and <sender> are defined in <application> node in AndroidManifest.xml. Show activity on this post.
Step 1: Opening Android Studio Settings. Navigate to the File > Settings option you will get to see below dialog screen. Inside that screen. Click on Appearance and Behavior option > System Settings options and then click on the Android SDK option to get to see the below screen.
Inside this screen, you will get to see your SDK path. You can update your SDK path by clicking on the Edit option. After that select your SDK path, then click on Apply option, and then click on the OK option. Now sync your project with Gradle files to check that SDK is working fine.
Click on Appearance and Behavior option > System Settings options and then click on the Android SDK option to get to see the below screen. Inside this screen, you will get to see your SDK path.
Add Category with your package name to the intent-filter
<receiver
android:name=".xxxxx"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<!-- Receives the actual messages. -->
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.xxxx" />
</intent-filter>
</receiver>
The registration ID´s generation includes not only the device but also the app and the sender ID. If I understood your architecture correctly you want to implement a GCM-client-library (your SDK) enabling your app to use GCM through your library? If that´s true make sure that you only register once
The senderId of the SDK and app are different
I assume this is the problem, you have to register each app with a sender id (e.g. XYZ) and use the SAME sender id at the server to send the notification. It is not possible to use ABC as sender id to send notifications to a device registered for sender id XYZ
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With