Giter Site home page Giter Site logo

Comments (23)

elnezah avatar elnezah commented on April 28, 2024 6

I have the same problem as many here: want to place a weekly notification on a certain time of the day. Anybody knows what the parameter count is for? What happens if you combine every and on?

There is a huge lack of documentation here.

from capacitor-plugins.

ralscha avatar ralscha commented on April 28, 2024 3

Hi. You can already do that with on.

"remind every day on 08:00 am"

        schedule: {
          on: {
            hour: 8,
            minute: 0
          }
        }

"remind every day on 11:00 am"

        schedule: {
          on: {
            hour: 11,
            minute: 0
          }
        }

"remind every month on the 17th on 7:00 am"

        schedule: {
          on: {
            day: 17
            hour: 7,
            minute: 0
          }
        }

from capacitor-plugins.

slevy85 avatar slevy85 commented on April 28, 2024 2

I think this an important feature for notifications, this issue is also the same as #2752

from capacitor-plugins.

digaus avatar digaus commented on April 28, 2024 2

Is it possible you look into this? I am fairly certain it would be easy on the android side at least.

Just make it possible to combine at with every or on.

The current interval for repeating notifications using at does not make any sense https://github.com/ionic-team/capacitor-plugins/blob/main/local-notifications/android/src/main/java/com/capacitorjs/plugins/localnotifications/LocalNotificationManager.java#L348

I would suggest to just use the at parameter as a startTime for the repeating alarm when every or on is set.

https://github.com/ionic-team/capacitor-plugins/blob/main/local-notifications/android/src/main/java/com/capacitorjs/plugins/localnotifications/LocalNotificationManager.java#L365
https://github.com/ionic-team/capacitor-plugins/blob/main/local-notifications/android/src/main/java/com/capacitorjs/plugins/localnotifications/LocalNotificationManager.java#L374

For iOS we would have to do something similar.

Any reason against this?

from capacitor-plugins.

ionicsiva avatar ionicsiva commented on April 28, 2024 2

bumping this up. As users of ionic, we would like to be able to setup a daily notification at a specific time. (and a weekly one on a specific day and specific time)

the source code https://github.com/ionic-team/capacitor-plugins/blob/main/local-notifications/android/src/main/java/com/capacitorjs/plugins/localnotifications/LocalNotificationManager.java#L340

does not seem to support that functionality.

If we use "every": day", we can't specify the start time. (kinda important, don't you think?) source code does this: long startTime = new Date().getTime() + everyInterval; should be long startTime = schedule.getAt() // but if there's an at specified, we don't get this far in the code.

if we use "on:" new Date(year, month, day, hour, minute, second) and "repeat", it repeats once a year. (or can we use count 365?)

The original poster covered it pretty clearly. We spent 2 days on this before digging into the source code.

I have the same issue as many others here: I want to build a daily notification on which time is selected in frontend and want to execute a daily notification at the same time every day. I tried the repeats: true and every: 'day' here, but it didn't work for me. I tried this and searched everywhere.

I'm Using Ionic with angular on that am Using the Local Notification capacitor plugin.

Look for my code below.

import { LocalNotifications } from '@capacitor/local-notifications';

async setAlarm() {
const now = new Date();
const alarmDate = new Date(this.alarmTime);
const alarmTime = new Date();
alarmDate.setFullYear(now.getFullYear(), now.getMonth(), now.getDate());

if (alarmDate <= now) {
alarmDate.setDate(alarmDate.getDate() + 1);
}

await LocalNotifications.schedule({

notifications: [
{
title: 'Alarm',
body: 'Time to wake up!',
id: 1,
schedule: {
at: new Date(this.alarmTime),
repeats: true,
every: 'day',
},
actionTypeId: '',
extra: null,
},
],
});

alert('Alarm set for ' + alarmDate.toLocaleTimeString() + '.');
}

from capacitor-plugins.

daveshirman avatar daveshirman commented on April 28, 2024 1

@mlynch
@jcesarmobile

The documentation for this (V3) is extremely lacking. Please can someone update it to provide a way to:

  1. Schedule a DAILY notification at a specific time, e.g. Every DAY at 15:00
  2. Schedule a WEEKLY notification at a specific time, e.g. Every WEEK at 15:00
  3. Schedule a SPECIFIC DAY OF THE WEEK notification at a specific time, e.g. Every WEDNESDAY at 15:00

