I have registered my Telerik Appbuilder (cordova) app for Push Notifications. Everything works fine, except for the fact that when the user is inside the application, he does not receive the push notification.
It works fine as long as he is on the 1 page that registers his push ie:
var registerPush = function (user, callback) {
$(".modal-loader").show();
document.addEventListener("deviceready", function () {
var el = new Everlive('m4yh8cw6ei7xxwio');
var pushSettings = {
iOS: {
badge: true,
sound: true,
alert: true,
clearBadge: true
},
notificationCallbackIOS: function (e) {
navigator.notification.alert(e.alert, function () { }, "Alert", "Ok");
},
customParameters: {
login: user
}
};
el.push.register(
pushSettings,
function () {
$(".modal-loader").hide();
callback();
}
,
function errorCallback(error) {
// This callback will be called any errors occurred during the device
// registration process
console.log("error registering push");
console.log(data);
}
);
}, false);
}
If the user is on the page that actually registers this function, then he will be alerted via the navigationCallbackIOS. but as soon as we browse to a different page via:
location.href= nextpage.html
then the navigationCallbackIOS no longer works. What is the logic I need to implement here to have a global callback that works on every page?
If you change the page like this location.href= nextpage.html
, then it's a different page, the webview is reloaded and all the code you executed on the index.html won't exist anymore.
You have two options.
location.href