Push Notification Implementation on Safari
- HTTPS enabled site
- Apple developer certificate (.p12)
npm install
-
Register and download your apple certificate from Apple Developer Console or follow this article for details
-
Put those files (eg.
website_aps_production.cer
&Certificates.p12
) into certificates directory -
Then generate the expected certificate & key file using these commands
openssl x509 -in website_aps_production.cer -inform DER -outform PEM -out cert.pem
openssl pkcs12 -in Certificates.p12 -out key.pem -nodes
openssl x509 -inform der -in AppleWWDRCA.cer -out AppleWWDRCA.pem
-
Replace the push package related info in app.js, makePushPackage.js & client/index.html files
-
Run the app
node app.js
-
Visit your site on safari and subscribe the push notification
-
Send notification to the subscribed users
curl -XPOST -H 'Content-Type: application/json' https://yourdomain.com/send -d '
{
"alert": {
"title": "Push Test",
"body": "Hello, this is my first push notification"
}
}
'