Google cloud messaging push with parse and android client not working
used these lines in android:
InstanceID instanceID = InstanceID.getInstance(this);
String token = null;
token = instanceID.getToken(getString(R.string.gcm_defaultSenderId),
GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
exception received, token = null.
google.android.gms.iid.InstanceID.getToken (Unknown source)
any suggestions?
checked that the sender id is ok and the api key. no clue.
thank
+3
source to share
3 answers
I had this error too. This is because I called instanceID.getToken on the main thread. The GCD manual says: Do not call this method on the main thread; instead use a service that extends the IntentService .
There is a tutorial here showing how to create an IntentService where you can call instanceID.getToken. I hope this help.
+4
source to share