Since SDK is loaded async way, all it's methods should be called via push([METHOD_NAME, ARGS...]) wrapper. The only exception is when you are 100% sure that it is already loaded and inited. For instance, in events callbacks.
Example:
// Subscribe to notifications
Notimatica.push(['subscribe']);{.toc}
- init({Object} options)
- subscribe()
- unsubscribe()
- isSubscribed() : {Boolean}
- isUnsubscribed() : {Boolean}
- on({String} event, {Function} callback)
- emit({String} event)
- resetHistory
- resetState
- resetSDK
{#init}
Initialize SDK. Should be called on every page of your site.
This method should be called once. Multiple calls won't cause any additional effect but will show a warning in the browser console.
Params
{Object} options- Map of options
Example
Notimatica.push(['init', {
project: 'PROJECT_ID',
subdomain: 'SUBDOMAIN'
}]);{#subscribe}
Start subscription process.
Example
Notimatica.push(['subscribe']);{#unsubscribe}
Unsubscribes user from notifications
Example
Notimatica.push(['unsubscribe']);{#isSubscribed}
If user is subscribed.
Returns
{Boolean}-trueif user is subscribed,falseif not
Example
if (Notimatica.push(['isSubscribed'])) {
alert('You are subscribed')
};{#isUnsubscribed}
If user is or was unsubscribed.
Returns
{Boolean}-trueif user is not subscribed,falseif is
Example
if (Notimatica.push(['isSubscribed'])) {
alert('You are not subscribed')
};{#on}
Subscribe to SDK event.
Params
{String} event- Event name{Function} callback- The callback to fire when event is emitted
Example
Notimatica.push(['on', 'ready', function () {
alert('Notimatica SDK is ready')
}]){#emit}
Trigger the event.
Params
{String} event- Event name
Example
Notimatica.push(['emit', 'error', 'Something bad happened']){#resetHistory}
Reset history of received notifications.
Example
Notimatica.push(['resetHistory']){#resetState}
Reset saved state and settings.
Example
Notimatica.push(['resetState']){#resetSDK}
Reset already inited SDK.
Example
Notimatica.push(['resetSDK'])