Android Question How to get permanent notifications so that the user must read them

sergio Rassino

Member
Licensed User
Hello. I've just purcached the B4a licence and I had success with this proyect:
https://www.b4x.com/android/forum/threads/simple-push-framework.35635/

and with this one, but only in your database, not in my mysql VPS.
https://www.b4x.com/android/forum/threads/19226/#content

With both of them, i get my message in the bottom of the screen, and it is show for some seconds and then it desapear. I need the message to be persistent, until the user read it and make it desapear by his own. (like an email or whatsap notification)

Would you be so kind to show me some way to do it?

Thanks a lot

Sergio
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
When a push message is received the following sub is executed:
B4X:
Sub MessageArrived (Intent As Intent)
   Dim From, CollapseKey, Data As String 'ignore
   If Intent.HasExtra("from") Then From = Intent.GetExtra("from")
   If Intent.HasExtra("data") Then Data = Intent.GetExtra("data")
   If Intent.HasExtra("collapse_key") Then CollapseKey = Intent.GetExtra("collapse_key")
   Log(Intent.ExtrasToString)
   'Here you should handle the new message:
   Log("New message arrived: " & Data)
   ToastMessageShow("New message: " & Data, True)
   Dim n As Notification
   n.Initialize
   n.Icon = "icon"
   n.Sound = True
   n.SetInfo(Data, Data, Main)
   n.Notify(1)
End Sub

This code will create a regular notification. It will show for a few seconds and will then be listed in the notifications list until the user dismisses it.
 
Upvote 0
Top