subscribe

open override fun subscribe(scope: String, appServerSey: String?): SubscriptionResponse

Subscribes to a new channel and gets the Subscription Info block

Arguments

  • scope - Site scope string

  • server_key - optional VAPID public key to "lock" subscriptions (defaults to "" for no key)

Returns

A Subscription response that includes the following:

  • A URL that can be used to deliver push messages

  • A cryptographic key that can be used to encrypt messages that would then be decrypted using the `PushManager::decrypt` function

Errors

Returns an error in the following cases:

  • PushManager was unable to access its persisted storage

  • An error occurred sending a subscription request to the autopush server

  • An error occurred generating or deserializing the cryptographic keys