GCM 'Error : Not Registered'

2019-01-07 15:59发布

I succeed in testing My GCM code.

But exactly same code, I couldn't get GCM push and got:

GCM Error : Not Registered.

8条回答
虎瘦雄心在
2楼-- · 2019-01-07 16:19

I had this error when I had the gcm receiver outside of the application in the manifest file. Moved the receiver into the application scope and everything worked. A very happy bunny now.

<application>
...
<receiver>
...
</receiver>
...
</application>
查看更多
SAY GOODBYE
3楼-- · 2019-01-07 16:23

If you really think your code is correct and still getting error

{"error": "NotRegistered"} 

try un-installing app manually from phone and run it again (your device will get new registration ID).

At least in my case the problem was solved!

查看更多
闹够了就滚
4楼-- · 2019-01-07 16:27

A Google account is a requirement on devices running Android 4.0.4 or lower. http://developer.android.com/google/gcm/gcm.html

You should also add <uses-permission android:name="android.permission.GET_ACCOUNTS" /> in your manifest file.

查看更多
霸刀☆藐视天下
5楼-- · 2019-01-07 16:28

If you are using a device for testing, you need to delete the InstanceID before obtaining the token and re-testing because once you overwrite your APK it de-registers that InstanceId and you get that NotRegistered error. So in your RegisterIntentService class, in the onHandleIntent function do the following:

InstanceID instanceID = InstanceID.getInstance(this);
try
{
    instanceID.deleteInstanceID();
} catch(IOException e) 
{
    e.printStackTrace();
}
instanceID = InstanceID.getInstance(this);
查看更多
一夜七次
6楼-- · 2019-01-07 16:31

This means simply your are giving a wrong registration Id. So for this, first run your mobile application and your registration ID will come as token. Put this token to your app server code as registration ID. For App ID give server ID, which you could get from Google developer console,your project,And credentials. For sender Id , set your project ID which could aquire from project,settings in developer console.

查看更多
走好不送
7楼-- · 2019-01-07 16:41

GCM response Not Registered means following "If it is NotRegistered, you should remove the registration ID from your server database because the application was uninstalled from the device or it does not have a broadcast receiver configured to receive com.google.android.c2dm.intent.RECEIVE intents." from documentation. Check in what case you get this error, when app is uninstalled from the device or you describe incorrect broadcast receiver in AndroidManifest. You can test your GCM functionality with my test GCM server. Hope, this helps you.

查看更多
登录 后发表回答