Unable to schedule alarm for native service in hybrid app

Unable to schedule alarm for native service in hybrid app

BY 27 Jan 2019 Web Application Development

Hello I am having a problem with a hybrid app I am developing for Gear/Galaxy watches (Tizen 3.0, Tizen 4.0). My app consists of web app with UI and a native service. I package them together.

 

In the UI app, when I start the service with this code:

tizen.application.launchAppControl(
            new tizen.ApplicationControl(“http://tizen.org/appcontrol/operation/service”),
            “o647BNWshs.serviceelement”,
            function() {
                console.log(” service started”);
            },
            function(e) {
                console.error(“service failed to start: ” + e);
            }
    );

 

It starts correctly (I can see the logs from the service in dlogutil). However, when I try the schedule a service start via the Alarm API:

 

var appId = “o647BNWshs.serviceelement”;
var appControl = new tizen.ApplicationControl(“http://tizen.org/appcontrol/operation/service”, “check”);
 
var alarm = new tizen.AlarmRelative(60);
tizen.alarm.add(alarm, appId, appControl);

 

I get an exception: UnknownError: Error while add alarm to server.

 

When I put other appId in this code, for example the Id of the web UI app or Id of some other app which is present on the watch, the alarm is scheduled correctly, there is no exception and the app is launched after one minute. Only when I try to schedule the start of the native service from the same hybrid package, I get the exception.

 

Does anybody have an idea what I am doing wrong? I think it should be possible to schedule the service to run in background after some time?

Written by