iOS Question Overwrite the message in a Push Notification

dieterp

Active Member
Licensed User
Longtime User
Is it possible to change the 'body' message that arrives in a push notification in the Application_RemoteNotification (Message as Map) sub? The string that arrives in the body message is bunch of messy values that I strip out using Regex.Split. I would like the notification message to be something cleaner though that the user can make sense of. I am referring to the message that appears in the Notifications pane of the device when the app is in the background.
 
Last edited:

tufanv

Expert
Licensed User
Longtime User
You cannot change the automatic notification text.

However you can use silent notifications and then show a local notification from your app. This will allow you to change the message.
I have the same issue. Isn't it something intereseting that the shown message contains absurd symbols ?
 
Upvote 0

dieterp

Active Member
Licensed User
Longtime User
My message is purposely sent with all the ";" characters in them so that I can break the different values up that I require to populate the database. It's just not very user-friendly text. I know in Android you can change the body message when it arrives.

Thanks for the suggestion Erel. Will try it out.
 
Upvote 0

dieterp

Active Member
Licensed User
Longtime User
Erel, I have gotten the Silent Notification to work to change the body message of the notification. I see however that the actual message that gets sent in the Notification does not get sent through with these changes. What do I need to do after setting the Silent notification to be able to receive/pull down the actual message?
 
Upvote 0

dieterp

Active Member
Licensed User
Longtime User
I'm also not entirely sure I'm doing the right thing but let me try explain. I add this line to the PushServer as per the Silent Push notification tutorial:

B4X:
jg.Initialize(CreateMap("aps":CreateMap("content-available": 1)))

When I send through the notification with my body message the following is what I receive on the client side. Using normal push notifications that map would normally contain my message:

B4X:
Remote notification: (read only map) {
    aps = "(read only map) {\n    \"content-available\" = 1;\n}";
}
(read only map) {
    "content-available" = 1;
}

Am I still able to retrieve the body message I sent in the notification and if so, how do I go about it?
 
Upvote 0
Top