firefox - Show notifications when app is closed -
i'm having problems notifications in app.
i've seen pages reference alarmapi in firefox os , how handle notifications:
https://developer.mozilla.org/en-us/apps/developing/control_the_display/using_alarms_to_notify_users
the code same in both cases , works when app open or in background. if close app doesn't show notifications. i've tested example app second link , works when app closed.
what problem , how can fix it?
thanks.
you must use navigator.mozsetmessagehandler() https://developer.mozilla.org/en-us/docs/web/api/navigator.mozsetmessagehandler
if(navigator.mozsetmessagehandler) { navigator.mozsetmessagehandler("alarm", function (alarm) { // launch notification if alarm of right type app if(alarm.data.task) { // create notification when alarm due new notification("your task " + alarm.data.task + " due!"); updatenotified(alarm.data.task); } }); }
Comments
Post a Comment