Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apple Push Notification Service - change title of notification message

I have APNS messages working well. However I'd like to change the title of the messages that are sent. Currently the title is always the name of my app. I see that notifications for the native iOS 'Mail' app have the 'From' address as the title of the message and also have the email subject showing in bold as a sub-heading to the notification. I'd like to reproduce this for my app's notifications but can't see how to do this. The JSON payload just seems to have a key for "alert" with no mention of a 'title' key. Is it possible to achieve what I want?

like image 792
Jonathan Wareham Avatar asked Dec 27 '22 20:12

Jonathan Wareham


2 Answers

Not possible to change the title of APNS messages.

like image 20
Jonathan Wareham Avatar answered Feb 15 '23 01:02

Jonathan Wareham


I just stumbled over this old question and just wanted to add, that specifying a title and body for the notification is now possible (since iOS 8, I think).

Your push payload needs to look like this:

{
  "aps": {
    "alert": {
        "title": "New Message from Boss",
        "body": "Can you complete the new feature until tomorrow, please?!"
    }
  }
}

You find the detailed specs in Apple's Local and Remove Notification Programming Guide.

like image 118
codingFriend1 Avatar answered Feb 15 '23 02:02

codingFriend1