我正在关注这个GCM 示例,它工作正常,只需告诉我服务器如何向每个注册设备发送消息的机制,它将如何唯一标识每个设备。我SENDER_ID
是regId
什么服务器如何唯一标识我的设备 php 服务器如何在没有 SMS 电子邮件服务的情况下向每个设备发送消息 请告诉我它的机制 请告诉我它将如何在这个应用程序中工作 我几乎没有这个
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;
}
};
}
}