UI related methods
User Attribute Types.
See UserAttributeType
.
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.
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 there is no worker or no push subscription, 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.
Get the current configuration
Returns the installation identifier
Returns the permission state of notifications. Having the permission to display notifications doesn't mean that this installation is subscribed to push notifications.
Returns the raw subscription associated to this installation. 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 the subscription state including :
Read the saved attributes. Returns a Promise that resolves with the attributes.
Returns the user language associated to this installation
Returns the user region associated to this installation
Read the saved tag collections. Returns a Promise that resolves with the tag collections.
Determines whether this installation is subscribed to push notifications and can receive notifications (browser notification permission granted, see #getNotificationPermission)
Listen to api events
Get the Profile module
Returns a Promise that resolves with the profile's APIs
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.
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", {...})
Subscribe this installation to notification. Returns true if the installation is subscribed, false otherwise.
Track an event.
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.
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:
Type auto-detection is possible.
If you were previously using label
and tags
you can specify in the attributes
object 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.
Try to subscribe from the given subscription state. Force asking the permission even if the permission is granted
Unsubscribe this installation from notification. Returns true if the installation is unsubscribed, false otherwise.
Generated using TypeDoc
Event Attribute Types. See
TypedEventAttributeType
.