The public API of the SDK.
Classes
Namespaces
Members
-
<readonly> SessionState :integer
-
List of Session States
Type:
- integer
Properties:
Name Type Default Description INIT_FAILED
integer -1 Session initialization failed
INIT_UNSTARTED
integer 0 Session initialization is not started
INIT_INPROGRESS
integer 1 Session initialization is in progress
INIT_SUCCESS
integer 2 Session initilialization is successful
-
<readonly> SubscriptionState :integer
-
List of Subscription States
Type:
- integer
Properties:
Name Type Default Description UNSUPPORTED
integer -2 The client does not support native push notifications.
UNSUBSCRIBED
integer -1 The client has manually unsubscribed from native push notifications.
UNDETERMINED
integer 0 The real subscription state is not yet available.
NOT_SUBSCRIBED
integer 1 The client is not yet subscribed to native push notifications.
SUBSCRIBED
integer 2 The client is subscribed to native push notifications.
Methods
-
askNativePushNotificationPermission()
-
Ask the user for permission to receive push notifications. The user must grant the Notification permission in order to opt-in to push notifications.
-
getInitializationPromise() → {Promise}
-
Get a promise which will be resolved at SDK initialization.
Returns:
- Type
- Promise
-
getInstallation() → {Promise}
-
Fetch the installation object.
Returns:
- Type
- Promise
-
getSessionState() → {WonderPushSDK.SessionState}
-
Get the session initialization state.
Returns:
- Type
- WonderPushSDK.SessionState
-
isNativePushNotificationSupported()
-
Ask the permission to receive notifications. The user must grant the permission in order to opt-in to push notifications.
-
newPageLoaded()
-
Call this function whenever new page content is loaded, for instance using AJAX. This helps the SDK to know whether the user is still active on the page.
The SDK already monitors the
load
,hashchange
andunload
events. -
newUserInteraction()
-
Call this function whenever the user does any meaningful operation on the page, such as navigating to a new tab that does not trigger any AJAX calls or browsing events. This helps the SDK to know whether the user is still active on the page.
The SDK already monitors the
load
,hashchange
andunload
events. -
putInstallationCustomProperties(customData)
-
Updates the installation custom properties.
Parameters:
Name Type Description customData
object -
trackEvent(type, customData)
-
Tracks a custom event
Parameters:
Name Type Argument Description type
string The type of the event to track.
customData
object <optional>
Optional custom properties associated to the event.
-
unsubscribeFromPushNotification()
-
Ask the user for permission to receive push notifications. The user must grant the Notification permission in order to opt-in to push notifications.
Events
-
WonderPushSessionEvent
-
WonderPushEvent to indicate SDK initialization state.
- See:
Properties:
Name Type Description name
string "session"
state
WonderPushSDK.SessionState The session initialization state
WonderPushSDK
WonderPushSDK The SDK instance
-
WonderPushSubscriptionEvent
-
WonderPushEvent to indicate push notification subscription state.
- See:
-
- WonderPushSDK.prototype.Notification.getSubscriptionState
Properties:
Name Type Description name
string "subscription"
state
WonderPushSDK.SubscriptionState The push notification subscription state
WonderPushSDK
WonderPushSDK The SDK instance