iOS Question IOS not receiving the push notifications

f0raster0

Well-Known Member
Licensed User
Longtime User
Hi Guys,

We have an App with push notifications.
The push notifications are working fine with Android, but not working with IOS iPhone.

To test, I use the b4j tool to send push-tests to Android and IOS, just IOS not receiving the pushs.

It was working fine until last year (last time that I tested it :rolleyes: ), then I think maybe something with the certificates, because I updated the certificates the last July, but not tested the pushs :cool: then I'm not sure if it stopped working at that time or just now.

Question,
Do we have any new bigs changes then that the problem could be in the IOS-App or maybe I just have to create the certificates/profile again?

Thanks for any advice.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

f0raster0

Well-Known Member
Licensed User
Longtime User
....Make sure to use the latest version of the B4J tool (there was an old version that only sent to Android)..

until last year I was using this b4j-tool, Is it correct?
B4X:
'Non-UI application (console / server application)
#Region  Project Attributes
    #CommandLineArgs:
    #MergeLibraries: True
#End Region

Sub Process_Globals
    'IOS
    Private const API_KEY As String = "AAA...........m7o"
    'Android
    'Private const API_KEY As String = "AAA...........ukL"

End Sub

Sub AppStart (Args() As String)

    'IOS
    SendMessage("ios_general", "title", "body") 
    'Android
    'SendMessage("general", "title", "body")
  
  
    StartMessageLoop
End Sub


Private Sub SendMessage(Topic As String, Title As String, Body As String)
    Dim Job As HttpJob
    Job.Initialize("fcm", Me)
    Dim m As Map = CreateMap("to": $"/topics/${Topic}"$)
    Dim data As Map = CreateMap("title": Title, "body": Body)
    If Topic.StartsWith("ios_") Then
        Dim iosalert As Map =  CreateMap("title": Title, "body": Body, "sound": "default")
        m.Put("notification", iosalert)
        m.Put("priority", 10)
    End If
    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


Sub JobDone(job As HttpJob)
   Log(job)
   If job.Success Then
     Log(job.GetString)
   End If
   job.Release
   ExitApplication '!
End Sub
 
Last edited:
Upvote 0
Top