-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Null pointer exception when trying to create channel #1734
Comments
It solved for me
|
I encountered the same issue as @iamjon. In my case, this is because other push notification library may set empty channel description as null. When I migrated to this library and created the same channel again, the code crashed at channel.getDescription().equals(channel_description) due to channel.getDescription() is null. |
Hi @iamjon, Thanks for the report, sorry for the delay, got an issue with my mail provider... Regards |
Hello, guys! java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference |
I think i found a solution, added all the default values for channels in manifest and now it's ok |
This issue should be fixed in 6.1.3, Regards, |
Bug
Hello,
While trying to create a channel the module crashed.
2020-11-05 17:30:36.355 17176-17269/com.priority_software.template E/unknown:ReactNative: Exception in native call java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference at com.dieam.reactnativepushnotification.modules.RNPushNotificationHelper.checkOrCreateChannel(RNPushNotificationHelper.java:870) at com.dieam.reactnativepushnotification.modules.RNPushNotificationHelper.createChannel(RNPushNotificationHelper.java:917) at com.dieam.reactnativepushnotification.modules.RNPushNotification.createChannel(RNPushNotification.java:306) at java.lang.reflect.Method.invoke(Native Method) at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372) at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:151) at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27) at android.os.Looper.loop(Looper.java:224) at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:226) at java.lang.Thread.run(Thread.java:919)
The crash is coming from this bit of code
if ( channel == null && channel_name != null && channel_description != null || channel != null && ( channel_name != null && !channel.getName().equals(channel_name) || channel_description != null && !channel.getDescription().equals(channel_description) ) )
I locally changed the condition to this, which fixed the bug:
`
if (
(channel == null && channel_name != null && channel_description != null) ||
(channel != null && channel.getName() == null || channel.getDescription() == null) ||
(channel != null &&
(
channel_name != null && !channel.getName().equals(channel_name) ||
channel_description != null && !channel.getDescription().equals(channel_description)
)
)
)
`
If you think this is a good fix, I can make a pr
In my case, for some reason channel description was null, name wasn't.
Environment info
AndroidManifest.xml:
`
react-native info
output:System:
OS: Linux 5.4 Ubuntu 20.04.1 LTS (Focal Fossa)
CPU: (4) x64 Intel(R) Core(TM) i7-4510U CPU @ 2.00GHz
Memory: 302.14 MB / 15.57 GB
Shell: 5.0.17 - /bin/bash
Binaries:
Node: 12.18.2 - ~/.nvm/versions/node/v12.18.2/bin/node
Yarn: 1.22.5 - /usr/bin/yarn
npm: 6.14.5 - ~/.nvm/versions/node/v12.18.2/bin/npm
Watchman: Not Found
SDKs:
Android SDK:
API Levels: 28, 29, 30
Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.0, 30.0.1
System Images: android-28 | Intel x86 Atom_64, android-30 | Google APIs Intel x86 Atom, android-30 | Google Play Intel x86 Atom
Android NDK: Not Found
IDEs:
Android Studio: Not Found
Languages:
Java: 14.0.1 - /usr/bin/javac
Python: Not Found
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: "react-native-push-notification": "^6.1.2",
Steps To Reproduce
Install the module on android. When starting the app call
PushNotification.createChannel({ channelId: NotificationsChannel, channelName: 'My Channel', importance: 5, });
Describe what you expected to happen:
Channel would be created
The text was updated successfully, but these errors were encountered: