Android notification channel maximum count - push-notification

I am new to implement Android notification channel in Oreo. What is the maximum number of notification channels for a single application. Can we create unlimited channels or it has some count?

As far as I know there is no limit on the number of channels an app can create. The only purpose of NotificationChannel is to give more control of notification behavior to the user. It is no way to reduce the number of notification per app.
You can read about Notification Channel in detail at Create and Display Notification on Android Oreo | With Example

There is a limit that is not documented on the number of channels you can have at the same time, but no limit on how many times you can create a channel, as long as you have deleted other channels.
The file PreferencesHelper.java contains a limit that is currently set to 50.000
https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/services/core/java/com/android/server/notification/PreferencesHelper.java
And this is being used to restrict the creation of more channels when it goes over that limit, throwing the exception "Limit exceed; cannot create more channels"
Unfortunately that value is not publicly accessible, so any limit check you might want to implement will have to be hardcoded by yourself. My suggestion is to set your own limit to a number that you think starts being unreasonable, and when that is reached you run a check on your notification channels to figure out what is going on, and fix it. For example, if your app will never need more than 5 channels to be created, then setting the limit to 6 would be a good way to start.

The commit https://github.com/aosp-mirror/platform_frameworks_base/commit/f528b337dd48b7e8071269e07e610bd4a3668c75 update the max notification channel to 5.000

Coming with Android Oreo, Notification Channels are something a developer uses to break down the notifications his or her app can give to us by type. The channels are decided by the people doing the developing, and the idea is to give us a way to separate out the notifications that are important to us from the ones that aren't, then decide how they will be shown. Some apps will have a lot of different channels. Some will have just a few and some will have only one.
In versions of Android before O, a developer used what was called a priority level to decide how to show you a notification. If they felt the notification was important, they could set it to peek (show a visual indication on your screen) or make a sound, or both. If they felt it wasn't it would just be placed in the tray for you to see the next time you went through them.
Now they break things out into channels and we get to decide how each type of notification is displayed. All notifications of the same type (for example, a reply on your Twitter feed) are placed into the same channel without any other types of notification grouped with them.
As a bonus, apps that allow us to use more than one account can have channels for each combined — your personal email and work email can follow the same rules and show you things the same way no matter which accounts received the notification.
You should read this:
https://developer.android.com/guide/topics/ui/notifiers/notifications.html#ManageChannels
Example:

Related

Is it possible to change contents dynamically which Alexa skill shows without any user actions?

