zo0r / react-native-push-notification

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

Unstable push notifications on Android 12 #2341

Closed trinhnguyen81 closed 3 months ago

trinhnguyen81 commented 1 year ago

Bug

Unstable push notifications on Android 12 on Android 9 or 10 it's still okay

Environment info

react-native info output:

System:
    OS: macOS 11.6
    CPU: (4) x64 Intel(R) Core(TM) i5-3340M CPU @ 2.70GHz
    Memory: 86.71 MB / 8.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.0.0 - ~/.nvm/versions/node/v16.0.0/bin/node
    Yarn: 1.22.18 - ~/.nvm/versions/node/v16.0.0/bin/yarn
    npm: 7.10.0 - ~/.nvm/versions/node/v16.0.0/bin/npm
    Watchman: 2022.03.21.00 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.2, iOS 15.2, macOS 12.1, tvOS 15.2, watchOS 8.3
  IDEs:
    Android Studio: 2021.1 AI-211.7628.21.2111.8193401
    Xcode: 13.2.1/13C100 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.8.6 => 16.8.6
    react-native: 0.60.6 => 0.60.6

Library version: ^8.1.1

Steps To Reproduce

I created a channel like this PushNotification.createChannel( { channelId, // (required) channelName: 'Channel', // (required) importance: Importance.HIGH, // (optional) default: Importance.HIGH. Int value of the Android notification importance vibrate: true, // (optional) default: true. Creates the default vibration pattern if true. playSound: true, soundName: "beeps.mp3" }, (created) => console.log(createChannel returned '${created}') // (optional) callback returns whether the channel was created, false means it already existed. );

then create a list schedule push with time different like this const localNotificationSchedule = (id, time, message, sound, playSound = true, vibrate = true) => { const option = { autoCancel: true, largeIcon: 'ic_launcher', vibrate, vibration: 300, playSound, priority: 'high', importance: 'high', soundName: sound, ignoreInForeground: true, userInfo: { id: Number(id) }, message, date: new Date(time) } if (IS_ANDROID) { const channelId = getChannelIdBySound({sound, playSound, vibrate})

option.channelId = channelId

} PushNotification.localNotificationSchedule(option) }

Actually: it does not push correct time, it will accumulate and push 1 time, you can check image below 1672917503091

Describe what you expected to happen:

I wan to push correct time, pls help me

ajalasegun1 commented 1 year ago

Do something like this to set a correct time: const getCorrectDate = () => { const date = new Date(); date.setDate(date.getDate() + 1); date.setHours(23); date.setMinutes(54); return date; };

trinhnguyen81 commented 1 year ago

hi @ajalasegun1 not same that, but it works well on every version os, only without Android 12 and ios 16 :(

Arkan4ik commented 1 year ago

@trinhnguyen81 have you found solution?

github-actions[bot] commented 4 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.