Cordova-plugin-local-notifications: FirstAt and every parameter not working in IOS & Android

Created on 1 Mar 2018  路  11Comments  路  Source: katzer/cordova-plugin-local-notifications

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

  • Plugin version:0.9.0-beta.3
  • Platform:iOS & Android
  • OS version: IOS: 10^ Android : 4.4^
  • Device manufacturer / model:Apple iPhone 6s Plus and iOS Simulator
  • Cordova version (cordova -v):7.1.0
  • Cordova platform version (cordova platform ls):ios 4.5.4
  • Plugin config: cordova-plugin-device 1.1.7 "Device"
    cordova-plugin-dialogs 1.3.4 "Notification"
    cordova-plugin-globalization 1.0.8 "Globalization"
    cordova-plugin-local-notification 0.9.0-beta.3 "LocalNotification"
    cordova-plugin-statusbar 2.2.0 "StatusBar"
    cordova-plugin-whitelist 1.3.3 "Whitelist"
    cordova-sqlite-ext 0.10.6 "Cordova sqlite"
  • Ionic Version (if using Ionic): 3.19.0

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
-

Most helpful comment

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+
:)

All 11 comments

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.

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

same problem

firstAt (or at:) and every not work togheter

I need create a notification every day at same time

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

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+
:)

@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 馃憤

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

@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.

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

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.

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

Yeah it keeps beeping until the time has expired

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jomarocas picture jomarocas  路  3Comments

faytekin picture faytekin  路  3Comments

ThorvaldAagaard picture ThorvaldAagaard  路  3Comments

AbayIbrayev picture AbayIbrayev  路  4Comments

ashvin777 picture ashvin777  路  3Comments