Hi,
I don't have technical issue so ignored template. I want to show notification on specific time 10AM every day.
So how should i add time on "at" attribute?
I personnaly use momentJs library to easily manipulate times. scheduler method waits a date object of the first occurence of your repeating event. In next exemple the notification will trigger every day at 10am starting tomorrow.
var tomorrow10 = moment().add(1, 'days').hours(10).minutes(0).seconds(0);
cordova.plugins.notification.local.schedule({
id: 0,
text: "It's time !",
every: 'day',
firstAt: tomorrow10.toDate()
});
Don't use at: and every: and firstAt: together as they don't work under IOS10 and will not work as Apple has changed the framework. Use at: and schedule things yourself.
@rwillett Is it a temporary behavior linked to the cordova plugin or do we need to stop "forever" to use repeating notification (or schedule them manually)
@Mihir7
I don't have technical issue so ignored template.
Doesn't imply to ignore the template!
I want to show notification on specific time 10AM every day.
Thats possible with IOS10. There's no plugin interface for such things. As I've started to work on the plugin now I am looking to add that.
@rwillett Don't use at: and every: and firstAt: together as they don't work under IOS10 and will not work as Apple has changed the framework.
firstAt:
) anymore.OK, with the next version (at least for iOS) you will be able to do as following:
cordova.plugins.notification.local.schedule({
title: "Happy Birthday!",
text: "It's 9 AM at your birthday"
every: { month: 2, day: 29, hour: 9 }
});
I just want to use it for android..
Can you show me how it will work in android?
Hi,
In this code i set 3 notification for today, but all 3 gets notified whn i install the app and not at the time mentioned. Can you please help me find out what is going wrong.
And @ZenSide can you help me out here without momentjs..
`var today = new Date();
var tomorrow = new Date();
tomorrow.setDate(today.getDate());
tomorrow.setHours(2);
tomorrow.setMinutes(16);
tomorrow.setSeconds(0);
var tomorrow_at_11_am = new Date(tomorrow);
var today2 = new Date();
var tomorrow2 = new Date();
tomorrow2.setDate(today2.getDate());
tomorrow2.setHours(2);
tomorrow2.setMinutes(18);
tomorrow2.setSeconds(0);
var tomorrow_at_5_pm = new Date(tomorrow2);
var today3 = new Date();
var tomorrow3 = new Date();
tomorrow3.setDate(today3.getDate());
tomorrow3.setHours(2);
tomorrow3.setMinutes(19);
tomorrow3.setSeconds(0);
var tomorrow_at_8_pm = new Date(tomorrow3);
cordova.plugins.notification.local.schedule([{
id: 1,
text: "Hello1!",
firstAt: tomorrow_at_11_am,
every: "day"
}, {
id: 2,
text: "Hello2!",
firstAt: tomorrow_at_5_pm,
every: "day"
}, {
id: 3,
text: "Hello3",
firstAt: tomorrow_at_8_pm,
every: "day"
}]); `
@Mihir7
You have a technical issue, that is why the template is there. You have provided zero information about your background and what you are doing apart from a code fragment. Use the template.
Rob
cordova -v
): 6.3.1cordova platform ls
): android 5.2.2I am setting 3 notifications for day at different times, eg - 11am, 5pm, 8pm - so the app should send local notifications at those times,
But the app sends all the notifications all at once during the last notification of the day. Here at 8pm it send all the 3 notifications..It doesn't give notification on 11am and 5pm, instead it shows all 3 at 8pm.
In this example the time is different, with few minutes gap. all the notification is shows at 14:19..
`var today = new Date();
var tomorrow = new Date();
tomorrow.setDate(today.getDate());
tomorrow.setHours(14);
tomorrow.setMinutes(16);
tomorrow.setSeconds(0);
var tomorrow_at_11_am = new Date(tomorrow);
var today2 = new Date();
var tomorrow2 = new Date();
tomorrow2.setDate(today2.getDate());
tomorrow2.setHours(14);
tomorrow2.setMinutes(18);
tomorrow2.setSeconds(0);
var tomorrow_at_5_pm = new Date(tomorrow2);
var today3 = new Date();
var tomorrow3 = new Date();
tomorrow3.setDate(today3.getDate());
tomorrow3.setHours(14);
tomorrow3.setMinutes(19);
tomorrow3.setSeconds(0);
var tomorrow_at_8_pm = new Date(tomorrow3);
cordova.plugins.notification.local.schedule([{
id: 1,
text: "Hello1!",
firstAt: tomorrow_at_11_am,
every: "day"
}, {
id: 2,
text: "Hello2!",
firstAt: tomorrow_at_5_pm,
every: "day"
}, {
id: 3,
text: "Hello3",
firstAt: tomorrow_at_8_pm,
every: "day"
}]); `
mentioned in Expected behaviour
No logs, app runs successfully
The plugin does not work properly when you use 'firstat' and 'every' for scheduling. Try just 'at' to schedule.
(spelling and grammer powered by autocorrupt)
On Jul 12, 2017, 2:42 AM -0700, Mihir7 notifications@github.com, wrote:
Your Environment
• Plugin version: "0.8.2dev"
• Platform: android
• Device manufacturer / model: Mi
• Cordova version (cordova -v): 6.3.1
• Cordova platform version (cordova platform ls): android 5.2.2
• Plugin configExpected Behavior
I am setting 3 notifications for day at different times, eg - 11am, 5pm, 8pm - so the app should send local notifications at those times,
Actual Behavior
But the app sends all the notifications all at once during the last notification of the day. Here at 8pm it send all the 3 notifications..It doesn't give notification on 11am and 5pm, instead it shows all 3 at 8pm.
Code
In this example the time is different, with few minutes gap. all the notification is shows at 14:19..
var today = new Date(); var tomorrow = new Date(); tomorrow.setDate(today.getDate()); tomorrow.setHours(14); tomorrow.setMinutes(16); tomorrow.setSeconds(0); var tomorrow_at_11_am = new Date(tomorrow); var today2 = new Date(); var tomorrow2 = new Date(); tomorrow2.setDate(today2.getDate()); tomorrow2.setHours(14); tomorrow2.setMinutes(18); tomorrow2.setSeconds(0); var tomorrow_at_5_pm = new Date(tomorrow2); var today3 = new Date(); var tomorrow3 = new Date(); tomorrow3.setDate(today3.getDate()); tomorrow3.setHours(14); tomorrow3.setMinutes(19); tomorrow3.setSeconds(0); var tomorrow_at_8_pm = new Date(tomorrow3); cordova.plugins.notification.local.schedule([{ id: 1, text: "Hello1!", firstAt: tomorrow_at_11_am, every: "day" }, { id: 2, text: "Hello2!", firstAt: tomorrow_at_5_pm, every: "day" }, { id: 3, text: "Hello3", firstAt: tomorrow_at_8_pm, every: "day" }]);
Context
mentioned in Expected behaviour
Debug logs
No logs, app runs successfully
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
Thanks @Tawpie . With 'at' it works good..
Hi, @Tawpie
I changed firstat to 'at' - then i got first notification on time, but second and third notification together at the time of third notification.
Also i didn't got notification on second day as i have mention every:"day" also.
Can you please help me out here..
Sure. I haven't tried using "every", so not certain how well that works (there are known problems with _every_ and _firstat_ and may well be problems with _every_ and _at_ as well) but there's a flaw in your creation of the dates...
Specifically, var tomorrow_at_8_pm = new Date(tomorrow3);
will return undefined (on Safari at least). You already have tomorrow3
set to a date so instead try tomorrow_at_8_pm = tomorrow3;
oh. And you're not getting "tomorrow" by the way, your date creation simply sets the time to today at 1419. Since you're scheduling using "every" and assuming that "every" actually works, you would think that it doesn't matter. But it might.
For what it's worth, I don't use _every_, instead I compute each fire date/time individually and schedule them as individual notifications. There are limitations though, so you have to be aware of that. Search the issues for "firstat", there's lots of discussion.
Lastly, your second and third notifications are scheduled a second apart... on Android notifications will NOT fire at their exact fire time, it seems to be "within a few minutes" of scheduled time. So it's not surprising you got #2 and #3 at the same time.
Thanks @Tawpie
First issue is solved, i created more time gap and it gives 2nd and 3rd notification differently with time gap in between..
But every is not working, i decided to use this plugin for "every : day". Am i doing something wrong, or does it not work with 'at' also. As you are also not using it and you made your own logic for it.
@katzer can you help me out here..
@rwillett and @katzer There is any error in this code bellow? It works fine for the current day, but on the next day it is not fired.
__I'm testing using iOS 10.3.3__
now = new Date();
const tenSeconds = 10000;
const tenMinutes = 600000;
// meal = "07:00:00"
t = val.meal.split(':');
now.setHours(parseInt(t[0]));
now.setMinutes(parseInt(t[1]));
now.setSeconds(0);
now.setMilliseconds(0);
reminder = new Date(now.getTime() + tenSeconds - tenMinutes);
$cordovaLocalNotification.schedule({
id: (key + 1),
title: 'Hora da refeição',
text: 'Daqui a 10min será o seu ' + val.tipo_refeicao,
every: 'day',
at: reminder
});
Yes, you are using at:
and every:
.
You are adding ten seconds to the time now and then taking away ten minutes, that means you are scheduling in the past. Don't, no idea what will happen.
Your code to create the now time is long winded. I gave up trying to work out what you think it does.
No idea if val.tipo_refeicao is declared.
No idea if key is declared.
Hi, I'm facing the same issue. I have the latest version of the plugin installed and I'm testing on Android 6.0 (real device). I want to schedule a notification for every day at fixed time like this:
var now = new Date();
cordova.plugins.notification.local.schedule({
id: 1,
text: "Test message",
title: "Test title",
every: "day", // "minute" or integers - same result
at: new Date(now.getYear(), now.getMonth(), now.getDate()+1, 10, 0, 0, 0) // "firstAt" - same result
});
Only one notification is received...
I saw from the comments that every
,at
and firstAt
are not compatible with each other, but how am I supposed to schedule the notification?
Thanks in advance :)
Stella:
Because the “every” feature is not working properly, the workaround is to schedule each notification individually using an array. True, each phone OS imposes limits on how many notifications you can schedule this way so your user must open the app on occasion (so you can schedule the next batch). It’s certainly a workaround and not ideal, but it does work while the “every” feature is fixed.
On Sep 20, 2017, at 7:07 AM, Stella Gavrailova notifications@github.com wrote:
Hi, I'm facing the same issue. I have the latest version of the plugin installed and I'm testing on Android 6.0 (real device). I want to schedule a notification for every day at fixed time like this:
var now = new Date();
cordova.plugins.notification.local.schedule({
id: 1,
text: "Test message",
title: "Test title",
every: "day", // "minute" or integers - same result
at: new Date(now.getYear(), now.getMonth(), now.getDate()+1, 10, 0, 0, 0) // "firstAt" - same result
});Only one notification is received...
I saw from the comments that every,at and firstAt are not compatible with each other, but how am I supposed to schedule the notification?Thanks in advance :)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
Hi,
I tried setting 'at' in ms (new Date.getTime()) instead of Date object and is working fine with 'every' property.
Hope this could help someone too. :)
That's possible with 0.9-beta
schedule({
trigger: { every: { hour: 10, minute: 0 } }
})
@stelllla thanks a lot, we did the same and it seems to work fine (tested OK in iOS 8 & 9, and Android too).
We are using 0.8.5, and the syntax at: date_in_ms, every: "day"
@katzer I would like to thank you for this, and I do confirm your suggested syntax works fine in version 0.9.0-beta.3
and not in 0.9.0-beta.2
.
I don't know why cordova plugin add cordova-plugin-local-notification
installs version 0.9.0-beta.2
by default. is any reason behind it?
It seems version 0.9.0-beta.2
displays a notification for each seconds! of chosen { hour: x, minute: y }
. and I have to uninstall the app for interrupting receiving notifications.
@katzer
the syntax is not working for me in on both 0.9.0-beta.3 and 0.9.0-beta.2. Please help. How to get it work with ionic/native.
@amansinghA2 in the Readme is mentioned that this plugin is not quite compatible with ionic/native wrapper. So here you can use this plugin without it:
add following line next to your imports:
declare var cordova: any;
then access this plugin with this prefix:
cordova.plugins.notification
for example:
cordova.plugins.notification.local.schedule({
id: 1,
title: 'MarsIsNext',
text: 'Are you ready to travel to planet Mars today? :)',
trigger: { every: { hour: 10, minute: 10 } }
});
Thanks.
P.S. see my previous comment if you also had (my) issue with version 0.9.0-beta.2
.
@SidMorad Thankyou sid for the prompt reply. I already tried it but got the ( undefined is not an object) error. What am i doing wrong?
@SidMorad Thankyou so much Sid , reinstalling the plugin and following your solution did the trick for me.
None worked of me. I just managed with recursive way as below
this.localNotifs.on('trigger').subscribe(notification => {
console.log("Triggering notification (Page)",notification);
if(notification.id == 999) {
this.localNotifs.clear(notification.id).then((result)=> {
console.log('Successfully cleared',result);
var d1 = new Date();
d1.setDate(d1.getDate()+1);
d1.setHours(5,0,0,0);
this.localNotifs.schedule({
id: 999,
trigger: { at: d1 }
});
}).catch((err)=> {
console.log('Failed clearing notification',err);
})
@SidMorad it works for me on iOS 12 and 0.9.0-beta.3 thanks.
If you use ionic, I don't recomand using natif plugin...
@katzer BIG thanks for your amazing plugins
for iOS count parameter doesn't work see my xCode warning :
WARN: trigger: { count: } is not supported on iOS.
With this code :
cordova.plugins.notification.local.schedule({
id: 1,
title: 'MarsIsNext',
text: 'Are you ready to travel to planet Mars today? :)',
trigger: { every: "minute", count: '3' }
Most helpful comment
@amansinghA2 in the Readme is mentioned that this plugin is not quite compatible with ionic/native wrapper. So here you can use this plugin without it:
add following line next to your imports:
then access this plugin with this prefix:
for example:
Thanks.
P.S. see my previous comment if you also had (my) issue with version
0.9.0-beta.2
.