whale.instanceID

Description: Use whale.instanceID to access the Instance ID service.
Availability: Since Chrome 46.
Permissions: "gcm"
## Summary | Methods | |---| | [getID](#method-getID) − `whale.instanceID.getID(function callback)` | | [getCreationTime](#method-getCreationTime) − `whale.instanceID.getCreationTime(function callback)` | | [getToken](#method-getToken) − `whale.instanceID.getToken(object getTokenParams, function callback)` | | [deleteToken](#method-deleteToken) − `whale.instanceID.deleteToken(object deleteTokenParams, function callback)` | | [deleteID](#method-deleteID) − `whale.instanceID.deleteID(function callback)` | | Events | | [onTokenRefresh](#event-onTokenRefresh) |
## Methods
### getID
`whale.instanceID.getID(function callback)`
Retrieves an identifier for the app instance. The instance ID will be returned by the `callback`. The same ID will be returned as long as the application identity has not been revoked or expired. | Parameters | |---| | function | callback | Function called when the retrieval completes. It should check [runtime.lastError](/extensions/runtime#property-lastError) for error when instanceID is empty. The _callback_ parameter should be a function that looks like this: `function(string instanceID) {...};` | string | instanceID | |---|---| An Instance ID assigned to the app instance. | |
### getCreationTime
`whale.instanceID.getCreationTime(function callback)`
Retrieves the time when the InstanceID has been generated. The creation time will be returned by the `callback`. | Parameters | |---| | function | callback | Function called when the retrieval completes. It should check [runtime.lastError](/extensions/runtime#property-lastError) for error when creationTime is zero. The _callback_ parameter should be a function that looks like this: `function(double creationTime) {...};` | double | creationTime | |---|---| The time when the Instance ID has been generated, represented in milliseconds since the epoch. | |
### getToken
`whale.instanceID.getToken(object getTokenParams, function callback)`
Return a token that allows the authorized entity to access the service defined by scope. | Parameters | |---| | object | getTokenParams | Parameters for getToken. | string | authorizedEntity | |---|---| Identifies the entity that is authorized to access resources associated with this Instance ID. It can be a project ID from [Google developer console](https://code.google.com/apis/console). | | string | scope | Identifies authorized actions that the authorized entity can take. E.g. for sending GCM messages, `GCM` scope should be used. | | object | (optional) options | Allows including a small number of string key/value pairs that will be associated with the token and may be used in processing the request. | | | function | callback | Function called when the retrieval completes. It should check [runtime.lastError](/extensions/runtime#property-lastError) for error when token is empty. The _callback_ parameter should be a function that looks like this: `function(string token) {...};` | string | token | |---|---| A token assigned by the requested service. | |
### deleteToken
`whale.instanceID.deleteToken(object deleteTokenParams, function callback)`
Revokes a granted token. | Parameters | |---| | object | deleteTokenParams | Parameters for deleteToken. | string | authorizedEntity | |---|---| The authorized entity that is used to obtain the token. | | string | scope | The scope that is used to obtain the token. | | | function | callback | Function called when the token deletion completes. The token was revoked successfully if [runtime.lastError](/extensions/runtime#property-lastError) is not set. The _callback_ parameter should be a function that looks like this: `function() {...};` |
### deleteID
`whale.instanceID.deleteID(function callback)`
Resets the app instance identifier and revokes all tokens associated with it. | Parameters | |---| | function | callback | Function called when the deletion completes. The instance identifier was revoked successfully if [runtime.lastError](/extensions/runtime#property-lastError) is not set. The _callback_ parameter should be a function that looks like this: `function() {...};` |
## Events
### onTokenRefresh
Fired when all the granted tokens need to be refreshed.
#### addListener
`whale.instanceID.onTokenRefresh.addListener(function callback)`
| Parameters | |---| | function | callback | The _callback_ parameter should be a function that looks like this: `function() {...};` |

results matching ""

    No results matching ""