B4A Library FirebaseNotifications - Push messages / Firebase Cloud Messaging (FCM)

Status
Not open for further replies.

Noorul HAQUE

Member
Licensed User
Dear Team,

I facing two problems with Firebase Notification,

1st Problem

Firebase notification is only happening if my application is in background working mode, ie, If I am in my App, I am not receiving any notification.

2nd Problem

I have defined newMessage as global variable

Sub Process_Globals
Dim newMessage As Boolean
newMessage = false


and in FireBaseMessaging I have code as below where I have set newMessage as True


Sub fm_MessageArrived (Message As RemoteMessage)
Dim n As Notification
If Message.GetData == Null Or Message.GetData.Get("title") == Null Then
Return
End If
n.Initialize
n.Icon = "icon"
n.SetInfo(Message.GetData.Get("title"), Message.GetData.Get("body") , Main)
Main.newMessage=True
n.Notify(1)
End Sub

Now my problem if I access this variable from Main Module, its value still false even after notification message. My requirement is to set this variable true if any notification arrives, I also tried to save this value in a text file upon receiving notification that also not working.

Please support me on this, thanks in advance.
 

Erel

Administrator
Staff member
Licensed User
Please start a new thread for this question and make sure to use [ code ] tags (without spaces).
 

mariobam

Member
Licensed User
I can not create bigtextstyle notifications from firebasemessagingservice, fm_MessageArrived, (when my app this closed) .. what do I do?
 

Erel

Administrator
Staff member
Licensed User
No server is needed for Firebase notifications. You can use the B4J code to send the requests (take it from the B4i tutorial).
 

ilan

Expert
Licensed User

Erel

Administrator
Staff member
Licensed User
You should start a new thread for this question in B4i questions forum.
 

Alpandino

Member
Licensed User
Hi Erel,

I did all the steps in this tutorial and everything works fine.
However, I noticed that the device that sends the message also receive the message just sent. Is it possible to avoid this? I don't need to receive a message that I have sent.

Thanks
 

ilan

Expert
Licensed User
Hi Erel,

I did all the steps in this tutorial and everything works fine.
However, I noticed that the device that sends the message also receive the message just sent. Is it possible to avoid this? I don't need to receive a message that I have sent.

Thanks
Just dont subscribe to the topic with that device.and it should not recive that notification..

B4X:
fm.SubscribeToTopic("general")
 

Alpandino

Member
Licensed User
Just dont subscribe to the topic with that device.and it should not recive that notification..

B4X:
fm.SubscribeToTopic("general")
I need to subscribe my device to this topic, because I want to receive messages from other users of this topic, but I don't want to receive messages sent from my device. In this case I think that I may find a workaround, for example: I could insert in every message a "sender" ID, so if sender == mysender_ID then ignore this message.
It's a waste of time processing and of network traffic, but it seem that is not possible to find other solutions.

Anybody have some ideas?
 

ilan

Expert
Licensed User
You can create a txt file with the msg u sent and when u receive a msg u check if such a file exists that contains the same text. If true dont show notification.

Thhis should be simpler to implement then create user and handle a db where all users are listed to avoid give two users the same user id....
 

Alpandino

Member
Licensed User
You can create a txt file with the msg u sent and when u receive a msg u check if such a file exists that contains the same text. If true dont show notification.

Thhis should be simpler to implement then create user and handle a db where all users are listed to avoid give two users the same user id....
I must not work with ID users stored in a DB Table, because I'm using the UID provided by Firebase Authentication, so I'm sure this UID is really unique.

Anyway, thank you for the smart suggestion, it can be useful in other situations.
However it seems really strange that Firebase don't give the possibility to avoid the delivery of the message at sender.
 

VTSinLincoln

Member
Licensed User
I'm using FCM notification in an alarm notification app. One of the things I'm noticing though is a very inconsistent delivery time - anything from a few seconds to over 10 minutes.

I've set the messages to be delivered high priority (see https://firebase.google.com/docs/cloud-messaging/concept-options#setting-the-priority-of-a-message) which seems to help. Is there anything else I can do to ensure the notifications turn up in a more timely fashion? Any suggestions where to start looking for delays - the API end (I always get a valid ID from the FCM API when I send messages to it) or the device end?

Vaughan
 
Status
Not open for further replies.
Top