InstanceID

class InstanceID : NSObject

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

Once an InstanceID is generated, the library periodically sends information about the application and the device where it’s running to the Firebase backend. To stop this. see [FIRInstanceID deleteIDWithHandler:].

Instance ID is long lived but, may be reset if the device is not used for a long time or the Instance ID service detects a problem. If Instance ID is reset, the app will be notified via kFIRInstanceIDTokenRefreshNotification.

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 [FIRInstanceID tokenWithAuthorizedEntity:scope:options:handler].

  • FIRInstanceID.

    Declaration

    Swift

    class func instanceID() -> Self

    Return Value

    A shared instance of FIRInstanceID.

  • Unavailable. Use +instanceID instead.

  • Returns a result of app instance identifier InstanceID and a Firebase Messaging scoped token. param handler The callback handler invoked when an app instanceID and a default token are generated and returned. If instanceID and token fetching fail for some reason the callback is invoked with nil result and the appropriate error.

    Declaration

    Swift

    func instanceID(handler: @escaping InstanceIDResultHandler)
  • 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.

    This is an asynchronous call. If the token fetching fails for some reason we invoke the completion callback with nil token and the appropriate error.

    This generates an Instance ID if it does not exist yet, which starts periodically sending information to the Firebase backend (see [FIRInstanceID getIDWithHandler:]).

    Note, you can only have one token or deleteToken call for a given authorizedEntity and scope at any point of time. Making another such call with the same authorizedEntity and scope before the last one finishes will result in an error with code OperationInProgress.

    See

    FIRInstanceID deleteTokenWithAuthorizedEntity:scope:handler:

    Declaration

    Swift

    func token(withAuthorizedEntity authorizedEntity: String, scope: String, options: [AnyHashable : Any]? = nil, handler: @escaping InstanceIDTokenHandler)