While creating notification channels, I categorise them by assigning them to a group (NotificationChannel.setGroup).
Later, while displaying notification, I use Notification.Builder. Should the value given to setGroup method here be the same as the first to function properly?
Not necessarily. Even though they might be related in your business rules, channel groups and notification groups are used for different reasons.
As stated in https://developer.android.com/training/notify-user/channels:
If you'd like to further organize the appearance of your channels in the settings UI, you can create channel groups. This is a good idea when your app supports multiple user accounts (such as for work profiles), so you can create a notification channel group for each account. This way, users can easily identify and control multiple notification channels that have identical names.
So, if you set different channel groups they'll be displayed separately in App Info -> Notifications. I'd say you just need it if your app has multiple channels and you want to further organize them.
A notification group, the one you set in Notification.Builder.setGroup(), is used to group notifications in the notification tray. You can learn more about it at https://developer.android.com/training/notify-user/group.
Related
For notifications for Android/iOS is it possible to turn on and off different notifications for different things in one app?
For example, we send notifications to the user using OneSignal service.
The first one if the user has not visited the application for a long time and another notification when there is a promotion in the store. So we have two different notifications.
Is it possible for the user to be able to turn off one of these notifications (manually in the app settings) and the other to work, or we can only turn off notifications completely?
Yes, they're called Notification Channels in Android. For every notification, you set a notification channel it belongs to. That way, the user can enable/disable specific channels.
Since Android 8 notification channels required for notifications. My Question is each and every notification should have different notification channel Id or same channel Id?
Notification channels let you group related types of notifications together.
Why would you need that?
A user may only want to disable notifications for a specific type. Let's say in a Calendar App he may want to disable all notifications which are of type reminder. Instead of disabling all notifications, the user (if a channel for reminders exists) can now specifically say: Ok I only want to disable reminder notifications.
In short: It enables the user to filter notifications more granular.
Just provide a different notification channel for each different notification "type" (meaning: they do not relate to each other).
Ok very good question, I am sure, I am late to answer but today I came across same problem. Actually I am showing multiple notification and when I long press on it and click on turn off notifications for my app, I came to know that same channel is being added multiple times as shown below:
So as and when I show the notification, I was using unique channel id while showing the notification, so even though notification channel name is same but channel id is different & unique, it keeps adding new channel each time I show the notification, that is completely wrong. It unnecessary ads multiple channels, very hard to turn off notification and many more reason.
So, in short, while you show particular group's notification, please use same channel name and channel id. Notification of particular type is grouped under channel id, not the channel name technically. But user can see the channel name only when he wants to turn it off.
Hope this answer your query and it will also help to others who are facing same issue of duplicate or multiple channels being created on each notification.
This question is about Android Grouped Notifications.
According to the official documentation, it mentions:
Note: If your app sends four or more notifications and does not specify a group, the system automatically groups them together on Android 7.0 and higher.
The problem is I found that this group of notification is clickable.
In my testing, I received a total of 5 notifications, 4 of them have their own pendingIntents, one of them is just a foreground service notification which is un-clickable and not dimiss-able.
While their clicking behavior worked correctly when separated, when I click on a group of them, Android simply creates on top of my current activity stack, another entrance Activity.
I know that I can force separate them into different notifications without grouping them, by specifying a different group ID for each of them;
Is there a way to preserve the notification group feature, but making the group non-clickable?
Actually, when a user clicks a group of notifications, you must open the screen where these "notifications" will be seen. For example, you are developing a social network app. You receive 3 notifications about new messages. You can group all of them as a "New message" and when a user clicks this type of group notification you must open the screen of the chat list. And if you receive 2 notifications about new friend requests, you can group them as a "Friend request" and when a user clicks to this group you must open a friend request list where all requests are shown.
I have an app with different notification types it can receive (for example News and Podcast). Currently it has two simple switches where the user can enable and disable those different notification types. It works by just subscribing and unsubscribing from the corresponding Firebase Topic for the type. The clear advantage is that the device only receives the notification the user wants and does not have to filter them locally => battery and data efficient.
Problem is, I want to combine it with the new android O notification channels. Am I right to assume that the only way is to just subscribe to all topics in Firebase and have the user manually disable unwanted ones in the android settings?
Is there a better way that saves more battery life (by not receiving all notifications)?
The Notification Channel (a feature only needed for Android O -- presumably onwards) is (like) a parameter that you would (typically) use to sort/manage the notifications you build locally. --
Android O introduces notification channels to provide a unified system to help users manage notifications.
It doesn't necessarily disable receiving the notifications that you don't want to receive, but (AFAIK) notifications built without the Notification Channel won't show up/display in Android O (not received != not displayed). i.e. Your device may actually still be receiving the notifications, but just isn't displayed.
For Notifications sent through topics, so long as the corresponding registration token is subscribed, it is the expected behavior that the client would handle it accordingly.
With all that said, what you already have implemented (if I understand your post correctly -- subscribe and unsubscribe to topics based on a switch of some sort) is already the simplest as it could get.
If you want to totally disable notifications completely, you could call deleteInstanceId(). See my answers here and here for some additional info.
I have been reading many posts/articles/tutorials I can find about updating an active notification. I fear I may have a fundamental misunderstanding about how one may update an Android push notification.
So far: I can update an active notification based on its ID, and I haven't been able to get any results out of Builder.setGroup()
My problem: When I update an active (not dismissed) notification, I want to be able to get the text from the previous, active notification, parse and add the new notification text and update it.
I'm starting to think that this might not be possible without a local DB and that my approach to this problem is no good.
Is there a way to get the content of the last notification (or one with a specific ID)?
EDIT: It seems to me that many of the examples I have seen are grouping a number of notifications all at once rather than successively.
Example
This is an example of what I want to do. The scenario I'm imagining is like this:
The owner of the device gets a notification that he/she has a new message from 'Alex Faaborg'. (See image)
The notification is not dismissed by the device owner
Another notification regarding a new message from 'Jeff Chang' comes in
Get 'Alex Faarborg's' name from the first notification, and 'Jeff Chang' from the second
Parse the info and display a summary of their notifications rather than have multiple notifications build up
4 is what I'd like to do
OK, so I realized I could do what I need to do to combine notifications by keeping track of users' unread messages(or invites etc..) on the backend, then if there's more than one, it will send out a summary of the notifications rather than each individually. On the client, this will overwrite any previous, related notifications (kept track with a JSON field sent to GCM (and subsequently, the client) that represents the 'topic' of the notification)
For whatever reason, I thought I should handle the grouping/summarizing of notifications on the client. I think the API is the way to go.