I've set up Pushbots to work with my PhoneGap app, but since the setup and initiation of Pushbots is happening in the index.js file, i am not able to call any methods inside my main angularjs controller.
Whenever the user clicks on a notification i would want to run a function from my main controller and navigate to a page.
How can I achieve this?
Here's my index.js file with the onDeviceReady event set up:
function onDeviceReady() {
// Handle the Cordova pause and resume events
document.addEventListener( 'pause', onPause.bind( this ), false );
document.addEventListener( 'resume', onResume.bind( this ), false );
// TODO: Cordova has been loaded. Perform any initialization that requires Cordova here.
document.addEventListener("backbutton", onBackKeyDown, false);
window.plugins.PushbotsPlugin.initialize(.....);
window.plugins.PushbotsPlugin.on("registered", function(token){
console.log("Registration Id:" + token);
});
window.plugins.PushbotsPlugin.getRegistrationId(function(token){
console.log("Registration Id:" + token);
});
window.plugins.PushbotsPlugin.on("notification:received", function(data){
console.log("received:" + JSON.stringify(data));
});
// Should be called once the notification is clicked
window.plugins.PushbotsPlugin.on("notification:clicked", function(data){
$scope.LoadMyPage(); //this is not getting fired...
alert("clicked:" + JSON.stringify(data));
console.log("clicked:" + JSON.stringify(data));
});
};