ionic-team / capacitor

Build cross-platform Native Progressive Web Apps for iOS, Android, and the Web ⚡️
https://capacitorjs.com
MIT License
12.04k stars 999 forks source link

bug: Changing timeZone doesn't reschedule existing notifications #3873

Closed wal0x closed 8 months ago

wal0x commented 3 years ago

Bug Report

Capacitor Version

Capacitor Doctor

Latest Dependencies:

  @capacitor/cli: 2.4.3
  @capacitor/core: 2.4.3
  @capacitor/android: 2.4.3
  @capacitor/electron: 2.4.3
  @capacitor/ios: 2.4.3

Installed Dependencies:

  @capacitor/ios not installed
  @capacitor/cli 2.4.2
  @capacitor/android 2.4.2
  @capacitor/core 2.4.2
  @capacitor/electron not installed

[success] Android looking great! �

Platform(s)

Android

Current Behavior

When I schedule a local notification at a specific time, let's say 23h00, while the phone is on 17h59 UTC, and I change the timeZone manually to UTC+4 so the phone's time become 22h59. The local notification does not trigger when the phone arrive to 23h00 on the new timezone.

Expected Behavior

Local notification should be triggered at the new 23h00

Code Reproduction

const notifications: LocalNotification[] = [];
const notificationTime = new Date("2020-11-23T23:00:00.000Z");
notifications.push({
      title, body, id, schedule: {
        on: {
          hour: notificationTime.getHours(),
          minute: notificationTime.getMinutes()
        }
      }
    });
LocalNotifications.schedule({ notifications });

Other Technical Details

npm --version output: 6.14.8

node --version output: v12.19.0

pod --version output (iOS issues only):

Additional Context

At first I was using LocalNotificationSchedule.at like :

notifications.push({
  title, body, id, schedule: { at: new Date(notificationTime) }
});

and I thought that the problem is due to the fact that I pass a Javascript Date object containing already a Timezone. So I switched to use LocalNotificationSchedule.on as above.

roelofsaj commented 2 years ago

Is there any update or a workaround for this? I'm running into the same issue on iOS.

jcesarmobile commented 8 months ago

closing due to the lack of sample app reproducing the issue if the issue is still present, please, report it on https://github.com/ionic-team/capacitor-plugins/issues and provide a sample app

ionitron-bot[bot] commented 7 months ago

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.