Skip to content

Instantly share code, notes, and snippets.

@royyeah
Created Dec 30, 2016
Embed
What would you like to do?
Change in pushNotifications.mpk to refresh page after opening a push notification from the background
[...]
onPushNotification: function (data) {
logger.debug(".onPushNotification");
if (data.additionalData.foreground) {
//If the app is running when the push received
var cards = document.getElementById("cards");
var card = '' +
'<div class="alert alert-info alert-dismissible animated fadeInDown" role="alert">' +
'<button type="button" class="close" data-dismiss="alert" aria-label="Close" onClick="window.pushWidget.removeAlert(this);">' +
'<span aria-hidden="true">&times;</span>' +
'</button>' +
data.message +
'</div>';
var cardList = cards.childNodes;
for(var i = 0; i < cardList.length; i++){
cardList[i].className = "alert alert-info alert-dismissible";
}
cards.innerHTML += card;
} else if(data.additionalData.coldstart) {
//If the app is closed and started by clicking on the push notification
} else {
//If the app is open but not active. i.e. running in background
//TODO: Call microflow with parameters instead
setTimeout(
function() {
window.location.reload(true);
}
,0);
}
this._push.finish(function () {
logger.debug('Successfully processed push notification.');
});
},
[...]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment