Notification

This family of device APIs provided by dronahq.js can be used to interact with the notification data received by a micro-app.

All notifications are received in the inbox of the container app by default. On clicking a notification the micro-app is invoked and the unique id of the notification is appended as query sting, which can be used to perform actions such as fetching the relevant notification data.

It has the following method(s) -

getnotification()

This method gets notification based on a notification id.

//Get the notification id from query string

function getQParameter(name) {
        name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
        var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
        results = regex.exec(location.search);
        return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}

var notiId = getQParameter('dm_noti_id');

var fnSuccess = function(notiData){
        //notiData contains the JSON object
        //that was sent using platform notification API
        console.log(notiData);

};
var fnError = function(e){
        if(e.code == '1'){
                console.log('Invaid Notification ID');
        }
};

DronaHQ.notification.getNotification(notid, fnSuccess, fnError);

getallnotification()

This method generates a list of all unread notifications. Any notification that is not retrieved by getNotification() is to be considered as unread.

var fnSuccess = function(data){
        var unreadNotiCount = data.notifications.length;
};

var fnError = function(e){};

DronaHQ.notification.getAllNotification(fnSuccess, fnError);