Accessing local storage when a push notification arrives (when app is not running yet)

I’m trying to save some data to local storage when a push notification arrives 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:

canShowAlert: true, //Can pushes show an alert on your screen?
canSetBadge: true, //Can pushes update app icon badges?
canPlaySound: true, //Can notifications play a sound?
canRunActionsOnWake: true, //Can run actions outside the app,
onNotification: function(notification) {
window.localStorage.setItem(‘someData’, notification.payload.somedata);

Later in the app, when I try window.localStorage.getItem(‘someData’) it’s always null.

What I’m mainly wondering is if I cannot access window.localStorage, what are some other ways to persist the data in this case?