Methods
Usage
Add the initialization code to your index.js
file
document.addEventListener('deviceready', function () {
var notificationReceivedCallback = function(data) {
console.log('notificationReceivedCallback:', JSON.stringify(data));
};
var notificationOpenedCallback = function(data) {
console.log('notificationOpenedCallback:', JSON.stringify(data));
};
var subscribedCallback = function(subscriptionId) {
console.log('subscriptionId:', subscriptionId);
};
window['plugins'].CleverPush.init("INSERT_YOUR_CHANNEL_ID", notificationReceivedCallback, notificationOpenedCallback, subscribedCallback);
}, false);
Be sure to replace INSERT_YOUR_CHANNEL_ID
with your CleverPush channel ID (can be found in the channel settings).
If you are using Ionic, you can use platform.ready() instead of deviceready like this:
import { Component } from '@angular/core';
import { Platform } from '@ionic/angular';
@Component({
selector: 'app-root',
templateUrl: 'app.component.html'
})
export class AppComponent {
constructor(
private platform: Platform
) {
this.initializeApp();
}
initializeApp() {
this.platform.ready().then(() => {
...
window['plugins'].CleverPush.init("INSERT_YOUR_CHANNEL_ID", ...);
});
}
}