I have integrated onesignal notification module in my Titanium iOS App.I want to save all the notification received by the iPhone in to the SQLITE Db. Now the problem is how can I get the data of All the Unread Notifications when user opens the app or user clicks on one of the received notification?
Here is the module I am using.
Below is my code.
var onesignal = require('com.williamrijksen.onesignal');
if (Ti.Platform.osname != 'android') {
onesignal.promptForPushNotificationsWithUserResponse(function(obj{});
}
onesignal.addEventListener('notificationOpened', function(evt) {
alert("Clicked " + JSON.stringify(evt));
if (evt) {
var title = '';
var content = '';
var data = {};
if (evt.title) {
title = evt.title;
}
if (evt.body) {
content = evt.body;
}
if (evt.additionalData) {
data = (evt.additionalData);
alert(JSON.stringify(data));
}
}
});
onesignal.addEventListener('notificationReceived', function(evt) {
alert("Received " + JSON.stringify(evt));
if (evt) {
Ti.API.info('Notification Received: ' + JSON.stringify(evt));
}
});
Is there anything I am missing?
Thanks in advance.