katzer / cordova-plugin-local-notifications

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

Repeated local notification not working #1651

Open stenioanibal opened 6 years ago

stenioanibal commented 6 years ago

Expected Behavior

I need to schedule one repeatable local notification to every Friday at 19h.

Actual Behavior

I using your plugin in ionic (https://ionicframework.com/docs/native/local-notifications/) but the parameters to repeat notifications is different of docs. In my case, parameters same every is a ELocalNotificationTriggerUnit, not string (like your docs). I'm trying create a schedule and repeatable notification in all Fridays of weeks but, this not working because, the comments of plugin file not light my life to perfect understand a method to implement that.

I try to implement equals actual docs but, not working.

This is the parameters of ILocalNotificationTrigger:

 /**
 * The date and time when the system should deliver the local notification. If the specified value is nil or is a date in the past, the local notification is delivered immediately.
 * Default: now ~ new Date()
 */
at?: Date;

/** ***** TIMESPAN ***** */
/**
 * Amount of units
 */
in?: number;

/**
 * Unit
 */
unit?: ELocalNotificationTriggerUnit;

/** ***** REPEAT/MATCH ***** */
/**
 * Amount of units
 */
count?: number;

/**
 * The unit
 */
every?: ELocalNotificationTriggerUnit;

/**
 * The end of the repeating notification
 */
before?: Date;

/**
 * The date and time when the system should deliver the local notification. If the specified value is nil or is a date in the past, the local notification is delivered immediately.
 * Only for "repeat"
 * Default: now ~ new Date()
 */
firstAt?: Date;

/**
 * Only for "match"
 */
after?: Date;

How i make that? Sorry for my mistake and thanks for your attention.

Simpler1 commented 5 years ago

Try:

        cordova.plugins.notification.local.schedule({
          id: notificationId,
          title: title,
          text: text,
          trigger: {
            every: {
              weekday: 5,
              hour: 19,
              minute: 0,
            },
            count: 365,
          },
        });
h3nr1ke commented 5 years ago

Try:

        cordova.plugins.notification.local.schedule({
          id: notificationId,
          title: title,
          text: text,
          trigger: {
            every: {
              weekday: 5,
              hour: 19,
              minute: 0,
            },
            count: 365,
          },
        });

if i nee to trigger every minute that matches "48", it will happen 24 times a day, so the counts will end after ~15 days, right?

how can I trigger a notification that matches a specific time forever ?

rushabhmakwana-multidots commented 5 years ago

@Simpler1 Could you please tell me that how can I set the repeated local notification for every weekday(Monday, Tuesday, Wednesday Thursday, Friday) at a specific time?

stenioanibal commented 5 years ago

@rushabhmakwana This is a expected result for me but, I can't get this in my tests. Now I trying to verify again this problem to find a solution. When I get that, I update this post to help you. Please @katzer help us with this problem.

stenioanibal commented 5 years ago

@Simpler1 What is the magic about the count: 365? This apparently works perfect for me but, I don't understand that because, independent of count value, the notification is successful fired, only one time in correct moment (different from case without the count, where the notification makes a loop into the entire minute). Can you explain this count for us? Unfortunately, the docs not light this for me.

MoradAbdelgaber commented 5 years ago

Is there any solutions for this problem ? @rushabhmakwana

mschristo commented 5 years ago

Check this #1533