nativescript-local-notifications icon indicating copy to clipboard operation
nativescript-local-notifications copied to clipboard

Schedule date not working as expected

Open andresilva-cc opened this issue 4 years ago • 4 comments

I'm trying to use this plugin to set up daily reminders for the user. The user can choose the time of the reminder then the app schedules the notification with 'day' interval. I was trying to create the date object like this:

const date = new Date();
date.setHours(15, 0); // actually it's a variable with the value the user set

The problem is that when I console.log the date, it shows the right hour/minute but in the wrong timezone (UTC), when the device (in this case an Android Emulator) is actually running with GMT -3 timezone (America/Sao_Paulo).

In any case, I tried to set up the notification to see what happens, but the notification won't show. I tried in a lot of different ways, using Unix time, using moment, moment-timezone, but each time I tried it would not give the right result.

The question I would ask here is: how to handle timezones when scheduling the notification?

But, I tried using the demo this repository provides, where it schedules the notification to 5 seconds from now using this:

new Date(new Date().getTime() + (5 * 1000));

And guess what? It doesn't show after 5 seconds, but after like 2 minutes. I also tried using different values (like 3-5 minutes), but they also show at the wrong time. This made me think that maybe whatever causing this is also related to the timezone problem I'm having.

In any case, any help on this would be very appreciated.

PS: Tested only on Android

andresilva-cc avatar Jul 13 '20 16:07 andresilva-cc

Any help on this?

andresilva-cc avatar Aug 05 '20 02:08 andresilva-cc

I have the same problem, cant find a solution.

Cersin avatar Dec 16 '20 10:12 Cersin

Delete interval and it works...

Cersin avatar Dec 16 '20 10:12 Cersin

Delete interval and it works...

I ended up using a server-side solution, but as far as I remember I didn't set a value for interval.

andresilva-cc avatar Dec 16 '20 12:12 andresilva-cc