Ali Abdulaal
Ali Abdulaal

Reputation: 175

Ionic 3 / local notification not works in case "every"

I installed the plugin without any problems and I tested it in case I have date and time.

but if I use "every", then nothing happens

this.localNotifications.schedule({
    id: 1,
    title: "New Scheduled Task" ,
    text: "Hi world"
    at: notificationTime, //have the time of notification
    every: "week"
});

I tested this way also, the notification shows directly but there is no repeats:

cordova.plugins.notification.local.schedule({
    id: 1,
    title: "New Scheduled Task" ,
    text: "Hi world",
    at: notificationTime,
    trigger: { every: 30, unit: 'second' }
});  

So, Is there any wrongs and how can I solve this problem !

Upvotes: 1

Views: 1167

Answers (2)

Abraham Post
Abraham Post

Reputation: 11

I have been having the same problem- I think it that the newest versions of LocalNotifications aren't completely compatible with the newest versions of Ionic.

This isn't an exact fix to the problem, but it is what we came up with when we ran into this issue in our project. Every time a user logs onto the app cancel all the notifications, and then schedule the next X number of days right then just using "at". If the user doesn't log in for a week, month, quarter, etc. then they probably didn't want the notifications anymore and it is ok for them to stop anyways. Not a perfect solution, but it works for us. Hope that helps.

Upvotes: 1

Eber
Eber

Reputation: 179

Another options is to specify the weekday (Monday is first day of the week). If you want to trigger something 2 times a week you have to schedule 2 notifications. In the tests I did with the master branch worked correctly.

Exemple:

cordova.plugins.notification.local.schedule({
    id: 1,
    title: "New Scheduled Task" ,
    text: "Hi world",
    trigger: { every: { weekday: 1, hour: 10, minute: 0 } }
});  

Upvotes: 1

Related Questions