Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

v6.1.0 - RuntimeException: Unable to instantiate service "RNPushNotificationListenerService" #1676

Closed
@DaniShalash

Description

@DaniShalash

Bug

After updating to version 6.1.0, when the app is killed or in the background, and a remote push notification is received, the app crashes with the following exception:

E AndroidRuntime: FATAL EXCEPTION: main
E AndroidRuntime: Process: <MY_APP_PACKAGE_ID_REMOVED_HERE>, PID: 31392
E AndroidRuntime: java.lang.RuntimeException: Unable to instantiate service com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.PackageManager android.content.Context.getPackageManager()' on a null object reference
E AndroidRuntime: 	at android.app.ActivityThread.handleCreateService(ActivityThread.java:3750)
E AndroidRuntime: 	at android.app.ActivityThread.access$1400(ActivityThread.java:237)
E AndroidRuntime: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:106)
E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:214)
E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:7078)
E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
E AndroidRuntime: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)
E AndroidRuntime: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.PackageManager android.content.Context.getPackageManager()' on a null object reference
E AndroidRuntime: 	at com.dieam.reactnativepushnotification.modules.RNPushNotificationConfig.<init>(RNPushNotificationConfig.java:23)
E AndroidRuntime: 	at com.dieam.reactnativepushnotification.modules.RNReceivedMessageHandler.<init>(RNReceivedMessageHandler.java:38)
E AndroidRuntime: 	at com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService.<init>(RNPushNotificationListenerService.java:26)
E AndroidRuntime: 	at java.lang.Class.newInstance(Native Method)
E AndroidRuntime: 	at android.app.AppComponentFactory.instantiateService(AppComponentFactory.java:103)
E AndroidRuntime: 	at androidx.core.app.CoreComponentFactory.instantiateService(CoreComponentFactory.java:75)
E AndroidRuntime: 	at android.app.ActivityThread.handleCreateService(ActivityThread.java:3745)
E AndroidRuntime: 	... 8 more

Environment info

 System:
    OS: macOS 10.15.4
    CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
    Memory: 41.49 MB / 8.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 14.6.0 - /usr/local/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.14.7 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.9.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 13.7, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
    Android SDK:
      API Levels: 21, 26, 28, 29
      Build Tools: 28.0.3, 29.0.1, 29.0.2, 29.0.3
      System Images: android-26 | Google Play Intel x86 Atom, android-28 | Google Play Intel x86 Atom, android-29 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 4.0 AI-193.6911.18.40.6626763
    Xcode: 11.7/11E801a - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_241 - /Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/bin/javac
    Python: 2.7.15 - /usr/local/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.13.1 => 16.13.1 
    react-native: 0.63.2 => 0.63.2 
  npmGlobalPackages:
    *react-native*: Not Found

Library version: x.x.x

Steps To Reproduce

  1. Create a react-native app, and install v6.1.0 of react-native-push-notification
  2. Follow the installation instructions.
  3. Send a a remote notification while the app is in background

Describe what you expected to happen:

Receiving the notification, and have it shown in notification center

Reproducible sample code

Reproducible on Example project

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions