I created an Ionic Framework project that receives notifications of the GCM push method. I want to save incoming notifications in the window.localStorage application.
This is what I have tried so far:
function onNotificationGCM(e) {
switch( e.event )
{
case 'registered':
if ( e.regid.length > 0 )
{
var elem = angular.element(document.querySelector('[ng-app]'));
var injector = elem.injector();
var myService = injector.get('PushProcessingService');
myService.registerID(e.regid);
}
break;
case 'message':
if (e.foreground)
{
window.localStorage['notifications'] = e.payload.message;
}
else
{
if (e.coldstart)
window.localStorage['notifications'] = e.payload.message;
else
window.localStorage['notifications'] = e.payload.message;
}
break;
case 'error':
break;
default:
break;
}
}
Saving to window.localStorage works if the application is already open when a notification arrives, but when the application is closed, these methods will not be called. This will only happen if the user hits a notification, which then opens the application.
Is there a way to save notification data in the local application store even if the user rejects the incoming push notification?
, , , , .