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

Discussion in 'Additional libraries, classes and official updates' started by Erel, Jun 9, 2016.

Thread Status:
Not open for further replies.
  1. DonManfred

    DonManfred Expert Licensed User

    Create a NEW thread in the B4J Questionsforum for this.
    The problem seems to be in your code. Upload your project and let us check it...
    jayel likes this.
  2. Noorul HAQUE

    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
    End If
    n.Icon = "icon"
    n.SetInfo(Message.GetData.Get("title"), Message.GetData.Get("body") , Main)
    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.
  3. Erel

    Erel Administrator Staff Member Licensed User

    Please start a new thread for this question and make sure to use [ code ] tags (without spaces).
  4. mariobam

    mariobam Member Licensed User

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

    Erel Administrator Staff Member Licensed User

    Please start a new thread for this question.
  6. ilan

    ilan Expert Licensed User

    is the b4j push server also good for b4i firebase notifications?
  7. Erel

    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).
  8. ilan

    ilan Expert Licensed User

  9. Erel

    Erel Administrator Staff Member Licensed User

  10. ilan

    ilan Expert Licensed User

    thank you very much for this tutorial now it works :) (without it i would never be able to set up the push notifications)

    i would like to understand 1 thing: I recommend using a Production SSL Certificate with a Distribution / Ad Hoc provision profile

    with ad Hoc provisions file i can also upload my app to the store and also test it during development?
  11. Erel

    Erel Administrator Staff Member Licensed User

    You should start a new thread for this question in B4i questions forum.
  12. Alpandino

    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.

  13. ilan

    ilan Expert Licensed User

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

  14. Alpandino

    Alpandino Member Licensed User

    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?
  15. ilan

    ilan Expert Licensed User

    Are the sent msg's always the same?
  16. Alpandino

    Alpandino Member Licensed User

    No, every message is different, each user can send a different message
  17. ilan

    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....
  18. Alpandino

    Alpandino Member Licensed User

    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.
  19. VTSinLincoln

    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?

  20. freedom2000

    freedom2000 Well-Known Member Licensed User

    Hi I have done a similar App see here, and for the moment I have quasi real time notifications.
    Last edited: Aug 21, 2016
Thread Status:
Not open for further replies.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice