Gcm phone_registration_error [英] Gcm phone_registration_error

查看:138
本文介绍了Gcm phone_registration_error的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图设置一个应用程序来使用gcm,但每次我根据Gcm文档得到phone_registration_error错误
时,这个错误的意思就是:

 向Google注册不正确的电话。 
此手机目前不支持GCM。

但我不明白为什么我不支持它,我在真正的Android设备上测试了这个一个模拟器与谷歌api的



我MainActivity:

  @Override 
public void onCreate(Bundle savedInstanceState){
checkNotNull(SENDER_ID,SENDER_ID);

GCMRegistrar.checkDevice(this);
GCMRegistrar.checkManifest(this);

final String regId = GCMRegistrar.getRegistrationId(this);
Log.i(TAG,registered id =====+ regId);
if(regId.equals()){
GCMRegistrar.register(this,SENDER_ID);

} else {
Log.v(TAG,已注册);
}

super.onCreate(savedInstanceState);
setContentView(R.layout.main);


$ / code>

我的清单:

在pastebin上显示

解决方案

GCM仅适用于运行android 2.2或更新版本的设备。此外,GCM仅适用于为设备安装Google帐户的情况。这也是Google推荐在清单中使用< uses-permission android:name =android.permission.GET_ACCOUNTS/> 的原因,因此您确定设备具有一个谷歌账户。


I'm trying to set up an application to work with gcm but every time I get the phone_registration_error error according to the Gcm documentation this error means:

Incorrect phone registration with Google. 
This phone doesn't currently support GCM.

But I don't understand why my it's not supported, I tested this on a real android device and a emulator with the google api's

My MainActivity:

    @Override
public void onCreate(Bundle savedInstanceState) {
    checkNotNull(SENDER_ID, "SENDER_ID");

    GCMRegistrar.checkDevice(this);
    GCMRegistrar.checkManifest(this);

    final String regId = GCMRegistrar.getRegistrationId(this);
    Log.i(TAG,  "registration id =====  "+regId);
    if(regId.equals("")){
        GCMRegistrar.register(this, SENDER_ID);

    } else {
        Log.v(TAG, "Already Registred");
    }

    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

}

And my manifest:

Manifest on pastebin

解决方案

GCM only works on devices that run android 2.2 or newer. Also GCM only works if a google account is installed for the device. This is also the reason google recommend using <uses-permission android:name="android.permission.GET_ACCOUNTS" /> in the manifest so you are sure the device has a google account.

这篇关于Gcm phone_registration_error的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