cordova plugin add https://github.com/Telerik-Verified-Plugins/Leanplum --variable APP_ID=<your App ID> --variable DEVELOPMENT_KEY=<your Development Key> --variable PRODUCTION_KEY=<your Production Key>
appbuilder plugin add "Leanplum"
document.addEventListener("deviceready", function () { // Calling 'start' will run your app in production mode. // Call 'enableDebugging' before calling 'start' to run this session in developer mode. Leanplum.enableDebugging(); Leanplum.start( function(msg) {console.log("Started Leanplum. Message was: " + msg)}, // success handler function(msg) {alert("ERROR, Leanplum did not start: " + msg)} // error handler ); });
Leanplum.track( function(msg) {alert(msg)}, // success handler function(msg) {alert("ERROR, not tracked: " + msg)}, // error handler "Button clicked" );
Leanplum.track( function(msg) {alert(msg)}, // success handler function(msg) {alert("ERROR, not tracked: " + msg)}, // error handler "Upgrade purchased", {"price" : 40, "quantity" : 2, "totalprice" : 80} );
Leanplum.registerPush({ "badge": "true", "sound": "true", "alert": "true", "callback": "onPushNotificationReceived" // make sure you define this function somewhere }); // the callback we configured a few lines back function onPushNotificationReceived(e) { alert("Push Notification received: " + JSON.stringify(e)); }
Leanplum.unregisterPush();