Android Question How to customize icons, color and sounds on PUSH notifications?

omarruben

Active Member
Licensed User
Longtime User
based on the excellent tutorial:


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.
 

asales

Expert
Licensed User
Longtime User
to start on customizing the icons or colors o others features
Check this:
 
Upvote 1

omarruben

Active Member
Licensed User
Longtime User
Check this:
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)?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
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.
 
Upvote 0

asales

Expert
Licensed User
Longtime User
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.
 
Upvote 0

omarruben

Active Member
Licensed User
Longtime User
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.
 
Upvote 0
Top