How to load the correct state after a push notification when app is in background?

I’m trying to save some data to local storage when a push notification arrives (users sometime have to login when they click on the push notification before I can take them to the correct view), but it seems like the data I save to localstorage at the time the push notification arrives is always null. Is there not access to window.localStorage in the onNotification event handler for ionic push?

Here is my code:

$ionicPush.register({
canShowAlert: true, 
onNotification: function(notification) {
window.localStorage.setItem('someData', notification.payload.somedata);
}
})

When I try window.localStorage.getItem(‘someData’) it’s always null.

onNotification is triggered when you actually go to the notification panel and select the notification. Are you doing this? If the application is in the foreground, it should be called automatically. Maybe you are checking the data before it is finished being set in local storage?

Yes I’m clicking on the notification, and after that is when I’m checking…

Did you inject $window? Don’t forget the ‘$’ in front of window.

Thanks for pointing me in the right direction…