Hi all,
I've just implemented the Firebase Push Notification whith a great help from Erel and DonManfred !
Now, my purpose is to filter notifications by "User", but not on Firebase side, but on apk side.
I explain:
My apk runs with a central SQL database.
All users are known, in this database, by a unique UserId
When apk is running, I know everytime which user is logged with a global variable.
But global variable are not reachable everywhere (and I think not by the fm service).
So my idea was to do something in 3 steps:
- on the first apk login, I store this UserId in a txt file
- when sending the push notification, I add in the body a tag to identify the user:
"$ALL$" for all users
"$USER$" + UserId for one specifique user
- on firebase_MessageArrived Sub, I read the txt file to know if user is involved or not.
Unfortunately, I think some part of my code are not compatible with a service ....
Result is apk crashes directly.
So, according with my code below, do you think something is possible ?
All good ideas are welcome !
I've just implemented the Firebase Push Notification whith a great help from Erel and DonManfred !
Now, my purpose is to filter notifications by "User", but not on Firebase side, but on apk side.
I explain:
My apk runs with a central SQL database.
All users are known, in this database, by a unique UserId
When apk is running, I know everytime which user is logged with a global variable.
But global variable are not reachable everywhere (and I think not by the fm service).
So my idea was to do something in 3 steps:
- on the first apk login, I store this UserId in a txt file
- when sending the push notification, I add in the body a tag to identify the user:
"$ALL$" for all users
"$USER$" + UserId for one specifique user
- on firebase_MessageArrived Sub, I read the txt file to know if user is involved or not.
Unfortunately, I think some part of my code are not compatible with a service ....
Result is apk crashes directly.
So, according with my code below, do you think something is possible ?
B4X:
Sub fm_MessageArrived (Message As RemoteMessage)
Dim Title As String = Message.GetData.Get("title")
Dim Body As String = Message.GetData.Get("body")
Dim User As String = ""
If File.Exists(File.DirInternal, "user.txt") = True Then
User = File.ReadString(File.DirInternal, "user.txt")
If Body.Contains("$ALL$") Then
Body.Replace("$ALL$","")
Dim n As Notification
n.Initialize
n.Icon = "icon"
n.SetInfo(Title, Body, "")
n.Notify(1)
Else
If Body.Contains("$USER$" + User) Then
Body.Replace("$USER$" + User,"")
Dim n As Notification
n.Initialize
n.Icon = "icon"
n.SetInfo(Title, Body, "")
n.Notify(1)
End If
End If
End If
End Sub
All good ideas are welcome !