Tech C**P
14 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
For enabling push notification on pushd server, you need to get a file with .p12 extension and .cer certificate file. For pushd to work you need to generate a .pem file and give its path in push configuration(`/etc/pushd/pushd.conf`).

We need to generate 2 pem files one called apns-cert.pem (generated from .cer file) and the other called apns-key.pem (generated from .p12 file).

To generate .pem file use openssl command, with the format below:
openssl pkcs12 -in YOUR_KEY.p12 -out apns-key.pem -nodes
NOTE: it may ask you for the password, enter the given password by whom that gave you the p12 file.

-in set your input file name and -out sets your output file name which will be generated.

And now generate the key pem file:
openssl x509 -in cert.cer -inform DER -outform PEM -out apns-cert.pem

Restart the pushd and check for any error in /var/log/pushd.

#pushd #openssl #p12 #cer #pem #push
Check if you can connect to APNS SERVER using openssl:
openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert /etc/pushd/apns-cert.pem -key /etc/pushd/apns-key.pem

At the end if you can connect to the APNS server you would see Verify return code: 0 (ok). Finally press CTRL+C to go outside of
response.

#pushd #openssl #apns #push