我正在尝试推送通知应用程序并在最初阶段注册。以下代码总是在register()中返回一个空id ...可能我对GCM并不太了解......发生了什么?
private class BackgroundRegister extends AsyncTask<Void,Void,String>{
@Override
protected String doInBackground(Void... params) {
// TODO Auto-generated method stub
String regId = "";
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(activity);
try {
regId = gcm.register(PROJECT_ID);
Log.d("reg id", regId+"");
if (regId == null || regId.isEmpty()){
return "";
} else {
storeRegistrationId(regId);
Log.d("Register", getRegId()+" registered");
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return regId;
}
}