Android Question NB6 - Double Notification

walterf25

Expert
Licensed User
Longtime User
Screenshot_20180418-230416_Samsung Experience Home.jpg
New
Hi All, i started using this class and it works great Thank you @Erel, however i'm having an issue where i receive two notifications when i send a notification, i'am using a service which builds the notification and displays it when ready, the problem is that if the app is active meaning opened, i only receive 1 notification and i see a number 1 badge on the app's icon, but if the app is closed i receive two notifications and i see a number 2 badge on the app's icon, i'm able to clear the notification that contains the message but the second notification stays and i can't seem to clear it or make it go away.

Here's my code.

B4X:
Sub BigText_Notification(title As String, message As String)
    Dim n As NB6
    n.Initialize("default", Application.LabelName, "HIGH").SmallIcon(icon)
    Dim cs As CSBuilder
    ''n.BigPictureStyle(icon.Resize(256dip, 256dip, True), icon, title, message)
    n.BigTextStyle(title, cs.Initialize.BackgroundColor(Colors.Green).Append("Message Summary").PopAll, message)
    Dim cur1 As Cursor
    cur1 = Common.SQL1.ExecQuery("SELECT * FROM registration")
    cur1.Position = 0
     
    'check if user is registered to a group, otherwise register to group by
    'getting groupregistered flag in notification message.
    Dim groupregistered As Int
    Try
    groupregistered = cur1.GetInt("groupregistered")
    If groupregistered <> 0 Then
    n.Build(title, "Read Content Below", "notification_alert", CustomMessages).Notify(1)
    Else
    n.Build(title, "Read Content Below", "notification_alert", Main).Notify(1)
    End If
    Catch
    n.Build(title, "Read Content Below", "notification_alert", Main).Notify(1)
    End Try
End Sub

What's interesting is that the first notification has the icon i assigned in my code and the second notification has a different icon, if you guys notice carefully the top notification has an icon which has the word Titans on the logo and the second notifications has the icon without the word Titans on it, i have both of these icons in my Obj/Res/Drawable folder but am only assigning one of them, i looked in my code and there is no other place where i'm calling for another notification.

Thanks All,
Walter
 
Last edited:

walterf25

Expert
Licensed User
Longtime User
Hi All, i did another test with Erel's example just to see if i get the same results and indeed i got the same results, same behavior i'am seeing on my top post.

Basically what I did was I created another service, when the app starts I schedule the new service start after closing the app.

In the service I basically call the HighPriority_Notification Sub.
B4X:
Sub HighPriority_Notification
    Dim n As NB6
    n.Initialize("default", Application.LabelName, "HIGH").SmallIcon(smiley)
    ''Dim cs As CSBuilder
    ''n.BigTextStyle("HELLO", cs.Initialize.BackgroundColor(Colors.Green).Append("Message Summary").PopAll, "My Message!!!!!")
    n.AutoCancel(True)
    n.Build("Important!!!", "Content", "tag", Me).Notify(1)
End Sub

As you guys can see in the picture there are two notifications, one contains the smiley icon which is assigned in the code and the second which is the persistent notification contains the B4A icon which is in the Objects/Res/Drawable folder.

2_notifications.jpg


Is this a normal behavior, i need to figure this out, i can't release this app until i fix this issue, otherwise users will be getting annoyed by the persistent notification and end up uninstalling the app.

Any advice is welcome guys.

Thanks,
Walter
 
Upvote 0

walterf25

Expert
Licensed User
Longtime User
Upvote 0

Francisco Picado

Member
Licensed User
Longtime User
Hello Walter,

Searching in the Forum about the Notification Got to your Post and I wanted to consult you regarding the counting of the Notifications in the icon, it happens that I am implementing the Notifications in my application whith FireBase, but I have doubts about whether that feature should be implemented separately (I see that in the forum there are several codes that do that and even put the desired Number ) , or if when you receive the notification through FireBase the count in the icon is Automatic , i know that you implemented the notification with NB6 Class and could be a little bit different, but I have an S6, working with the B4A 8.3 and I have implemented the FireBase Notifications but when I receive the Notifications, at least in my case it is not Automatic, and got stuck tried to get the icon Counter. Thanks for any Comments or Help.

Regards,
Francisco
 
Upvote 0
Top