I want to create a Photo Frame Skill for Echo Show.
I want to change photos triggered by external server (such as Firebase and so on).
Is it possible to change it dynamically without any user actions?
I saw Notification API and Proactive Events API.
But, These show notifications to user. I don't want to show anythings to user.
I want just trigger controlled from external server to change contents.
The answer depends a lot on the type of skill (for example if it is based on Alexa Conversations or not). But you can try exploring something along this line:
Keep the token of last rendered APL document
Send an APL ExecuteCommand directive from your skill server (https://developer.amazon.com/en-US/docs/alexa/alexa-presentation-language/apl-interface.html#executecommands-directive)
You can use one of the standard APL commands, depending upon your use case. One option is SetValue command (https://developer.amazon.com/en-US/docs/alexa/alexa-presentation-language/apl-standard-commands.html#setvalue-command) to modify the background image.
I want to create a Photo Frame Skill for Echo Show
Technically, a skill can last for a maximum of 5min30sec without any user interaction. Only if you provide a prompt that last for 4min then a reprompt that last for 90sec. It could be a blank audio. But Alexa is not suited for custom skills that stays live for a long time without user interactions.

Firebase & One Signal Push Notifications Guidance

I have been playing around with One Signal & Firebase Push Notification.
I am almost sure One Signal cannot help me and am starting to feel Firebase might also not be able to help me.
We have a web app that allows regular authors to post articles. It also allows users to comment on the article using Firebase synced realtime database.
I want to create functionality where users can get a push notification for article-specific comment treads. The room ID will be the article ID. If both allow push notification generally from our app and has commented on an article, they subscribe to this article comment tread solely. They can also click a button at this specific article comment thread and unsubscribe to this article comment thread if they want.
So we may have thousands of articles and hundreds of comments in each article, to put it lightly.
I quickly moved away from One Signal when I didn't feel like I could have a separate "Segment" for each article, I wasn't certain this is allowed? Thoughts there?
Throughout my exploration of Firebase I just came across this comment in their documentation in relation to groups (Which I was hoping could be my article room).
"The maximum number of members allowed for a notification key is 20" found here. A key is a group key from my understanding. This won't work because what if there are more than 20 users in a comment thread. I looked up the most popular commented threads ever to find numbers like 500. This means my system would have to be able to support large numbers of users per article tread.
Additionally One Signal Tags and Social activities look like could be investigated, but my general question is not specific, its more a wider general question. I am hoping someone with experience can give some guidance and good tips on best way to approach this problem. Are Push notification even allowed on such a scale I am wondering?
A scaling examples
1000 Articles with 100s of different users commenting on each article. A user may only receive a push notification on articles which he has commented in only.
(Assuming he has allowed push notification site-wide first and not blocked us or unsubscribed from the site entirely. Subscribing to the site doesn't automatically subscribe you to anything specific, just means you willing to be subscribed to something and have control which things easily)
Ok thanks for reading and looking forward to hearing from someone with this experience and share their experience.
Daniel Gadd # GaddBox
Maybe it's a bit late.
You have to use topics.
FCM topic messaging allows you to send a message to multiple devices that have opted in to a particular topic. You compose topic messages as needed, and FCM handles routing and delivering the message reliably to the right devices.
In your case, every Article is a topic.

Updating user properties in Firebase takes too long

I am using firebase for my mobile Android and iOS app and I want to send push notifications based on specific user properties that I set (push notifications topics don't work for my use case).
So now when I set a user property in via the app it takes forever for that change to be propagated. For example, I do have a property club which was set to a value x. I can successfully send push notifications to those users. Now when I change the value to club = y and this change will take forever to go through. Which means that all notifications sent to club = x will still be received on those devices.
To set user properties I use the firebase_analytics plugin for flutter as follows:
FirebaseAnalytics analytics = FirebaseAnalytics();
analytics.setUserProperty(name: 'club', value: 'some value')
Since I am using the user properties to set notification settings this delay is not acceptable. Does anyone know how to make this work with firebase? Or are there any guarantees at least after which amount of time these user properties get updated?
I don't want to use other services such as OneSignal etc. but stay in the firebase ecosystem completely if possible.
Per the Analytics doc
Note: Once the property is registered, it can take several hours for data collected with the property to be included in reports. When the new data is available, the user property can be used as a report filter or audience definition.
Which is what I assume is the cause for your delay.
Topics would be the way to go, but since as you mentioned it is not viable, you could set custom claims for the user and filter it that way as mentioned here but performance might not be great since you have to retrieve all your users first.
You could create a club collection in Firestore and for each clubName document have a toNotify subcollection containing the userIds as document name. In this context users would remove themselves from the previous clubName and create a new doc in the newClubName.
Keep in mind this has the potential of causing quite a lot of read operation depending on the frequency you send notifications and the size of the your userbase.

Google Cloud Messaging Notification vs Data

I was reading the GCM documentation about the difference between notification type and data type when you want to send a message to a mobile device.
They say that notification type is always collapsed but for me its not clear what it means exactly?
Does it mean that if i send two or more notification (before the user is able to open the previous one) only the last one will be visible?
Collapsible or Non-Collapsible
The push messages can be either collapsible or non-collapsible. “Collapsible” means that the most recent message overwrites any previous ones queued for sending. A typical example of collapsible messaging is a live game score. In case previous score updates haven’t reached their destination yet, the Android clients would only get the latest one. This happens however on a best effort basis: the order in which messages get sent in GCM is not guaranteed, so in some cases the “latest” message may not be actually the most recent one.
Notification: Set notification payload. May have optional data payload. Always collapsible.
Data: Set data payload only. Can be either collapsible or non-collapsible.

Activate/Desactivate notifications in an app having different notifications type

I was looking at different forums and tutorials but did not find anything that cover what I want to do. At the moment my notifications are working fine but I am trying to give the options to the user to receive them or not.
My server is sending 3 kind of different notification, they are all messages:
You have a new message
A new user just connected
A user is very close to you
I have an option menu where I am giving the user the option to choose which notifications he wants to receive. He can select the combination he wants.
The problem I have is I do not know how to allow the app to display say the message 1 and 2, but not the 3, if that was the user choice. So far the solution I have is either showing 1, 2 and 3) or showing nothing. I have nothing in the middle.
Did anyone came across this and how did you solved it?
PS: This is for apple push notifications
Thanks
Find a solution, just combine silent notification with local notification
1) receive the silent notification
2) do the treatment base on the notification
3) send a local notification (or not) to create the desired effect

Resources