I am trying to get my app running with Google Cloud Messaging. I am following the Google Cloud Messaging Quickstart App which can be found here on github.
In their quickstart app at some point we ask the Google Cloud Messaging service for a registration token so that this instance of our app can talk to the cloud.
I find this line of code:
InstanceID instanceID = InstanceID.getInstance(this);
String gcmRegistrationToken = instanceID.getToken(getString(R.string.gcm_defaultSenderId),
The part that is confusing me is this value:
It is defined in their quickstart app, but it is automatically generated.
How am I supposed to get my app to generate that value?
I look up the docs for InstanceID.getToken which is here
returns a token that authorizes an Entity (example: cloud service) to perform an action on behalf of the application identified by Instance ID.
This is similar to an
token except, it applies to the application instance instead of a user.
The function header looks like:
public String getToken (String authorizedEntity, String scope)
I see that the first arg that
so, what is this authorizedEntity String supposed to be?
It clearly identifies the instance of the app making the request, but how am I supposed to generate it? In the quickstart app, I can't find it defined in
, I can only find it defined in R.java and
It looks like:
There is just that one string in that file, and that file is buried way deep in the project structure.
I can't find anywhere in the code where this
is being generated programmatically.
I'm confused because, how was I supposed to know that string was there? I never defined that string, and googling for "cannot resolve
" gives no results. I'm trying to implement Google Cloud Messaging in my own app, so of course my own app is not going to automatically know to generate that string. How am I supposed to make that id number?
This is why I think it's important that I understand what this authorizedEntity string that InstanceID.getToken wants, so that I can properly generate one to give to getToken. Perhaps my idea is completely wrong, perhaps I am not supposed to generate gcm_defaultSenderId, but I know that I am not supposed to alter R.java, and the
file is also under a "generated" folder.
Help please? If I find the answer in my searches, I will happily post the answer. Any help much appreciated, note: my project was exported to Gradle
, so it will still have the Eclipse project/folder structure, that shouldn't cause any problems, but the
file is in a different place.