Following is my code snippet
protected String doInBackground(Void... params) {
if(GooglePlayServicesUtil.isGooglePlayServicesAvailable(context) == ConnectionResult.SUCCESS){
GoogleCloudMessaging gcm_instance = GoogleCloudMessaging.getInstance(context);
String reg_id = null;
int attempts = 0;
while(attempts < 3 && reg_id == null){
try{
reg_id = gcm_instance.register(SENDER_ID);
return reg_id;
} catch (IOException e) {
e.printStackTrace();
}
attempts++;
}
}
return null;
}
the register method is returning NULL and exception I am getting is SERVICE_NOT_AVAILABLE. I have cross checked the sender id and internet connection is working perfectly on my device.
Please help.