Android Question Firebase Messaging SubscribeToTopics

fbritop

Active Member
Licensed User
Longtime User
Hi,
I have a very strange situation. Upon FBM connection and as soon as I have an available Token, I do subscribe to a number of topics for each user depending on some attributes.

I see perfectly OK the users subscribing to the topics. But when I try to send a message to that topic, the message never arrives.

The wierd part is that if I send the notification to the user token, it arrives with no problem. In both cases, the Google SDK (For VB.Net) it displays the route of the message and that was succesfully sent to Firebase.

When I send the following data (From the message structure from the SDK):

JSON:
{
  "Token": null,
  "Topic": "C1394",
  "Condition": null,
  "Data": {
    "relayState": "0",
    "idAcceso": "2272",
    "deviceOnline": "1",
    "idDevice": "10172"
  },
  "Notification": null,
  "Android": null,
  "Webpush": null,
  "Apns": null,
  "FcmOptions": null
}

Google answers with: projects/android-abreme-cl/messages/644427452470285150
But no message on the Android app shows up (in my logs where I trace it)

If I send this data, which includes the user token:

JSON:
{
  "Token": "e9yQmKR6Sl2gemwCx-0rkj:APA91bGP6WWNMCtBXz_5dLZ9HAfeVo5vTwPp4QF4Nefr8yhFmE4B4kqPTbKvN4kch8R6_******************************************",
  "Topic": null,
  "Condition": null,
  "Data": {
    "relayState": "0",
    "idAcceso": "2272",
    "deviceOnline": "1",
    "idDevice": "10172"
  },
  "Notification": null,
  "Android": null,
  "Webpush": null,
  "Apns": null,
  "FcmOptions": null
}

Google answers with: projects/android-abreme-cl/messages/0:1730819047486989%8892d552f9fd7ecd
And the message on the Android app shows up (in my logs where I trace it)


I have tried both in Debug and in Release with the same luck. Has someone has experience something similar?
I did test also with a dummy topic subscribed with the topic name "test", same result.

Thanks
FBP
 

fbritop

Active Member
Licensed User
Longtime User
Where is the Sending Code you are using?
It is on a Windows Server with the Firebase SDK installed on it
Not relevant I think, because it is working with a token but not with a topic.

More wierd, tested the same App with the same topics on iOS and it was received


ASP.net:
                Dim jsonSerializer As New JavaScriptSerializer()
                jsonSerializer.MaxJsonLength = Int32.MaxValue
                if FirebaseApp.DefaultInstance is Nothing then
                    try
                        FirebaseApp.Create(New AppOptions() With {
                            .Credential = GoogleCredential.FromFile("C:\inetpub\wwwroot\com\************.json")
                        })          
                    catch ex As Exception
                        'LM.Helpers.ThrowError(ex.Message, false)
                       

                    finally


                    end try              
                end if
               
                        if objParams.containsKey("topic") andAlso objParams("topic")<>"" then

                            Dim message = New Message()
                            Dim foundData as boolean=false
                            message.topic="" & objParams("topic")
                            Dim data As New Dictionary(Of String, String)()

                            if objParams.containsKey("data") then
                                For Each kvp As KeyValuePair(Of String, Object) In objParams("data")
                                    data(kvp.Key) = kvp.Value.ToString()
                                Next          
                                if objParams.containsKey("notification") then
                                    Dim notification as object=objParams("notification")
                                    if notification.containsKey("title") then  data("title")=notification("title")
                                    if notification.containsKey("body") then  data("body")=notification("body")
                                    if notification("title")<>"" and notification("body")<>"" then data("action")="MSGBOX"
                                end if      
                                foundData=true      
                                message.data=data                          
                            end if

                            if objParams.containsKey("notification") then

                                message.Notification = New Notification()
                                Dim notification as object=objParams("notification")
                                if notification.containsKey("title") then  message.Notification.title=notification("title")
                                if notification.containsKey("body") then  message.notification.body=notification("body")
                                if not objParams.containsKey("data") then
                                    if notification.containsKey("title") then data("title")=notification("title")
                                    if notification.containsKey("body") then  data("body")=notification("body")  
                                    if notification("title")<>"" and notification("body")<>"" then data("action")="MSGBOX"
                                end if
                                if not foundData then
                                    message.data=data
                                end if
                            end if


                            Dim respuesta as String
                           
                            try
                                respuesta = FirebaseMessaging.DefaultInstance.SendAsync(message).Result
                                LM.Helpers.ThrowError(jsonSerializer.serialize(message), false)
                                LM.Helpers.ThrowError(respuesta, false)
                            catch ex As Exception
                                LM.Helpers.ThrowError("ERROR:", false)
                            end try
 
Last edited:
Upvote 0

fbritop

Active Member
Licensed User
Longtime User
Not sure if should be mark as close, because this is the kind of "BLACK BOX" errors..
I deleted the App Storage, which also clears the permisions, and then it started working.

It is still not clear, why is this. It is not a perms issue, as if it would have been so, I could not send a notification to my App with token, which worked before. Only topics where not working.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…