firebase::instance_id::InstanceId

#include <instance_id.h>

Instance ID provides a unique identifier for each app instance and a mechanism to authenticate and authorize actions (for example, sending a FCM message).

Summary

An Instance ID is long lived, but might be reset if the device is not used for a long time or the Instance ID service detects a problem. If the Instance ID has become invalid, the app can request a new one and send it to the app server. To prove ownership of Instance ID and to allow servers to access data or services associated with the app, call GetToken.

Constructors and Destructors

~InstanceId()

Public functions

DeleteId()
Future< void >
Delete the ID associated with the app, revoke all tokens and allocate a new ID.
DeleteIdLastResult() const
Future< void >
Get the results of the most recent call to DeleteId.
DeleteToken()
Future< void >
Revokes access to a scope (action)
DeleteTokenLastResult() const
Future< void >
Get the results of the most recent call to DeleteToken.
GetId() const
Future< std::string >
Returns a stable identifier that uniquely identifies the app instance.
GetIdLastResult() const
Future< std::string >
Get the results of the most recent call to GetId.
GetToken()
Future< std::string >
Returns a token that authorizes an Entity to perform an action on behalf of the application identified by Instance ID.
GetTokenLastResult() const
Future< std::string >
Get the results of the most recent call to GetToken.
app() const
App &
Gets the App this object is connected to.

Public static functions

GetInstanceId(App *app, InitResult *init_result_out)
Returns the InstanceId object for an App creating the InstanceId if required.

Public functions

DeleteId

Future< void > DeleteId()

Delete the ID associated with the app, revoke all tokens and allocate a new ID.

DeleteIdLastResult

Future< void > DeleteIdLastResult() const 

Get the results of the most recent call to DeleteId.

DeleteToken

Future< void > DeleteToken()

Revokes access to a scope (action)

DeleteTokenLastResult

Future< void > DeleteTokenLastResult() const 

Get the results of the most recent call to DeleteToken.

GetId

Future< std::string > GetId() const 

Returns a stable identifier that uniquely identifies the app instance.

Details
Returns
Unique identifier for the app instance.

GetIdLastResult

Future< std::string > GetIdLastResult() const 

Get the results of the most recent call to GetId.

GetToken

Future< std::string > GetToken()

Returns a token that authorizes an Entity 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.

For example, to get a token that can be used to send messages to an application via Firebase Messaging, set entity to the sender ID, and set scope to "FCM".

Details
Returns
A token that can identify and authorize the instance of the application on the device.

GetTokenLastResult

Future< std::string > GetTokenLastResult() const 

Get the results of the most recent call to GetToken.

app

App & app() const 

Gets the App this object is connected to.

Details
Returns
App this object is connected to.

~InstanceId

 ~InstanceId()

Public static functions

GetInstanceId

InstanceId * GetInstanceId(
  App *app,
  InitResult *init_result_out
)

Returns the InstanceId object for an App creating the InstanceId if required.

Details
Parameters
app
The App to create an InstanceId object from. On iOS this must be the default Firebase App.
init_result_out
Optional: If provided, write the init result here. Will be set to kInitResultSuccess if initialization succeeded, or kInitResultFailedMissingDependency on Android if Google Play services is not available on the current device.
Returns
InstanceId object if successful, nullptr otherwise.

Send feedback about...

Need help? Visit our support page.