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;
}
};
}
}