Can App Receive Phone Status Event

Is it possibe for an app to receive an event when the phones status changes. For example when the status changes to Do not disturb.

We have a service center that would like to track the time available on the phone, i would like to create an app on the phone for the users to see each day how long they were on Do not disturb and how long they were available to take calls.

Yes. A phone subscribes to it’s own status updates. For example if you ran the following on your phone:

var app = require('app');
var util = require('util');

// Allows this application to run in the background. = false;

var presenceChanged = function(param) {
    util.debug("Presence Changed: ");

    'eventName'     : '',
    'callback'      : presenceChanged

util.debug("Presence monitored");

You could get output on the debug console when switching to DND and back to available like:

Presence monitored
Presence Changed: 
Presence Changed: 

You can see that param.eventData.type changed to ‘dnd’ and back to ‘available’. You would need to parse the url in order to know it was the users phone that changed state and not another phone.

thank you for your quick reply, i am going to try it now