Tech C**P
15 subscribers
161 photos
9 videos
59 files
304 links
مدرس و برنامه نویس پایتون و لینوکس @alirezastack
Download Telegram
Customize pushd server to add a new field like subtitle or title for iOS push notification payload. As you may know ios payload is like below:
{
"aps":{
"alert":{
"body":"New flight is booked",
"title":"Boarding at 20:05",
"subtitle": ""Yay!
},
"category":"openFlightCategory"
},
}

pushd by default does not support subtitle in the payload, to add this do the following:

- open /usr/local/pushdcustomized/lib/payload.coffee file
- add @subtitle = {} to line 14
- add when 'subtitle' then @subtitle.default = value to line 28
- add the below function to line 51:
localizedMessage: (lang) ->
@localized('subtitle', lang)

Ok done in payload. Push now accept subtitle for iOS, but there is one step left. You need to send subtitle to iOS device.

Open /usr/local/pushdcustomized/lib/pushservices/apns.coffee file and go to line note.alert = alert (line 44), and change it to:
note.alert = {'title':payload.title.default, 'body':payload.msg.default, 'subtitle': payload.subtitle.default}

OK DONE :)

Restart your pushd server and enjoy title and subtitle in your iOS push notifications.

#pushd #ios #title #subtitle #coffee_script #push #notification