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


thankx for an answer. I followed all steps except steps

sendRegistrationToServer (marker); ....



since my token was null, I was unable to process. I had no problem with the parser service. when i tried to replace it with gcm it didn't work.

0


source


The problem is most definitely related to your google-services.json file. Make sure you set it up correctly.

One of the reasons for this "unknown source" problem is a tampered file.

0


source







All Articles