Languages

Menu
Sites
Language
Check when opened via alarm api

I'm using the alarm api https://developer.tizen.org/dev-guide/2.2.0/org.tizen.web.device.apireference/tizen/alarm.html

I want to be able to tell if the app has been opened by a user manually clicking on it or was it invoked as an alarm.

Responses

2 Replies
Marco Buettner

Yes, I have a similar structure...

I check on pageinit if the request comes from my appControl

var init = function () {
    var reqAppControl = tizen.application.getCurrentApplication().getRequestedAppControl();
     
    if(reqAppControl)
    {
        var appControl = reqAppControl.appControl;
        if (appControl.operation == "YourAppControl")
        {
            // DoSomething
        }
    }
};
 
$(document).one('pageinit', init);

You must define the appcontrol for alarm api like this

function setupAlarm() {
    tizen.alarm.removeAll(); // remove all app related previous alarm controls
  
    var appControl = new tizen.ApplicationControl("YourAppControl", null, null, null, null); // define an appcontrol
    var alarm = new tizen.AlarmRelative(time * tizen.alarm.PERIOD_MINUTE); // execution
    
    tizen.alarm.add(alarm, cupCaker.appId, appControl); // add to alarm schedule
}

Thats all

Philip Kirkbride

Thanks Marco.

Here is a really simple if statement I made based on your comment. It's hacky but for my app it only seems to trigger when the app has been invoked via alarm.

 if(tizen.application.getCurrentApplication().getRequestedAppControl().appControl.data[1]) {
    alert("alarm invoked");
}