W dniu 10.09.2013 15:46, Alive pisze:

Jan Jongboom <[email protected]> 於 2013/9/10 下午3:38 寫道:

On Monday, September 9, 2013 11:34:22 PM UTC+2, Krzysztof Adamski wrote:

The proof-of-concept application can be found on my github:

http://github.com/kadamski/fxos_apps/tree/master/alarm1

Don't use window.open but 
https://developer.mozilla.org/en-US/docs/Web/API/Apps.getSelf and then launch 
yourself and ring. (launch() function on the response).

Please don't do this. (Relaunch self) This is a bad pattern.

So what should I do instead?

See https://groups.google.com/forum/#!topic/mozilla.dev.webapi/GTIp4RZW2Vs
If you still want this make sure you're in the callback function of system 
message handler.

I have no device to test this right now. Should following work even if phone was suspended (and so screen is locked):

 navigator.mozSetMessageHandler("alarm", function (mozAlarm) {
   var request = window.navigator.mozApps.getSelf();
   request.onsuccess = function () {
     cpuWakeLock.unlock();
     request.result.launch();
   };
 });

?

I believe it should be possible for user in such application to be able to stop ring without unlocking the screen.

Then when application is launching, it could check list of all Alarms, find the one that belongs to my app and if it's end time is < than now(), it could start ringing.

This way I call launch() only from from system message handler, right?
_______________________________________________
dev-b2g mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-b2g

Reply via email to