7

Google Play に 5000 回ダウンロードされたアプリがあります。

それらの 5000 のうち、900 はサーバーに GCM 登録 ID を保存できませんでした。

失敗率が 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;
    }
}
4

4 に答える 4

4

私はちょうどあなたの問題と同じになるかもしれない問題に対処しました。Android 4.1 未満のデバイスは、GCM に登録できませんでした。android-gcm Google グループからの私の投稿は次のとおりです。

Ok, got it solved. Thanks to J.Carlos Navea and Mark Murphy in this thread:
https://groups.google.com/forum/?fromgroups=#!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
于 2013-03-19T00:41:28.947 に答える
2

次のように、GCM が機能しない原因がいくつかあります。

同期されていない Google アカウント。

Android 3.2 以降では、ユーザーがアプリケーションを「強制停止」すると、gcm も機能しません。

于 2013-03-07T16:34:11.910 に答える
1

GCM 登録が失敗する状況に対処していますか? GCMIntentService を使用している場合は、以下を実装していることを確認してください。

@Override
protected void onError(Context context, String regid) {
   // Handle error condition.
}
于 2013-05-09T15:14:23.613 に答える