I am running these commands in order to get a token:
InstanceID instanceID = InstanceID.getInstance(getApplicationContext());
String token = instanceID.getToken(Config.GOOGLE_PROJECT_ID,
GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
But getting this exception:
java.io.IOException: MISSING_INSTANCEID_SERVICE
at com.google.android.gms.iid.zzc.zza(Unknown Source)
at com.google.android.gms.iid.zzc.zzb(Unknown Source)
at com.google.android.gms.iid.zzc.zza(Unknown Source)
at com.google.android.gms.iid.InstanceID.zzc(Unknown Source)
at com.google.android.gms.iid.InstanceID.getToken(Unknown Source)
at autofocus.com.autofocus.activity.ItemListActivity$4.doInBackground(ItemListActivity.java:408)
at autofocus.com.autofocus.activity.ItemListActivity$4.doInBackground(ItemListActivity.java:398)
Any idea what I am doing wrong?
According to official docs:
https://developers.google.com/android/reference/com/google/android/gms/iid/InstanceID#ERROR_MISSING_INSTANCEID_SERVICE
you get this error because
Tokens can't be generated. Only devices with Google Play are supported.
Testing on emulator without Google Play Services enabled/installed?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With