I created a set of functions that check if there are any current notifications planned for iOS, and if there are any, I want to cancel them and reschedule them. The logic below will return if there are planned elements, and if they begin to cancel and reschedule. The problem is that they all show successful and console logs to show this, but the allocation function does not revise them. Is there any way to make sure they were deleted before trying to reschedule? My only guess is that I'm trying to reschedule before he has completed the deletion.
if (isIOS){
var getScheduled = function() {
$cordovaLocalNotification.getAllScheduled().then(function (scheduledItems) {
$scope.scheduledContainer = scheduledItems;
$scope.scheduledItems = scheduledItems;
if($scope.scheduledItems.length < 1) {
console.log('no previously scheduled items.')
return;
} else {
cancelAll();
console.log("there are items here.")
}
})
}
getScheduled();
var cancelAll = function() {
console.log('we made it to the cancel function');
$cordovaLocalNotification.cancelAll().then(function (result) {
console.log('They Cancelled');
rescheduleAll();
});
}
var rescheduleAll = function() {
$cordovaLocalNotification.schedule($scope.scheduledItems).then(function() {
console.log('Successfully Scheduled');
});
}
}