Android GCM有些设备没有注册



我担心有18%的失败率,并且很难找出原因。 这绝对不是一个问题传递一个Id到我的服务器和存储,所以我认为它必须是注册失败。 有没有人遇到过这样的项目? 代码如下:

// Fired every time the app is booted in Main Activity private void setupGCM() { String gcmRegId = GCMRegistrar.getRegistrationId(this); if (gcmRegId.equals("")) { GCMRegistrar.register(this, AppProperties.GCM_SENDER_ID); } else { // This is well tested and is not the issue ServerUtils.sUpdatePushToken(this, gcmRegId); } } // GCMIntentService Class onRegistered @Override protected void onRegistered(Context context, String registrationId) { mContext = context; if (!registrationId.equals("")) { AppProperties.GCM_REGISTRATION_ID = registrationId; new UpdateGCMRegistrationIdAsync().execute(); } else { GCMRegistrar.setRegisteredOnServer(context, false); } } // GCMIntentService Class My Async class for updating Reg Id private class UpdateGCMRegistrationIdAsync extends AsyncTask<Integer, Integer, Void> { @Override protected Void doInBackground(Integer... params) { ServerUtils.sUpdatePushToken(mContext, AppProperties.GCM_REGISTRATION_ID); return null; } } 

Solutions Collecting From Web of "Android GCM有些设备没有注册"

我只是处理了一个可能会和你一样的问题。 Android小于4.1的设备无法注册GCM。 这里是我的post从android-gcm谷歌组:

 Ok, got it solved. Thanks to J.Carlos Navea and Mark Murphy in this thread:!searchin/android-gcm/onRegister/android-gcm/CqMRN4gVRpY/AGphcX1AuhgJ The issue was the <category> tag in the receiver declaration. It is required for anything less than 4.1 Use your package name there. Additionally, check to make sure that the <permission> and <uses-permission> tags use the same string/name. I was getting away with that one as well on 4.1 



在Android 3.2+当用户“强行停止”应用程序时,gcm不起作用。

您是否正在处理GCM注册失败的情况? 如果您使用的是GCMIntentService,请确保您正在执行以下操作:

 @Override protected void onError(Context context, String regid) { // Handle error condition. }