iOS Question Push Notification Messages (SOLVED)

Neil Rohan

Member
Licensed User
I have several Android and iOS apps listed on the PlayStore and AppStore respectively. I have decided to upgrade them with Firebase Push Notifications. I followed Erel's tutorials for both platforms and was able to generate functioning applications.

I apologize in advance if this question has already been answered, but here goes:
Using the B4J sending tool to send an Android message, the result in my device is in the following format:

AppId in header
Title
Message (body)

When using the same tool to generate an iOS message, the result is a Messagebox with the following:

"Push message!"
JSON dump

Is there any way to format the iOS message in the same way the Android message is presented? That is, a simple title/body displayed?
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
When using the same tool to generate an iOS message, the result is a Messagebox with the following:

"Push message!"
JSON dump
While the app is in the foreground, right?

It simply a "debug" line:
B4X:
 Msgbox(Message, "Push message!")

Two options:

1. Add the UserNotificationCenter class to your project and initialize an instance of it in Application_Start.
This will cause the notification to appear while the app is in the foreground in the same way it appears while the app is in the background.

2. Parse the Message map and do whatever you like with the data:
B4X:
Private Sub Application_RemoteNotification (Message As Map, CompletionHandler As CompletionHandler)
    Log($"Message arrived: ${Message}"$)
    Dim aps As Map = Message.Get("aps")
    Dim alert As Map = aps.Get("alert")
    Log(alert.Get("body"))
    Log(alert.Get("title"))
    CompletionHandler.Complete
End Sub
 
Upvote 0
Top