Android Question About FCM


Hello everybody,
I'm studying Firebase Cloud Message and would like to know if there is a way to implement the following:
I have a project that will have two applications:
An application, which I will call administrator, will be responsible for sending a message to certain groups. It can be one or several groups.
The other application will only receive the messages. I'll call him the receiver. The application that will receive the message can receive messages from one or more administrator applications.
The way groups will be identified is similar to WhatsApp groups. So when the administrator sends the message, all members of a certain group must receive the sent message.
The admin application and the receiver have different package names. They actually differ by one letter.
The administrator application has more added functions than the receiver. The administrator will be paid, while the receiver will be free, however, with advertising ads.
Is there a way to implement FCM following this design logic?
If so, what do I need to study to implement it?
I read some articles, but I confess that I didn't understand the logic behind the process of how one application can send the message and the other receive it.

I thank you for your attention.


I have a VPS already installed and even with the application database already under test. When you comment on the installed server, would it be B4J-SendingTool or a PHP application?
Sorry for my ignorance, but it's been many years since I've worked with WEB applications and everything in this area is new to me now.
Upvote 0


Licensed User
Longtime User
Any server technology can be.
1) Your apps can get FCM message about the fact that a new message for it is ready to download (message from server's DB).
2) The server database should store the FCM ID of each Android-device, and be able to send push-messages via FCM API.
3) So, DB should have tables for users (android devices), user groups, messages.
4) And server script (or app) for: admin page for message preparing, FCM API sending, URL for getting the message by clients.
Upvote 0


Thank you for your attention and explanation. Not wanting to abuse your goodwill, any codes for study?
I read in an article that individual identifiers could be used, I don't know if this is correct, instead of those provided by the FCM. In my case, I could use the customers' phone number as this ID, because one of the business rules is that the customer enters their phone number in the application (I don't intend to do an automatic search, because I've read elsewhere that the Google has already created restrictions for this method).
And of course the number will be encrypted. But, it is an identifier.
If this is possible, I believe that my search, now, is how to send the push message to the client via FCM, using this identifier as a parameter.
Upvote 0


Licensed User
Longtime User
Some my old code of FirebaseMessaging service, now it should be the receiver B4A module.

FirebaseMessaging receiver module:
#Region  Service Attributes
    #StartAtBoot: True
#End Region

Sub Process_Globals
    Dim fm As FirebaseMessaging
    Dim Token As String
    Dim n As Notification
    Dim tim As Timer
End Sub

Sub Service_Create
    Token = StateManager.getSetting("fbtoken")
End Sub

Public Sub SubscribeToTopics
    fm.SubscribeToTopic("general") 'you can subscribe to more topics
End Sub

Sub Service_Start (StartingIntent As Intent)
    If fm.IsInitialized Then
        fm = Null
    End If
    tim.Initialize("tim", 2000)
    tim.Enabled = True    'pause for getting the token
    Log("FB.tim.Enabled = True")
    If StartingIntent.IsInitialized And fm.HandleIntent(StartingIntent) Then Return
End Sub

Sub fm_MessageArrived (Message As RemoteMessage)
    Log("Message arrived")
    Log($"Message data: ${Message.GetData}"$)
    Dim title As String = Message.GetData.Get("title")
    Dim body As String = Message.GetData.Get("body")

    If title.ToLowerCase = "null" Then
        title = Application.LabelName
    End If
    If body.ToLowerCase = "null" Then
        body = others.r("push_message")
    End If

Log(Message.GetData)    '(MyMap) {priority=high, vibration=1, body=Body text, icon=, sound=default, title=Title text, requestId=2033}
Dim requestId As String = Message.GetData.Get("requestId")

    chat.CurOrderID = requestId
    chat.push = True
    If IsPaused(chat) Then
        CallSub(chat, "Activity_Resume")
    End If

    n.Icon = "icon"
    n.SetInfo(title, body, Main)
    n.AutoCancel = True

End Sub

Sub Service_Destroy
End Sub

Sub fm_TokenRefresh
End Sub

Sub tim_Tick
    If Starter.InternetConnected = False Then
        'Log("FB.timer: no Internet")
    End If
    Dim a As String = fm.Token
    Log("fm.Token=" & a)
    If a.Length > 5 Then
        tim.Enabled = False
        If a <> Token Then    'send new token to server
            Log("In Refresh " & $"Token(${fm.Token})"$)
        Else    'old existing token
            Log("In Service_Create " & $"Token(${fm.Token})"$)
        End If
        Token = a
        Dim userId As String = StateManager.GetSetting("userId")
        If userId <> "" Then    'if already registered user
        End If
        StateManager.SetSetting("fbtoken", Token)
        Log("FB token is empty!")
        tim.Enabled = True
    End If
End Sub

StateManager - search the forum.
Send_token - make yourself for your server (mine was HTTPjob to POSTrequest)
Upvote 0


First, I would like to thank everyone for their attention, and I would like some more information, if possible: to use the FCMPush server provided by Erel on my VPS, should I configure it as JRDC?
If so, what would the request be like, on Android, to send a message.
In jRDC there is the DBRequestManager that takes care of requests. What would it be like with FCMPush?
Upvote 0