ionic-team / capacitor-plugins

Official plugins for Capacitor ⚡️
523 stars 586 forks source link

[@capacitor/local-notifications] - Android - Schedule Notification not sending on first occurrence. #2173

Open hommalex opened 2 months ago

hommalex commented 2 months ago

Bug Report

Plugin(s)

"@capacitor/app": "^6.0.0", "@capacitor/local-notifications": "^6.0.0",

Capacitor Version

6

Platform(s)

Android

Current Behaviour

run:

await LocalNotifications.schedule({
          notifications: [
            {
              id: Math.floor((Math.random() * 1000000) + 1),
              title: 'A Title',
              body: 'Some Body',
              schedule: {
                on: {
                    weekday: w, // a day of the week
                    hour: h, // some hours that week
                },
                every: 'week',
                allowWhileIdle: true,
              },
            }
          ]
        });

Expected Behaviour

Receiving a notification from the first occurrence. So, If on Monday the 1st, I set a notification to go every Tuesday at 12pm. I should receive a notification on Tuesday the 2nd.

What happen:

The notification is not sent on the First Tuesday of the occurrence. It is sent the Tuesday the following week. But not on the first Tuesday. This happens to Android device. So, the workaround is to manually set that missing notification. But then iOS users will receive 2 notifications on the first Tuesday.

Thank you to fix this.

Ionitron commented 2 months ago

This issue needs more information before it can be addressed. In particular, the reporter needs to provide a minimal sample app that demonstrates the issue. If no sample app is provided within 15 days, the issue will be closed.

Please see the Contributing Guide for how to create a Sample App.

Thanks! Ionitron 💙

hommalex commented 2 months ago

Hi Ionitron,

It's too easy to reproduce to spend time making a new sample app.

Just create an empty project add the @capacitor/local-notifications add the code from the bug report to the onload function

Nothing else to do here. You can even test it from an existing app.