Yesterday I notice that devices that are using an Android version greater than 8.0 were not receiving push notifications. When I was debugging it, I notice that it's caused by the null value returned by this.config.getChannelName() on the RNPushNotificationHelper.java file.
A workaround that I found was to make a ternary there in order to set a default value to it if it returns null.
NotificationChannel channel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, this.config.getChannelName() != null ? this.config.getChannelName() : "rn-push-notification-channel", importance);
It's working but I know that it's not the best solution for it. Can we improve it? Is there any drawback related to this workaround?
The fork that I'm using with the workaround: https://github.com/rafaelcamaram/react-native-push-notification
Cheers
+1
One thing that I forgot to mention is that this ChannelName is required starting in Android 8.0 (API level 26); so all notification must be assigned to a channel.
But there is no specific name we must put there, you can give the name you want to your channel; it's used only to group all the notifications of the same app - or type - in order to set some properties on it. So, since we're not setting properties on it, I believe that the workaround that I suggested above won't cause any problems to your app until the repository maintainers fix this problem
Did you make a PR for this @rafaelcamaram ?
Just tried this now and it works for me! Thanks @rafaelcamaram!
Is there a special way we should put this code in our projects until a solid fix comes out? I have just edited the node module directly for now.
@JonesN3 Not yet. I would like to see what the project maintainers have to say about it before making a PR.
@sonicsmith You can use the fork that I've created or do the same as I did and fork the project, change it and use as a dependency on the package.json
"react-native-push-notification": "git+https://github.com/rafaelcamaram/react-native-push-notification.git#ceda7e9"
Thanks, this saved my life. I suggest you to create a PR, I guess it will be reviewed?
Thanks, this saved my life. I suggest you to create a PR, I guess it will be reviewed?
@ebaynaud I'm happy to contribute somehow :)
I just opened a PR: Pull Request
Heya, I was having issues again, and pulled the newest version of this project. Wasn't working unitl I looked into the readme! There's new info about channels that needs to go in the manifest now. Works for me now!
Heya, I was having issues again, and pulled the newest version of this project. Wasn't working unitl I looked into the readme! There's new info about channels that needs to go in the manifest now. Works for me now!
Hello, what kind of changes have you made can you share, I am trying to upgrade mine but the app keeps crashing on start?
@sonicsmith, could you please clarify?
@rafaelcamaram What stops you from updating the manifest file?
<meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_name"
android:value="YOUR NOTIFICATION CHANNEL NAME"/>
<meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_description"
android:value="YOUR NOTIFICATION CHANNEL DESCRIPTION"/>
can you give some sample codes for this
Most helpful comment
@ebaynaud I'm happy to contribute somehow :)
I just opened a PR: Pull Request