When I try to get InstanceID from the GCM per the doc, Android Studio complains about missing context parameter. The documentation doesn't mention that. How do I resolve this? Do I simply pass context as such:
String iid = InstanceID.getInstance(this).getID();
Yes, as per the InstanceID Javadoc, you must pass a Context to InstanceID.getInstance() - be that your Activity or another context.
Try this
try {
InstanceID instanceID = InstanceID
.getInstance(getApplicationContext());
token = instanceID.getToken(ApplicationConstants.SENDER_ID,
GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
} catch (IOException e) {
e.printStackTrace();
}
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