Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface IPublicAPI

Hierarchy

  • IPublicAPI

Index

Properties

eventAttributeTypes

eventAttributeTypes: typeof TypedEventAttributeType

Event Attribute Types. See TypedEventAttributeType.

ui

ui: IUiAPI

UI related methods

userAttributeTypes

userAttributeTypes: typeof UserAttributeType

User Attribute Types. See UserAttributeType.

Methods

clearInstallationData

  • clearInstallationData(): Promise<void>
  • Clear the custom data of this installation.

    This mean removing all attributes attached to the user's installation but Profile's data will not be removed.

    Returns Promise<void>

doesExistingSubscriptionKeyMatchCurrent

  • doesExistingSubscriptionKeyMatchCurrent(): Promise<boolean>
  • Checks if the currently installed service worker's push subscription can be used with the VAPID public key (aka applicationServerKey) defined in the current Batch configuration.

    This method can be used to detect a VAPID public key change, which can happen:

    • If you already were using Batch but changed the key
    • If you are using Batch for the first time but another push provider was configured and held a registration

    If there is no worker or no push scubscription, the promise resolves to true as a subscription would most likely succeed.

    Always returns true on Safari, as it doesn't support standard push notifications.

    Returns Promise<boolean>

getConfiguration

getInstallationID

  • getInstallationID(): Promise<string>

getNotificationPermission

  • getNotificationPermission(): Promise<NotificationPermission>
  • Returns the permission state of notifications. Having the permission to display notifications doens't mean that this installation is subscribed to push notifications.

    • granted : we have the permission
    • denied : we don't have the permission
    • default : we don't have, have to ask the user

    Returns Promise<NotificationPermission>

getSubscription

  • getSubscription(): Promise<unknown>
  • Returns the raw subscription associated to this insallation. Having a subscription doesn't necessarily mean the installation is subscribed, the user may have unsubscribed or refused notification. Call #isSubscribed() or #getSubscriptionState() to know the exact state of this subscription.

    Returns Promise<unknown>

getSubscriptionState

  • Returns the subscription state including :

    • permission : determines the notification permission
    • subscribed : determines whether the user is subscribed and the permission is granted

    Returns Promise<ISubscriptionState>

getUserAttributes

  • getUserAttributes(): Promise<{}>
  • Read the saved attributes. Returns a Promise that resolves with the attributes.

    Returns Promise<{}>

getUserLanguage

  • getUserLanguage(): Promise<null | string>
  • Returns the user language associated to this installation

    Returns Promise<null | string>

getUserRegion

  • getUserRegion(): Promise<null | string>
  • Returns the user region associated to this installation

    Returns Promise<null | string>

getUserTagCollections

  • getUserTagCollections(): Promise<{}>
  • Read the saved tag collections. Returns a Promise that resolves with the tag collections.

    Returns Promise<{}>

isSubscribed

  • isSubscribed(): Promise<boolean>
  • Determines whether this installation is subscribed to push notifications and can receive notifications (browser notification permission granted, see #getNotificationPermission)

    Returns Promise<boolean>

on

  • on(eventCode: SDKEvent, callback: unknown): void

profile

  • Get the Profile module

    Returns a Promise that resolves with the profile's APIs

    Returns Promise<IProfile>

refreshServiceWorkerRegistration

  • refreshServiceWorkerRegistration(): Promise<void>
  • Refresh the service worker registration. If you do anything to the service worker registration while Batch is running, please call this method, as the SDK caches it for performance.

    Note: depending on Batch's configuration, it might register the service worker as it would have on next page load.

    Returns Promise<void>

setup

  • Configure the SDK with the given configuration map. Can only be called once.

    Note: while this is available on the API object, the supported way is to call this using the "short" syntax. Example: batchSDK("setup", {...})

    Parameters

    Returns void

subscribe

  • subscribe(): Promise<boolean>
  • Subscribe this installation to notification. Returns true if the installation is subscribed, false otherwise.

    Returns Promise<boolean>

trackEvent

  • Track an event.

    Parameters

    • name: string

      The event name. Must be a string made of letters, underscores and numbers only (a-zA-Z0-9_). It also can't be longer than 30 characters.

    • Optional eventDataParams: EventDataParams

      eventDataParams (optional). Parameter object, accepting label, attributes and tags, all optional.

      attributes: Must be an object. The key should be made of letters, numbers or underscores ([a-z0-9_]) and can't be longer than 30 characters.

      Attribute typing is optional. Supported types:

      • Date, the value must be a Date
      • URL, the value must be a string or URL
      • String, the value must be a string or number
      • Integer, the value must be a string or number
      • Double, the value must be a string or number
      • Boolean, the value must be a boolean or number
      • Array, the value must be an array of strings
      • Object, the value must be an object containing the above types

      Type auto-detection is possible.

      If you were previously using labeland tagsyou can specify in the attributesobject the reserved keys: $tags: Must be n array of string. Can't be longer than 64 characters, and can't be empty or null. $label: Must be a string when supplied. It also can't be longer than 200 characters.

    Returns void

tryToSubscribeFrom

  • Try to subscribe from the given subscription state. Force asking the permission even if the permission is granted

    see

    #getSubscriptionState to get the "state" parameter value

    Parameters

    Returns Promise<boolean>

unsubscribe

  • unsubscribe(): Promise<boolean>
  • Unsubscribe this installation from notification. Returns true if the installation is unsubscribed, false otherwise.

    Returns Promise<boolean>

Generated using TypeDoc