SDK

Remote Notifications

In this page you'll learn how notifications are handled in your app and what all the options at your disposal to create a great messaging experience for your users.

Receiving Notifications

By default any incoming notification will be handled automatically and pass it through to your application. In most cases you will want to simply use our built-in native UI to display the content of the notification. However if this is not enough for your specific case, you might want to handle notifications yourself.

Whenever the device receives a notification, the Notificare plugin will trigger the following event, which you should use to handle notifications:

onDeviceReady: function() {

    ...more code

    Notificare.on('notification', function(notification) {
        Notificare.openNotification(notification);
    });

    ...more code
});

This would be all it takes for you handle notifications. But there might be situations where you will want to intercept an incoming notification in the method above and handle some UI updates in your app like showing a badge or similar functionality, without interfering with the fact that our library will display the message in the notification drawer, log the events for open notifications or any other default behaviour.

Inbox

With our library it's extremely easy to implement an in-app inbox. Implementing an inbox increases considerably the engagement rate with notifications simply because messages will always be available inside your app. To activate the inbox functionality, please follow the instructions described here.

After activating this functionality you can start implementing your inbox in your app. To get all the items in the inbox you would basically invoke the following:

Notificare.fetchInbox(skip, limit, function(inboxItems){

    //Handle inbox items
}, function(error){

    //Handle error
});

Whenever the badge with the number of unread messages is updated you'll get notified in the following event:

Notificare.on('badge', function(badge) {
    //Handle badge
});

Eventually you will want to open an inbox item, this is done by invoking the following method:

Notificare.openNotification({
    _id: inboxItem.notification
});

You would use the following method to mark an item as read:

Notificare.markInboxItem(inboxItem, function(success){

    //Handle inbox items
}, function(error){

    //Handle error
});

Finally to remove all the items in the inbox you would do the following:

Notificare.clearInbox(function(inboxItems){

    //Handle inbox items
}, function(error){

    //Handle error
});