0

Cordova 3.5.0 vibration plugin works well in firefoxos 1.3, except it does not get executed if screen is locked. Any way to overcome this issue?

Note: the app is certainly running as it plays (at same time of the expected vibration) music

lui
  • 440
  • 3
  • 16

1 Answers1

0

When the screen is off everything goes to sleep, for example: you want get any deviceorientation events either. The vibrate function knows this as well, and will return false.

I would expect that requesting a wakelock for CPU would fix that, but that's not the case. So the only way to get around this currently is to get a wakelock for screen, and not let the screen go off while using your application. It's a pretty bad fix though because it'll drain the battery like crazy.

var l = navigator.requestWakeLock('screen');
// after a while
l.unlock();
Jan Jongboom
  • 26,598
  • 9
  • 83
  • 120
  • Thanks Jan. Keeping the screen on is in effect what I've done but as you mentioned it's battery consuming. On Android you can have vibration while screen is off and locked. I think that should be the right behaviour: vibration is often an alarm and often an alarm can be triggered while device is locked... – lui Jul 10 '14 at 20:30
  • And, as you mentioned, also `deviceorientation` not working is annoying as often turning the device upside down is used as a "pause" o "no sound" quick system while device is locked... – lui Jul 10 '14 at 21:19
  • I created a post on the mailing list: https://groups.google.com/forum/#!topic/mozilla.dev.b2g/HJlnz9qZVFc – Jan Jongboom Jul 11 '14 at 09:11
  • I'm following this discussion https://bugzilla.mozilla.org/show_bug.cgi?id=912645 and I updated to the nightly build of 11th of Sept 2014... shall I find already options to try to have vibration and deviceorientation triggered while screen is locked? How in case? Thanks – lui Sep 11 '14 at 19:59
  • That bug is somehow related, but only applies to notifications. So not from your app yet unfortunately. – Jan Jongboom Sep 12 '14 at 10:32