Contents

generateToken(completionHandler:)

Generates a token that identifies the current device.

Declaration

func generateToken(completionHandler completion: @escaping  @Sendable (Data?, (any Error)?) -> Void)
func generateToken() async throws -> Data

Parameters

  • completion:

    A completion block that includes the following parameters:

    • token: An ephemeral token that identifies the current device.

    • error: The error that occurred, if any.

Discussion

Your server uses the generated token in its requests to get or set the persistent bits for the current device. You should treat the token you receive in the completion block as single-use. Although the token remains valid long enough for your server to retry a specific request if necessary, you should not use a token multiple times. Instead, use this method to generate a new token.