I have a form where a user can tick which days and what time to set off an alarm. The form saves it’s settings.
I want to now add a localNotification to fire as per the settings. I have used the ngCordova plugin to do this. The code does not raise an error, but I can’t get a notification to fire.
This is what my controller looks like.
angular.module('starter.controllers', [])
.controller('DailyCtrl', function($scope, $location, Settings, $cordovaLocalNotification) {
$scope.data = {};
$scope.data.settings = Settings.all();
$scope.doSave = function() {
Settings.save($scope.data.settings);
var today = new Date();
//save notification
$scope.addNotification = function () {
$ionicPlatform.ready(function() {
$cordovaLocalNotification.add({ message: 'Great app!' });
$cordovaLocalNotification.add({
id: 'happi_alert',
date: new Date(today.getFullYear(), today.getMonth(), today.getDate(), 16, 33, 0),
message: "Happi App Message", // The message that is displayed
title: "HappiApp Alert", // The title of the message
sound: "beep.caf", // plays `beep.mp3` located in folder
//json: String, // Data to be passed through the notification
repeat: "minutely",
autoCancel: true,
}).then(function () {
console.log('callback for adding background notification');
});
});
$cordovaLocalNotification.getScheduledIds(function (scheduledIds) {
alert('Scheduled IDs: ' + scheduledIds.join(' ,'));
}, scope);
};
$location.path("/");
};
})
How can i start to debug this? Where might I be going wrong?
Any points would be great, thanks