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. ricardotm1968

    ricardotm1968 Member Licensed User

    Hi Erel,
    i'm starting to develop a new app, i use appcompat library (ver 2.0) , when i try to chenge my GCM to FCM, in the compile send me this error ,

    Error.png

    if i inactivate the library everthig is fine, is not posible to use both library at the same time?

    thanks in advance
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    The server key is not stored inside the app. It is a different key.
     
    pesquera likes this.
  3. Erel

    Erel Administrator Staff Member Licensed User

    Yes, please start a new thread for this in the questions forum.
     
  4. Bel

    Bel Active Member Licensed User

    Hi
    In this push we dont need to google play service looklike gcm?
    In gcm or c2dm if device rooted so push not send
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    The requirements are the same as FCM is based on GCM.
     
  6. coslad

    coslad Well-Known Member Licensed User

    When i load the Firebase Notification library ,it comes out this error :
    "Maven artifact not found"
    what does it mean ?
     

    Attached Files:

  7. VTSinLincoln

    VTSinLincoln Member Licensed User

    How do I get topic subscription to work on device start-up?

    I've set the starter service to start at boot and installed the app then rebooted the device. I can see the starter service and the firebasemessaging service running in the device's Application Manager. However, it doesn't appear to have actually subscribed to my topic, as I don't get a notification when I subsequently send a message to the FCM API.

    If I uninstall the app and rebuild it so the starter service doesn't start at boot, then install and run it, my topic subscription works as expected (i.e. I can send a message to the FCM API with the topic in the post request that causes a notification on my device).

    Any suggestions gratefully accepted :)

    Vaughan
     
    pesquera likes this.
  8. Erel

    Erel Administrator Staff Member Licensed User

    You need to install the two repositories: https://www.b4x.com/android/forum/threads/integrating-firebase-services.67692/

    You don't need to do anything special. Once the app has subscribed to a topic it will remain subscribed until the app is uninstall. No need to start at boot.

    Note that you need to run the app in Release mode in order to test it.
     
    toby and pesquera like this.
  9. VTSinLincoln

    VTSinLincoln Member Licensed User

    Thanks Erel

    It works :)

    I just have to be a bit more patient when the device restarts as it can take a few minutes for the notification to arrive.


    V
     
  10. ilan

    ilan Expert Licensed User

    WOW, this is amazing. it is really working :D
    thank you very much @Erel!!!!

    i have integrated Admob + Push Notification and it is working like a charm!! (please make it also for b4i)
     
  11. driesvp

    driesvp Member Licensed User

    I'm also facing problems with "Maven artifact..."
    upload_2016-6-26_22-44-33.png

    I added the manifest snippets for Google play, Firebase and notifications.
    The repositories are installed.

    upload_2016-6-26_22-43-21.png

    Also, I created a Firebase Project.

    What can be the problem?
     
  12. ilan

    ilan Expert Licensed User

    are you testing it in release mode?
     
  13. driesvp

    driesvp Member Licensed User

    indeed
     
  14. ilan

    ilan Expert Licensed User

    so you copied those 3 snippets

    have you created the json file and put it in the folder where the b4a file is located?

    do you have any other attributes in you code?
     
  15. shashkiranr

    shashkiranr Active Member Licensed User

    Hi All,

    Just one question. If i need to send a massage for just one selected device out of 100 devices, how can I do that?

    Best,
    SK
     
  16. Erel

    Erel Administrator Staff Member Licensed User

    Are you sure that the IDE uses the correct Android SDK (Tools - Configure Paths)?

    Either subscribe each device to a unique topic or use your own server with the token ids (see FirebaseMessaging.Token).
     
  17. shashkiranr

    shashkiranr Active Member Licensed User

    Hi Erel,

    Thank you for the reply. I am saving individual tokens in the db. what is the format to send the messages using tokens.

    Best,
    SK
     
  18. DonManfred

    DonManfred Expert Licensed User

  19. DonManfred

    DonManfred Expert Licensed User

    based on this i would try something like

    Code:
    Private Sub SendMessage(id As String, Title As String, Body As String)
       
    Dim Job As HttpJob
       Job.Initialize(
    "fcm", Me)
       
    Dim m As Map = CreateMap("to"$"${id}"$)
       
    Dim data As Map = CreateMap("title": Title, "body": Body)
       m.Put(
    "data": data)
       
    Dim jg As JSONGenerator
       jg.Initialize(m)
       Job.PostString(
    "https://fcm.googleapis.com/fcm/send", jg.ToString)
       Job.GetRequest.SetContentType(
    "application/json;charset=UTF-8")
       Job.GetRequest.SetHeader(
    "Authorization""key=" & API_KEY)
    End Sub
     
  20. shashkiranr

    shashkiranr Active Member Licensed User

    Thank you DonManfred.
     
Thread Status:
Not open for further replies.
Loading...
  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