question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Notifications appear ONLY after opening the app!

See original GitHub issue

Bug

Hi there!

Amazing work with this package and it is working almost flawlessly. However, some of my android users have reported that their scheduled notifications are not arriving and are only being shown AFTER they have opened the app. This can be many notifications being shown at once if more than one scheduled notification already passed.

I did not see any other similar issue being open and wanted to see if anyone else has experienced this issue? All notifications within the app are scheduled locally.

On iOS it hasn’t been reported!

Environment info

react-native info output:

System:
    OS: macOS 10.15.3
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
    Memory: 65.34 MB / 16.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 8.9.4 - /usr/local/bin/node
    npm: 6.9.0 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 13.5, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
    Android SDK:
      API Levels: 23, 25, 26, 27, 28
      Build Tools: 26.0.2, 26.0.3, 27.0.2, 27.0.3, 28.0.2, 28.0.3
      System Images: android-28 | Google Play Intel x86 Atom, android-P | Google APIs Intel x86 Atom
  IDEs:
    Android Studio: 3.4 AI-183.6156.11.34.5692245
    Xcode: 11.5/11E608c - /usr/bin/xcodebuild
  npmPackages:
    react: 16.8.6 => 16.8.6 
    react-native: 0.60.4 => 0.60.4 
  npmGlobalPackages:
    create-react-native-app: 1.0.0
    react-native-cli: 2.0.1
    react-native-git-upgrade: 0.2.7

Library version: "react-native-push-notification": "^3.5.1",

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:11
  • Comments:74

github_iconTop GitHub Comments

5reactions
Vadimiennecommented, Oct 30, 2020

@raphaelrupprecht same story, a tough month trying to find a solution. I’m so happy I’ve found this thread though. I have the exact same problem testing notifications on my Xiaomi Poco F1. I did some digging into native documentation and here is what I found out: There are two classes used in process of creating a notification NotificationCompat is responsible for notification itself. NotificationChannel is responsible for notification channels.

Here is a priority setter for notification doc reference. https://developer.android.com/reference/androidx/core/app/NotificationCompat.Builder#setPriority(int) It says here that notification priority is only still used on older versions of Android.

And an importance setter for notification channel. https://developer.android.com/reference/android/app/NotificationChannel#setImportance(int) Now it is a primary way to set a notification priority. All notifications using particular channel are going to have this channel’s importance level. (You can also see here that importance is scaled from 0 to 4/5. React-native-push-notification docs are not clear about possible values, it only says that 4 is default)

So there is a value of 5 that can represent channel importance. Tho it is marked as “unused” in the docs I tried to use it and… got the same result.

Scheduled notifications only work when time offset is really small e.g. <1min. Guess it’s just because system doesn’t shut down the app right away when you swipe it off recent apps screen. There is some delay.

And it seems confusing because apps with cloud notification services e.g. Firebase work flawlessly.

Finally to the interesting part I installed To Do app from Play Store. Turned on Airplane mode on my phone just to be sure there is no Firebase involved, and scheduled a task for 10 minutes from now. Exited app, closed it in recents. After a few minutes I checked this app out in the Settings. Button “Force stop” wasn’t active so I guess system took care of stopping the app after I closed it. And after 10 minutes, I got notification, just in time. So, think there is hope. There is defenitely a way to schedule a notification (or schedule a job to pop a notification) I’ll continue to research and let you know if I find anything.

5reactions
wmoneckecommented, Aug 5, 2020

Hi @wmonecke

Does that occure every time ? or only in some users ?

Hi! This is mainly happening with Android devices. I can’t be sure because 90% of my users are Android users.

Can someone share the logic that define the date ? If the date is set in the past, the notification will trigger instantly (like when the app is opened). This is actually the most relevant root cause since AlarmManager is still OK on Android 29.

This is not the issue. I actually had the issue that the notification fired right away if set on the same date but earlier than the current time. I set the date to the next day if the user schedules a day for the current day but for an earlier hour. Something like this:

if (notificationDate.isBefore(moment())) {
    notificationDate.add(1, 'days')
}

The current issue is different and has happened many times. You won’t receive the notification at the time you set them but once you open the app in the future you will receive ALL scheduled notifications at once.

So for example, if you schedule notifications for 6 pm, 7 pm, and 8 pm, then by 9 pm you won’t have received any notification. However, if you open the app at 9 pm you will get all 3.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Not getting Notification until open the a… - Apple Community
Make sure that the app supports notifications. · If you have notifications turned on for an app but you're not receiving alerts, the...
Read more >
How to Fix Notifications Not Showing up on Android - Lifewire
Restart your phone · Make sure you haven't disabled system notifications · Make sure you haven't turned off app notifications · Check your...
Read more >
How to Fix Android Delayed Notifications - Hongkiat
Go to Apps from the phone Settings and open up the respective app. Tap on"Clear Cache" button to flush the cache. You can...
Read more >
Android Notifications Not Showing Up? 10 Fixes You Can Try
1. Reboot Your Phone · 2. Review the App's Notification Settings · 3. Disable Software Battery Optimizations · 4. Check for Proprietary Power ......
Read more >
Control notifications on Android - Google Support
Depending what notifications you want, you can change settings for certain apps or for your whole phone. Notifications show when you swipe down...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found