core.engagespot
Home > @engagespot/core > Engagespot
Engagespot class
Signature:export default class Engagespot
Constructors
| Constructor | Modifiers | Description |
|---|---|---|
| (constructor)(apiKey, options) | Constructor Initializes Engagespot and sets all required class variables. |
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| _ready | Promise<unknown> | ||
| apiKey | string | API Key for this app. (Please don't confuse with API_SECRET, which is never used in front-end apps) | |
| baseURL | string | ||
| debug | boolean | Toggle Debug Mode | |
| deviceId | string | Unique identifier for this device. | |
| enableNonHttpsWebPush | boolean | ||
| enableWebPush | boolean | Whether web push needs to be enabled. | |
| endPoint | string | null | ||
| eventListenerStore | EventListenerStore | EventListenerStore Object This is where the developer's custom eventListeners are stored for different allowed events. | |
| hideBranding | boolean | ||
| instanceState | 'none' | 'connecting' | 'connected' | 'errored' | ||
| isReady | static | boolean | |
| isWebPushSupported | () => boolean | Check if the current browser supports WebPush | |
| publicKey | string | ||
| realtimeClient | Realtime | Ably Realtime Client | |
| SERVICE_WORKER_URL | string | ||
| serviceWorkerRegistration | ServiceWorkerRegistration | null | ||
| socket | WebSocket | null | ||
| subscribableEvents | string[] | ||
| unreadCount | number | Unread notifications count. | |
| userId | string | This is the unique identifier for the user, as set by the developer | |
| userSignature | string | null | HMAC Signature for this user, for added security |
Methods
| Method | Modifiers | Description |
|---|---|---|
| _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 |