本文介绍了GCM注册时出现INVALID_SENDER错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发应用程序,在那里我要使用GCM实现推送通知,我已经在Google控制台上注册了我的项目,并使用项目ID作为发件人ID进行GCM注册。

  GCMRegistrar.checkDevice(this); //没有错误
GCMRegistrar.checkManifest(this); //没有错误
final String regId = GCMRegistrar.getRegistrationId(this);
if(regId.equals()){
GCMRegistrar.register(this,********); //在此之后..
// GCMIntentService类的onError方法
//被触发,在那里我打印错误
//记录它的名称INVALD_SENDER
}

我在AndroidManifest.xml中给出了所有必需的权限



我已经提到以下链接:

1)
2) 3) 4)

解决方案

SENDER_ID =项目编号,我使用的是项目标识..项目编号在项目ID旁边的控制台上可用。


I am developing application where I want to implement push notification for that I am using GCM, I have registered my project on google console and using project ID as senderID for GCM registraton.

GCMRegistrar.checkDevice(this); //no error
GCMRegistrar.checkManifest(this); //no error
final String regId = GCMRegistrar.getRegistrationId(this);
if (regId.equals("")) {
            GCMRegistrar.register(this, "********"); //after this..
                                       //onError method of GCMIntentService class
                                      //is triggered, there I am printing error
                                     //in log its saying INVALD_SENDER
        }

I have given all required permissions in AndroidManifest.xml

I Have already referred following links

1) Android GCM SENDER_ID, how to get it?2) Getting GCM Error: INVALID_SENDER occasionally in an app that has two GCM BroadcastReceivers 3) GCM Invalid sender error 4) http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/

解决方案

SENDER_ID = Project Number, I was using Project Id.. Project Number is available on console beside project id.

这篇关于GCM注册时出现INVALID_SENDER错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 21:52