-
Notifications
You must be signed in to change notification settings - Fork 767
Channels #535
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
Channels #535
Conversation
needed so much! |
Need this a lot! Will it be aproved? |
Thanks for update! Is there a possibility to create multiple channels if executing |
I did not test this, but I'm very sure it should work. Just make sure to use a different There is more information in the google's documentation and I think the most important part is that some settings of the channels cannot be updated after they are created (vibration, lights, etc):
I think that if you set up a channel wrong in production (wrong lights or vibration pattern), your only solution would be to create a new one with the correct settings and use the new one. |
would you please review and merge this? |
...d/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java
Show resolved
Hide resolved
* creating channels works * check if app is visible when showing notification * changed protected method to private * fixes imports in typescript * fixes push notifications tests * rerun tests - mac slave went offline
This reverts commit 6a8161b.
@alexbuicescu Thanks for adding android Channels support to this library. I have a problem in my typescript based project, it seems the new types and the method |
Thanks a lot for this job. Documentation should be updated too. |
@alexbuicescu it's a bit strange, but after this PR has been merged remote notifications never come. |
@anisimov74 do you have more details?
I just tried with the latest version (3.1.4-snapshot.114) and works fine for me, I'm using this to send the notification with a POST to {
"to": "<your_fcm_token_here>",
"priority": "normal",
"notification": {
"title": "Title",
"body": "You have received a new notification yayyy :) :) :)"
}
} If the notification does not come in while app is closed, there may be something else wrong (maybe your firebase token has changed, as it is usually the case). Any notification should come (appear in the notifications drawer) while the app is closed because it is managed by the system, not by the app. The only time when it won't appear is if it is a silent/data notification. Can you test on a fresh install to be sure that the firebase token is up to date? |
Hi, I thought it is supposed to work automatically. import {Notification, Notifications} from 'react-native-notifications';
Notifications.setNotificationChannel({...}) If there is another file that I need to update can you please give me a link? |
So weird, I'm using same version of typescript and the same syntax you are mentioned above but I got on the method usage. Maybe I need to clean my previous caches to make it work. I'll try that again and report it here. |
@alexbuicescu sorry for not responding to your question about not receiving notifications. |
@anisimov74 I know about that, but for me the problem was that the notification in the drawer would be blank (no title, no body, no icon, just a white, empty notification). One suggestion would be to make this configurable (for those like me, who do not want to display the notification if the app is in foreground). Another suggestion, and a fast fix for you, is to create a local notification when the app is in foreground, because you receive all the notification data on the js side (notification title, body, etc) I'm not entirely sure though how to store settings in the native app, so we can read them when a notification is received and choose whether to show it or not. Is there already something similar implemented in react-native-notifications? |
@alexbuicescu using a local notification sounds reasonable. Will try. Thanks! |
How do I send a local notification with a specific channel id? |
@danieloprado I don't know, I've never used local notifications |
the best way to use this library for creating local notifications on Android is using this tutorial, you can send all information you need to the Android side and do what you want like submit new channel and assign it to a channel group and etc.) |
This is great thanks! I can definitely see my notification channel being created, one thing I'm not clear about, when calling
Where the variable |
Hi, I don't know how you can set the channel for the local notification (maybe somebody else knows how). But I can certainly tell you that |
Thanks have opened #631 to track this! |
I appreciate the effort you put into this PR, but I see few problems this PR introduced and would like to give some advice to library maintainers.
This is not a bug, this is how the library has been working for the last 3 years. Now that you have made this change, it's breaking the existing functionality of all the apps and there is no option to configure it how we can in iOS. This change is not listed in the change log. why? Breaking functionality should have been released in major release not minor version. If there was a bug in foreground notification then we must have first fixed the bug, before deciding on this huge functionality change. Lastly there is no documentation update for all these changes, how will the users know the feature exist? If the maintainers feel they don't have enough time I request them to kindly add me to the collaborator list, until I use this library I will see to that library is well maintained. Not like issues and PR's are closed due to being stale. |
#535 started implementing custom channel and channels group creation but there were some missing parts that this PR finishes: - Using the incoming channel in `PostNotification` after creating it - Add channel group name and add this group to the custom channel - Show it in the example app This PR also fixes very old tests Closes #723 Co-authored-by: Yogev Ben David <[email protected]>
This PR brings the ability to create custom notification channels from javascript. This is how to use it:
I've also fixed a bug (I think it is a bug?) where the notification would be shown in the drawer if it is received while the app is opened (the changes in
src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java
). I think this is a bug, because with the react-native-firebase v5 I've never had this behaviour. Also the notification was displayed wrong (the title and body were missing).This may be related to #488 and #80
This should be the API call to FCM to send a notification (I think this is the legacy API version, you can use this one as a reference if you use the new API version):
POST
There are 4 ways to use this PR in case you want to test it or actually use it:
npm run build
npm run build
lib/dist/
from .gitignore