Android Question Unable to resolve host "fcm.googleapis.com"

kohle

Active Member
Licensed User
Longtime User
I have an app running which send notifications via firebase. Since the 27.11 I get the following error :

ResponseError. Reason: java.net.UnknownHostException: Unable to resolve host "fcm.googleapis.com": No address associated with hostname, Response:


When I send a notification from the google firebase console it works fine.

B4X:
public Sub SendNotif( Title As String, Body As String, Topic As String)
    Dim j As HttpJob
    Dim API_KEY As String ="my-key"
        
    
    
    If Topic.Trim ="" Then
        Return
    End If
    
    
    J.Initialize("fcm", Me)
    Dim m As Map = CreateMap("to": $"/topics/${Topic}"$)
    Dim data As Map = CreateMap("title": Title, "body": Body,"sound": "default")
    m.Put("data", data)
    Dim jg As JSONGenerator
    jg.Initialize(m)
    J.PostString("https://fcm.googleapis.com/fcm/send", jg.ToString)
    J.GetRequest.SetContentType("application/json;charset=UTF-8")
    J.GetRequest.SetHeader("Authorization", "key=" & API_KEY)
    

    Log("************************ send: " & Title & " body:" & Body)

        
End Sub
 

kohle

Active Member
Licensed User
Longtime User
The problem is solved. After an energy fail the device connected automatically to a router without internet access.
So the notifications couldnt be sent.
 
Upvote 0
Top