This is what we are trying to work out. The silence from the team is extremely frustrating. We want to use the Capacitor plugins, but if they aren't properly documented, how are we supposed to use and trust them over old Cordova ones?

Thanks.

from capacitor-plugins.

daveshirman avatar daveshirman commented on April 28, 2024 1

+1 - I have been struggling with this issue for days. I can't find any relevant information on how to do this. I see a lot of different questions and issue about this, but no feedback from the core team?

the documentation says it's possible, but from what I can tell it dose not seem to be the case for daily or weekly reminders.

I've only tested this on Android (7, 9, 11) - but feel free to do what I did here, it's a workaround, but it works in my testing so far:

https://www.codingandclimbing.co.uk/blog/android-localnotifications-with-cordova-capacitor-example

from capacitor-plugins.

danielmalmros avatar danielmalmros commented on April 28, 2024 1

@ionicsiva we had the exact same issue on our end. I really hope this is something the Capacitor team will prioritise.

After spending days trying to solve this and even play around with source code, we decided to go with a backend implementation and OneSignal for all of our notifications. But with that said, the local notification should something that is a core part of Capacitor.

from capacitor-plugins.

jansgescheit avatar jansgescheit commented on April 28, 2024 1

Daily Notifications should work. In my app the user can set a weekday and a time when notification should be sent, e.g.

import { LocalNotificationSchema, LocalNotifications, Weekday } from '@capacitor/local-notifications';


const notifyAt = new Date();
const notifications: LocalNotificationSchema = [
    Weekday.Monday,
    Weekday.Tuesday,
    Weekday.Wednesday,
    Weekday.Thursday,
    Weekday.Friday,
    Weekday.Saturday,
    Weekday.Sunday,
]
.map(weekday => {
    return {
        title: 'some title',
        body: 'some body',
        id: weekday,
        schedule: {
            on: {
                weekday,
                minute: notifyAt.getMinutes(),
                second: 0,
                hour: notifyAt.getHours(),
            },
        },
    };
});

await LocalNotifications.schedule({ notifications })

from capacitor-plugins.

ionicsiva avatar ionicsiva commented on April 28, 2024 1

Daily Notifications should work. In my app the user can set a weekday and a time when notification should be sent, e.g.

import { LocalNotificationSchema, LocalNotifications, Weekday } from '@capacitor/local-notifications';


const notifyAt = new Date();
const notifications: LocalNotificationSchema = [
    Weekday.Monday,
    Weekday.Tuesday,
    Weekday.Wednesday,
    Weekday.Thursday,
    Weekday.Friday,
    Weekday.Saturday,
    Weekday.Sunday,
]
.map(weekday => {
    return {
        title: 'some title',
        body: 'some body',
        id: weekday,
        schedule: {
            on: {
                weekday,
                minute: notifyAt.getMinutes(),
                second: 0,
                hour: notifyAt.getHours(),
            },
        },
    };
});

await LocalNotifications.schedule({ notifications })

Thank you for your assistance; it's working. Sending love from India!👍❤️

from capacitor-plugins.

DonWolfram avatar DonWolfram commented on April 28, 2024

Hi, I got the same issue here. Daily reminders at a specific time would be awesome!

from capacitor-plugins.

haschu avatar haschu commented on April 28, 2024

@ralscha Ah, thanks! Going to try that out :)

from capacitor-plugins.

jansgescheit avatar jansgescheit commented on April 28, 2024

I have a similar problem. The documentation is unfortunately insufficient. I would like to send notifications every Monday at 20:00, is that possible?

from capacitor-plugins.

ralscha avatar ralscha commented on April 28, 2024

@jannnnnn Don't see a way to do that with the current implementation. A startTime for every would solve that. Or if on would support a day of week property, like cron.

from capacitor-plugins.

jansgescheit avatar jansgescheit commented on April 28, 2024

@ralscha I went through the source code and come to the same conclusion. I have now switched back to the cordova plugin https://github.com/katzer/cordova-plugin-local-notifications

from capacitor-plugins.

askilondz avatar askilondz commented on April 28, 2024

Looking for the ability to schedule a notification on a specific day of the week every week like @jannnnnn mentioned. Any other thoughts on how to achieve this?

