0

GCM が正常に動作するためのこの例に従っています。サーバーがすべての登録デバイスにメッセージを送信したメカニズムを教えてください。各デバイスを一意に識別する方法を教えてください。SENDER_IDサーバーがregIdデバイスを一意に識別する方法 SMS メール サービスなしで PHP サーバーが各デバイスにメッセージを送信する方法 そのメカニズムを教えてください このアプリケーションでどのように機能するか教えてください これはほとんどありませ ん

String SENDER_ID = "748495904142"

https://code.google.com/apis/console/?pli=1#project:748495904142:accessから受け取ったもの

final String regId = GCMRegistrar.getRegistrationId(this);

// Check if regid already presents
if (regId.equals("")) {
    // Registration is not present, register now with GCM           
    GCMRegistrar.register(this, SENDER_ID);
} else {
    // Device is already registered on GCM
    if (GCMRegistrar.isRegisteredOnServer(this)) {
        // Skips registration.              
        Toast.makeText(getApplicationContext(),"Already registered with GCM",
        Toast.LENGTH_LONG).show();
    } else {
        // Try to register again, but not in the UI thread.
        // It's also necessary to cancel the thread onDestroy(),
        // hence the use of AsyncTask instead of a raw thread.
        final Context context = this;
        mRegisterTask = new AsyncTask<Void, Void, Void>() {

            @Override
            protected Void doInBackground(Void... params) {
                // Register on our server
                // On server creates a new user
                ServerUtilities.register(context, name, email, regId);
                return null;
            }

            @Override
            protected void onPostExecute(Void result) {
                mRegisterTask = null;
            }
        };
    }
}
4

2 に答える 2

1

SENDER_ID は、サーバーに関連付けられたさまざまなプロジェクトを区別するためにサーバーが使用するプロジェクト ID です。

REG_ID は、サーバーに登録されたさまざまなモバイル デバイスを区別するためにサーバーが使用する一意の ID です。

たとえば、同じモバイル デバイスが 2 つの異なるプロジェクトに関連付けられており、同じサーバーに関連付けられているため、サーバーは 2 つのプロジェクトを簡単に区別して、それぞれのメッセージをモバイル デバイスに送信できます。

于 2013-09-24T09:18:07.670 に答える