tizentizen-wearable-sdktizen-web-appsamsung-gear

Tizen app vibration background


I have a Samsung Gear S and I'm bussy writing a web app. I would like to vibrate my app when I get a message from my server. I simply use navigator.vibrate(1000) and this works just fine. But when my app goes to the background the vibration doesn't work anymore. I've found this thread (https://developer.tizen.org/ko/forums/web-application-development/vibration-background?langswitch=ko) in which they face the same problem but there is no solution. Someone also suggested to use alarms to make your app active but I don't know how to do that. I suppose it is something like this:

var alarm = new tizen.AlarmRelative(1);
var service = navigator.vibrate(1000);
tizen.alarm.add(alarm, "org.tizen.browser", service);

This fails because the service isn't correct. How can I get this to work?


Solution

  • The following method:

    You can turn on the screen light first then vibrate.

    tizen.power.turnScreenOn();
    navigator.vibrate(1000);
    

    doesn't work quite yet. I had to add a delay for the vibration:

    tizen.power.turnScreenOn();
    setTimeout(function (){
        navigator.vibrate(1000);
    }, 500);
    

    EDIT: Also add from the other answers to the config.xml file,

    <tizen:setting background-support="enable" background-vibration="enable" />
    <tizen:privilege name="http://tizen.org/privilege/power"/>