https://github.com/sohelamin/safari-push-notification
Push notification implementation for safari browser
https://github.com/sohelamin/safari-push-notification
safari safari-push-notifications
Last synced: 7 months ago
JSON representation
Push notification implementation for safari browser
- Host: GitHub
- URL: https://github.com/sohelamin/safari-push-notification
- Owner: sohelamin
- Created: 2019-03-12T16:24:23.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-03-30T15:14:16.000Z (over 6 years ago)
- Last Synced: 2025-01-06T19:40:04.505Z (9 months ago)
- Topics: safari, safari-push-notifications
- Language: JavaScript
- Homepage:
- Size: 17.6 KB
- Stars: 4
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Safari Push Notification
> Push Notification Implementation on Safari
## Pre-requisites
- HTTPS enabled site
- Apple developer certificate (.p12)## Installation
```
npm install
```## Usage
1. Register and download your apple certificate from [Apple Developer Console](https://developer.apple.com/account/ios/certificate) or follow [this article](https://pushalert.co/documentation/creating-safari-web-push-certificate) for details2. Put those files (eg. `website_aps_production.cer` & `Certificates.p12`) into certificates directory
3. 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
```4. Replace the push package related info in [app.js](app.js), [makePushPackage.js](makePushPackage.js) & [client/index.html](client/index.html) files
5. Run the app
```
node app.js
```6. Visit your site on safari and subscribe the push notification
7. Send notification to the subscribed users
```bash
curl -XPOST -H 'Content-Type: application/json' https://yourdomain.com/send -d '
{
"alert": {
"title": "Push Test",
"body": "Hello, this is my first push notification"
}
}
'
```