zo0r / react-native-push-notification

React Native Local and Remote Notifications
MIT License
6.73k stars 2.05k forks source link

Daily local notification is sent earlier than expected on iOS physical device #2315

Closed tsiareshchankau closed 8 months ago

tsiareshchankau commented 1 year ago

Bug

On iOS physical devices daily notification is not respecting the date as a start date.
If the HH:mm of the date is greater than current time, the notification would be received today regardless of the date being in the future (i.e tomorrow etc)

Environment info

react-native info output:

 System:
    OS: macOS 12.6
    CPU: (8) arm64 Apple M1 Pro
    Memory: 103.16 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.14.0 - ~/.nvm/versions/node/v16.14.0/bin/node
    Yarn: Not Found
    npm: 8.3.1 - ~/.nvm/versions/node/v16.14.0/bin/npm
    Watchman: Not Found
  Managers:
    CocoaPods: 1.11.3 - /opt/homebrew/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
    Android SDK: Not Found
  IDEs:
    Android Studio: 2021.2 AI-212.5712.43.2112.8815526
    Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild
  Languages:
    Java: Not Found
    Python: Not Found
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.13.1 => 16.13.1 
    react-native: ~0.63.4 => 0.63.4 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Library version: 8.1.1

Steps To Reproduce

Test on physical iOS device.

  1. Schedule a local notifications with the date for tomorrow + a couple minutes (from now), repeatType === 'day'
  2. Get all local notifications PushNotification.getScheduledLocalNotifications
  3. The date does not match the one passed to the scheduler, instead it only has the same HH:mm:ss but date is set to today
  4. Notifications is received today

Describe what you expected to happen:

  1. When retrieving all local notifications the date of the notification equals to the one passed to the PushNotification.localNotificationSchedule
  2. Notifications starts firing from the date passed to the PushNotification.localNotificationSchedule and repeats daily starting from then
tsiareshchankau commented 1 year ago

It seems like it's a specific behaviour of iOS. Folks writing the native code have the same struggles https://stackoverflow.com/questions/41449749/how-can-i-skip-the-first-occurrence-of-a-repeating-uncalendarnotificationtrigger

github-actions[bot] commented 9 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions.