Tôi có một ứng dụng trong Google Play với 5000 lượt tải xuống.Android GCM Một số thiết bị không đăng ký
Trong số 5000, 900 không lưu trữ ID đăng ký GCM trên máy chủ của tôi.
Tôi lo lắng về việc có tỷ lệ lỗi 18% và tôi đang cố gắng tìm hiểu lý do tại sao điều này xảy ra. Nó chắc chắn không phải là một vấn đề đi qua một Id để máy chủ của tôi và lưu trữ, vì vậy tôi giả sử nó phải là một thất bại của việc đăng ký. Có ai đi qua bất cứ điều gì như thế này với các dự án của họ? Mã như sau:
// 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;
}
}
.equals ("") không được khuyến nghị. thử regId.trim(). length()> 0 – drulabs
hoặc '.isEmpty()' – 323go
Đánh giá cao câu trả lời của bạn, tuy nhiên nó được google ghi lại trong bản demo GCM với .equals (""). Plus này sẽ làm việc cho 4100 thiết bị và không cho 900? – TommyGuns21