joseph
joseph

Reputation: 301

google cloud messaging push with parse and android client does not work

used those lines in android:

InstanceID instanceID = InstanceID.getInstance(this);
        String token = null;


 token = instanceID.getToken(getString(R.string.gcm_defaultSenderId),
                        GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);

got exception , token=null.

google.android.gms.iid.InstanceID.getToken(Unknown Source)

any suggestions?

checked that sender id is ok and api key. no clue.

thanks

Upvotes: 3

Views: 1723

Answers (3)

Flavio Reyes
Flavio Reyes

Reputation: 111

I had this error as well. That was because I called instanceID.getToken in the main thread. The GCD guide says that: Do not call this method in the main thread; instead, use a service that extends IntentService.

Here there is a tutorial where is shown how create an IntentService where you can call instanceID.getToken. I hope this help.

Upvotes: 3

Koh
Koh

Reputation: 1570

The issue is most definitely concerning your google-services.json file. Make sure that you have configured it correctly.

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

Upvotes: 0

katysei
katysei

Reputation: 31

thankx for the answer. I did all the steps except the steps

sendRegistrationToServer(token); ....

since my token was null I was not able to procseed. I had no problems with parse push service. when I tried to replace it with gcm it did not work.

Upvotes: 0

Related Questions