chrome.instanceID

Description: Use chrome.instanceID to access the Instance ID service.
Availability: Since Chrome 46.
Permissions: "gcm"

Summary

Methods
getID chrome.instanceID.getID(function callback)
getCreationTime chrome.instanceID.getCreationTime(function callback)
getToken chrome.instanceID.getToken(object getTokenParams, function callback)
deleteToken chrome.instanceID.deleteToken(object deleteTokenParams, function callback)
deleteID chrome.instanceID.deleteID(function callback)
Events
onTokenRefresh

Methods

getID

chrome.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 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

chrome.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 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

chrome.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.

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 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

chrome.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 is not set.

The callback parameter should be a function that looks like this:

function() {...};

deleteID

chrome.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 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

chrome.instanceID.onTokenRefresh.addListener(function callback)
Parameters
function callback

The callback parameter should be a function that looks like this:

function() {...};