I am building an ionic cordova app, The app is making use of Ionic Push notifications, The problem i am facing is that i want to run the code inside "onNotification" which is present in the app.js file before the execution of the controller.js .
Currently whenever i receive a notification on ColdStart,after i click on the notification, the app opens , the controller runs and then the onNotification method is called. I need a way such that the controller code is run only the onNotification code is run.
I register and listen for notifications in the app.js
.run(function($ionicPlatform,$rootScope, localStorageService, $state, $ionicLoading, $document) {
Ionic.io();
var push = new Ionic.Push({
"debug": false,
"onNotification": function(notification) {
console.log(notification.app.closed);
if(notification.app.closed){
console.log('Notification event');
}
},
"onRegister": function(data) {
console.log(data.token);
}
});