from capacitor-plugins.

elnezah avatar elnezah commented on April 28, 2024

@ralscha I went through the source code and come to the same conclusion. I have now switched back to the cordova plugin https://github.com/katzer/cordova-plugin-local-notifications

I have used this plugin for long. Is very buggy, not reliable, be careful and make a lot of test.

from capacitor-plugins.

alphagamer7 avatar alphagamer7 commented on April 28, 2024

Bump

from capacitor-plugins.

danielmalmros avatar danielmalmros commented on April 28, 2024

+1 - I have been struggling with this issue for days. I can't find any relevant information on how to do this. I see a lot of different questions and issue about this, but no feedback from the core team?

the documentation says it's possible, but from what I can tell it dose not seem to be the case for daily or weekly reminders.

from capacitor-plugins.

danielmalmros avatar danielmalmros commented on April 28, 2024

+1 - I have been struggling with this issue for days. I can't find any relevant information on how to do this. I see a lot of different questions and issue about this, but no feedback from the core team?
the documentation says it's possible, but from what I can tell it dose not seem to be the case for daily or weekly reminders.

I've only tested this on Android (7, 9, 11) - but feel free to do what I did here, it's a workaround, but it works in my testing so far:

https://www.codingandclimbing.co.uk/blog/android-localnotifications-with-cordova-capacitor-example

@daveshirman amazing job with that blog post! Maybe just mention that it only seems to work with the 0.9.0-beta.3 cordova plugin. Looks like npm is installing the 0.9.0-beta.2 version. I'll do some more testing on both Android and iOS tomorrow to see if it helps with the daily reminders.

With that said, I still hope to see some clarification around the daily reminders from the Ionic team on the @capacitor/local-notifications plugin 🙏

from capacitor-plugins.

daveshirman avatar daveshirman commented on April 28, 2024

+1 - I have been struggling with this issue for days. I can't find any relevant information on how to do this. I see a lot of different questions and issue about this, but no feedback from the core team?
the documentation says it's possible, but from what I can tell it dose not seem to be the case for daily or weekly reminders.

I've only tested this on Android (7, 9, 11) - but feel free to do what I did here, it's a workaround, but it works in my testing so far:
https://www.codingandclimbing.co.uk/blog/android-localnotifications-with-cordova-capacitor-example

@daveshirman amazing job with that blog post! Maybe just mention that it only seems to work with the 0.9.0-beta.3 cordova plugin. Looks like npm is installing the 0.9.0-beta.2 version. I'll do some more testing on both Android and iOS tomorrow to see if it helps with the daily reminders.

With that said, I still hope to see some clarification around the daily reminders from the Ionic team on the @capacitor/local-notifications plugin 🙏

Have updated my post to reference exact plugin url I used, hint it's not the katzer one that appears everywhere:

npm install https://github.com/Steffaan/cordova-plugin-local-notifications.git;

@danielmalmros

EDIT: The notification didn't trigger for the consecutive days, so I've updated my post with count in the trigger, i.e:

trigger: { every: { hour: hours, minute: mins }, count: 365 },

Manually changing the date + time seems to trigger it, but will do more testing letting the phone do its thing over the next few days.

Any other info your side?

from capacitor-plugins.

tomeberhard avatar tomeberhard commented on April 28, 2024

bumping this up. As users of ionic, we would like to be able to setup a daily notification at a specific time. (and a weekly one on a specific day and specific time)

the source code
https://github.com/ionic-team/capacitor-plugins/blob/main/local-notifications/android/src/main/java/com/capacitorjs/plugins/localnotifications/LocalNotificationManager.java#L340

does not seem to support that functionality.

If we use "every": day", we can't specify the start time. (kinda important, don't you think?)
source code does this: long startTime = new Date().getTime() + everyInterval;
should be long startTime = schedule.getAt() // but if there's an at specified, we don't get this far in the code.

if we use "on:" new Date(year, month, day, hour, minute, second) and "repeat", it repeats once a year. (or can we use count 365?)

The original poster covered it pretty clearly. We spent 2 days on this before digging into the source code.

from capacitor-plugins.

galaxyblur avatar galaxyblur commented on April 28, 2024

Would love to see this supported!

from capacitor-plugins.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.