java.lang.Object | |
↳ | com.google.android.gms.iid.InstanceID |
Instance ID provides a unique identifier for each app instance and a mechanism to authenticate and authorize actions (for example, sending a GCM message).
Instance ID is stable but may become invalid, if:getId()
to request a new Instance ID.
To prove ownership of Instance ID and to allow servers to access data or
services associated with the app, call getToken(String, String)
.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | ERROR_BACKOFF | Error returned when failed requests are retried too often. | |||||||||
String | ERROR_MAIN_THREAD | Blocking methods must not be called on the main thread. | |||||||||
String | ERROR_MISSING_INSTANCEID_SERVICE | Tokens can't be generated. | |||||||||
String | ERROR_SERVICE_NOT_AVAILABLE | The device cannot read the response, or there was a server error. | |||||||||
String | ERROR_TIMEOUT | Timeout waiting for a response. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Resets Instance ID and revokes all tokens.
| |||||||||||
Revokes access to a scope (action) for an entity previously
authorized by
getToken(String, String) . | |||||||||||
Returns time when instance ID was created.
| |||||||||||
Returns a stable identifier that uniquely identifies the app instance.
| |||||||||||
Returns an instance of this class.
| |||||||||||
Returns a token that authorizes an Entity (example: cloud service) to perform
an action on behalf of the application identified by Instance ID.
| |||||||||||
Returns a token that authorizes an Entity (example: cloud service) to perform
an action on behalf of the application identified by Instance ID.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Error returned when failed requests are retried too often. Use exponential backoff when retrying requests
Blocking methods must not be called on the main thread.
Tokens can't be generated. Only devices with Google Play are supported.
The device cannot read the response, or there was a server error. Application should retry the request later using exponential backoff and retry (on each subsequent failure increase delay before retrying).
Timeout waiting for a response.
Resets Instance ID and revokes all tokens.
Throws | |
---|---|
IOException |
Revokes access to a scope (action) for an entity previously
authorized by getToken(String, String)
.
Parameters | |
---|---|
authorizedEntity |
String :
Entity that must no longer have access. |
scope |
String :
Action that entity is no longer authorized to perform. |
Throws | |
---|---|
IOException |
if the request fails. |
Returns time when instance ID was created.
Returns | |
---|---|
long |
Time when instance ID was created (milliseconds since Epoch). |
Returns a stable identifier that uniquely identifies the app instance.
Returns | |
---|---|
String |
The identifier for the application instance. |
Returns an instance of this class.
Parameters | |
---|---|
context |
Context
|
Returns | |
---|---|
InstanceID |
InstanceID instance. |
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 OAuth2 token except, it applies to the application instance instead of a user. Do not call this function on the main thread.Parameters | |
---|---|
authorizedEntity |
String :
Entity authorized by the token. |
scope |
String :
Action authorized for authorizedEntity. |
Returns | |
---|---|
String |
a token that can identify and authorize the instance of the application on the device. |
Throws | |
---|---|
IOException |
if the request fails. |
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 OAuth2 token except, it applies to the application instance instead of a user. Do not call this function on the main thread.Parameters | |
---|---|
authorizedEntity |
String :
Entity authorized by the token. |
scope |
String :
Action authorized for authorizedEntity. |
extras |
Bundle :
additional parameters specific to each token scope.
Bundle keys starting with 'GCM.' and 'GOOGLE.' are
reserved. |
Returns | |
---|---|
String |
a token that can identify and authorize the instance of the application on the device. |
Throws | |
---|---|
IOException |
if the request fails. |