Google has deprecated the previous method of sending push notifications. It will stop working on June 2024. If you have an already working solution then you only need to update the B4J side. Do make sure that you switched from the service to a receiver on B4A. The new API is (confusingly) named...
www.b4x.com
I have everything working, but I don't have any idea where to start on customizing the icons or colors o others features, can anyone direct me please. Thank you.
Background The notifications features changed a lot as Android evolved. Android 8 (with targetSdkVersion 26+) adds another complexity with the introduction of notification channels. The built-in Notification object was rewritten in B4A v8 to work properly with all versions. This is a good...
Background The notifications features changed a lot as Android evolved. Android 8 (with targetSdkVersion 26+) adds another complexity with the introduction of notification channels. The built-in Notification object was rewritten in B4A v8 to work properly with all versions. This is a good...
NB6 is awesome,on the samples of NB6 the notification appears when the user click on the list,
but how to link it to the Firebase Message (when it arrives)?
See the code in the example. Add them whereever you need them.
Also note the todo on the NBuilder-Thread
Steps to create a notification:
- Initialize a NB6 object. You need to pass a ChannelId, Channel Name and Importance Level values.
Starting from Android 8+ some of the features are set in the notification channel and not in each notification separately. Once a notification channel is created, it cannot be modified.
If you want to make changes then you need to change the id or uninstall the app (reinstalling is not enough).
NB6 internally adds the importance level string to the channel id. So in most cases you can use the same value for all notifications.
The importance levels are: MIN, LOW, DEFAULT and HIGH.
LOW+ is required for foreground service notifications.
DEFAULT and HIGH enable sounds.
HIGH enables the headup notifications.
- Set the properties. You must set SmallIcon.
- Call Build. The last parameter is the activity that will be started when the user clicks on the notification.
Build returns a notification object.
- Call Notification.Notify to show the notification.
NB6 is awesome,on the samples of NB6 the notification appears when the user click on the list,
but how to link it to the Firebase Message (when it arrives)?
Is different things.
You will send the message from Firebase and get the message in the FirebaseMessaging receiver.
When the message is arrived, you can show a NB6 notification.
Check the push client example, change the "Dim n2 As Notification" to "Dim n2 As NB6" and made the necessary modifications.
just for future fast reference ... change inside the FireBaseMessaging module from the sample:
B4X:
'Dim n2 As Notification
'n2.Initialize2(n2.IMPORTANCE_HIGH)
'n2.Icon = "icon"
'n2.SetInfo(Message.GetData.Get("title"), Message.GetData.Get("body"), Main)
'n2.Notify(1)
Dim n As NB6
n.Initialize("default", Application.LabelName, "DEFAULT").AutoCancel(True).SmallIcon(iconKantutaTV)
n.Build(Message.GetData.Get("title"), Message.GetData.Get("body"), "tag1", Main).Notify(4) 'It will be Main (or any other activity) instead of Me if called from a service.