Skip to main content
Version: 1.4.x

core.engagespot

Home > @engagespot/core > Engagespot

Engagespot class

Signature:
export default class Engagespot

Constructors

ConstructorModifiersDescription
(constructor)(apiKey, options)Constructor Initializes Engagespot and sets all required class variables.

Properties

PropertyModifiersTypeDescription
_readyPromise<unknown>
apiKeystringAPI Key for this app. (Please don't confuse with API_SECRET, which is never used in front-end apps)
baseURLstring
debugbooleanToggle Debug Mode
deviceIdstringUnique identifier for this device.
enableNonHttpsWebPushboolean
enableWebPushbooleanWhether web push needs to be enabled.
endPointstring | null
eventListenerStoreEventListenerStoreEventListenerStore Object This is where the developer's custom eventListeners are stored for different allowed events.
hideBrandingboolean
instanceState'none' | 'connecting' | 'connected' | 'errored'
isReadystaticboolean
isWebPushSupported() => booleanCheck if the current browser supports WebPush
publicKeystring
realtimeClientRealtimeAbly Realtime Client
SERVICE_WORKER_URLstring
serviceWorkerRegistrationServiceWorkerRegistration | null
socketWebSocket | null
subscribableEventsstring[]
unreadCountnumberUnread notifications count.
userIdstringThis is the unique identifier for the user, as set by the developer
userSignaturestring | nullHMAC Signature for this user, for added security

Methods

MethodModifiersDescription
_createTokenRequest()_createTokenRequest Generates AblyTokenRequest by calling Engagespot API
_log(message)Wrapper for this._log which considers this.debug value
_resolveInstanceState()
askWebPushPermission()Trigger browser permission prompt for Notification Subscription
attachPushSubscription(subscription)Attach the push subscription for this device
clearWebPushSubscription()Clear WebPush Subscription
createNewDevice()Creares a new random device id, sets it to local storage and returns it.
getDeviceId()
getNotificationList()Returns a new empty NotificationList object
getServiceWorkerRegistration()Registers the service worker to the browser
getWebPushRegistrationState()Get Web Push Registration State
getWebPushSubscription(publicKey)Get WebPush Subscription
handleIncomingRealtimeMessage(message)Incoming Realtime Message Handler. This function is used by realtimeConnect() function
httpsWebPushSubscribe()HTTPS Web Push Subscription
init()Initializes Engagespot Instance
isReady()Function that returns boolean based on SDK Initilization State
onNotificationClick(handler)Subscriber function for NOTIFICATION_CLICKED
onNotificationDelete(handler)Subscriber function for NOTIFICATION_DELETED
onNotificationReceive(handler)Subscriber function for REALTIME_NOTIFICATION_RECEIVED
onNotificationSee(handler)Subscriber function for NOTIFICATION_SEEN
realtimeConnect()Connect to Ably Realtime. It also subscribes to channel with name in the format - APIKEY_UserID