Android GCM有些设备没有注册

我有一个Google Play应用,下载量为5000。


我担心失败率为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 { @Override protected Void doInBackground(Integer... params) { ServerUtils.sUpdatePushToken(mContext, AppProperties.GCM_REGISTRATION_ID); return null; } } 

我刚刚处理的问题可能与你的问题相同。 Android小于4.1的设备无法注册GCM。 这是我在android-gcm谷歌群组中的post:

 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  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  and  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. }