I'm trying a push notification application and in a very beginning stage-registration. The following code always give back an empty id in register()...probably I have not much idea on GCM...what's going on?
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;
}
}