Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to get token on API level 17

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?

like image 376
bashan Avatar asked Dec 02 '22 16:12

bashan


1 Answers

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?

like image 196
pelotasplus Avatar answered Dec 05 '22 04:12

pelotasplus