Skip to content
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

Channel name updated when sending local notification #1649

Closed
piotrponikowski opened this issue Sep 16, 2020 · 10 comments
Closed

Channel name updated when sending local notification #1649

piotrponikowski opened this issue Sep 16, 2020 · 10 comments

Comments

@piotrponikowski
Copy link

I have created custom channel:

    PushNotification.createChannel(
      {
        channelId: 'myid',
        channelName: 'Channel Name',
        channelDescription: 'Channel Description',
      },
      created => console.log(create)
    );

and then somewhere in my code I created new local notification:

    PushNotification.localNotification({
      title: 'Title',
      message: 'Message',
      channelId: 'myid',
    });

After this my channel name has been updated back to default value: 'rn-push-notification-channel'

Looks like this is caused by this check:
https://github.com/zo0r/react-native-push-notification/blob/master/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationHelper.java#L946
Is it intentional behavior?

Based on source code I was able to find workaround by providing channelName and channelDescription when sending notification, however these attributes are not documented.

    PushNotification.localNotification({
      title: 'Title',
      message: 'Message',
      channelId: 'myid',
      channelName: 'Channel Name',
      channelDescription: 'Channel Description',
    });
@Dallas62
Copy link
Collaborator

Hi @piotrponikowski
This is not the expected behaviour, I will look into it.
Regards,

@andkom
Copy link

andkom commented Sep 16, 2020

I have same issue

@CaptBoscho
Copy link

Happening to me, and it triggers 2 notifications with the RNPushNotification.presentLocalNotification

@Dallas62
Copy link
Collaborator

Hi,
I didn't made update on this issue, but I recommend you to keep creating channels by yourself (like you mentioned):

    PushNotification.createChannel(
      {
        channelId: 'myid',
        channelName: 'Channel Name',
        channelDescription: 'Channel Description',
      },
      created => console.log(create)
    );

In order to simplify the library and also avoid some complex edges cases, the following behaviour will be removed:

  • Auto creation of channels

This means the creation of the channel must be made before you trigger a notification. And this will solve this issue.

@Dallas62
Copy link
Collaborator

You can test changes on dev branch.

Please refer to the CHANGELOG for update instructions:
https://github.com/zo0r/react-native-push-notification/blob/dev/CHANGELOG.md#unreleased

To install this version:

npm install zo0r/react-native-push-notification#dev

OR

yarn add zo0r/react-native-push-notification#dev

Make sure your build cache is cleaned.

@piotrponikowski
Copy link
Author

I tested with dev branch and it works correctly for me - channel name is not overwritten to default name anymore.

Thank you for help!

@Dallas62
Copy link
Collaborator

Thanks for your feedback !

@CaptBoscho
Copy link

It works great for me as well- do you know when you'll be releasing ths update?

@Dallas62
Copy link
Collaborator

Dallas62 commented Sep 23, 2020

I will do it at this Friday, don't have enough time this week in case of issues.

@Dallas62
Copy link
Collaborator

Just released 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants