katzer / cordova-plugin-local-notifications

Cordova Local-Notification Plugin
Apache License 2.0
2.56k stars 1.75k forks source link

FirstAt and every parameter not working in IOS & Android #1548

Closed sudattadesai72 closed 2 days ago

sudattadesai72 commented 6 years ago

WARNING: IF YOU IGNORE THIS TEMPLATE, WE'LL IGNORE YOUR ISSUE. YOU MUST FILL THIS IN!

Provide a general summary of the issue.

Your Environment

Expected Behavior

Notification should appear every day at specific time.

Actual Behavior

Ios: every parameter not working and notification are not getting triggered. Android : Notification get triggered but not at specific time.

Steps to Reproduce

let momentOfFirstAt = moment(currentDateTime); let firstAt = new Date(momentOfFirstAt.toString()); cordova.plugins.notification.local.schedule({ title: "Daily Reminder", trigger:{ at: firstAt, every: "day" }, foreground:true });

Context

Trying to show a notification everyday at a specific date.

Debug logs

-

MZanggl commented 6 years ago
let momentOfFirstAt = moment(currentDateTime);
let firstAt = new Date(momentOfFirstAt.toString());

Aren't you just getting the current date like that, therefore triggering it immediately? Maybe you should add one day to it. That's what I am doing, but it is still not working for me.

I am using the same version. For me, the notification just never triggers. (just tested on Android).

    let d = new Date() 
    d.setDate(d.getDate()+1)
    d.setHours(9)
    d.setMinutes(0)
    d.setSeconds(0)

    cordova.plugins.notification.local.schedule({
      id: 1,
      text: "Time for your daily dose!",
      trigger: {
        firstAt: d,
        every: "day"
      }
    })

This should create a notification every day at 9AM starting the next day, but I do not receive it. If I leave out every: "day" it works fine btw.

katche70 commented 6 years ago

same problem to me testet on android with cordova-plugin-local-notification 0.9.0-beta.2

mabuonomo commented 6 years ago

same problem

firstAt (or at:) and every not work togheter

I need create a notification every day at same time

mabuonomo commented 6 years ago

this examples works

` var now = new Date().getTime(), _5_sec_from_now = new Date(now + 5 * 1000);

        cordova.plugins.notification.local.schedule({
            text: "Delayed Notification",
            at: _5_sec_from_now,
            every: "minute",
            led: "FF0000",
            sound: null
        });`

With every "minute", the first notification start not at 5 seconds from now but at 1' and 5'', without "minute" start after 5 seconds

gecsbernat commented 6 years ago

I solved it. First create a notification object, then pass that object to the schedule method. No need for 'at' or 'firstAt' option.

let notification = {
 id: 1,
 title: 'TITLE',
 text: 'TEXT',
 trigger: { every: { hour: 10, minute: 0 } }
};

this.localNotifications.schedule(notification);

This will trigger notification every day at 10:00 from now. If today we passed 10:00 it will start tomorrow. Plugin version: 0.9.3-beta.3 Tested on IONIC3 IOS 11+ :)

katche70 commented 6 years ago

@mabuonomo your syntax is for version under 0.9 und should not be valid. @gecsbernat code is working on android with Plugin version: 0.9.3-beta.3 👍

mabuonomo commented 6 years ago

@katche70 in my case the @gecsbernat's code work fine on android (7/8)

sudattadesai72 commented 6 years ago

@gecsbernat code is working fine on android with Plugin version: 0.9.0-beta.3 👍 Thank you so much!!! Can we customize notification on days and off days for same ??

Thanks in advance.

ghost commented 6 years ago

The notification keeps coming until after the time the time has expired.

chakri3130 commented 6 years ago

I am scheduling a notification on particular dates of a month. But it is repeating everyday with same title. Same code is working on android. But it is not working on iOS version 11.4.Is it possible to trigger a notification without "every" keyword. Please help me. Thanks in adavnce.

this-is-saudkhan commented 5 years ago

The notification keeps coming until after the time the time has expired.

Yeah it keeps beeping until the time has expired