-
Notifications
You must be signed in to change notification settings - Fork 21
Back end configuration
-
Navigate to universal_web_notification_sender project. Set previously generated (in Step 1.1) server keys as below.
// universal_web_notification_sender/src/main/java/info/wearetrying/PushServerVars.java static final String VAPID_PUBLIC_KEY = "put-the-public-key-here"; static final String VAPID_PRIVATE_KEY = "put-the-private-key-here";
2. Add your subscriptions in `Sender.java` as below.
```java
PushSubscription nonSuffariSubscription = new PushSubscription( "subscriptionJson" )
String suffariSubscription = "subscriptionToken";
- Sample notification should be delivered to your browser when you run
Sender.java
class.
If you need to send notifications to Safari browser, following additional steps are needed.
-
Place your .cer file (i.e apn_developer_identity.cer), .p12 file (i.e. private_dev_key.p12) and .certSigningRequest (i.e CertificateSigningRequest.certSigningRequest) in same directory and execute following commands to create apn_developer_identity.p12.
openssl x509 -in apn_developer_identity.cer -inform DER -out apn_developer_identity.pem -outform PEM} openssl pkcs12 -nocerts -out private_dev_key.pem -in private_dev_key.p12 openssl rsa -out private_key_noenc.pem -in private_dev_key.pem openssl pkcs12 -export -in apn_developer_identity.pem -inkey private_key_noenc.pem -certfile CertificateSigningRequest.certSigningRequest -name "apn_developer_identity" -out apn_developer_identity.p12
2. Place your **apn_developer_identity.p12** in **universal_web_notification_sender** project root.
3. Change your certificate passkey in `private static void sendToSafari()` method in `Sender.java` class.
4. Uncomment `sendToSafari(safariSubscription, safariPayload);` line
in `public static void main(String[] args)` method in `Sender.java` class.
3. Sample notification should be delivered to your Safari when you run `Sender.java` class.
### References
**If you encounter any problem with above guide lines, following resources from the original authors will be helpful.**
- [web-push-libs](https://github.com/web-push-libs), [MartijnDwars/web-push](https://github.com/MartijnDwars/web-push) for sending push notifications to non-Safari browsers.
- [jpoz/APNS](https://github.com/jpoz/APNS) and [notnoop/java-apns](https://github.com/notnoop/java-apns) for sending notifications to Safari.
- Some online demo sites, [simple-push-demo](https://gauntface.github.io/simple-push-demo/), [simple-push-demo-repo](https://github.com/gauntface/simple-push-demo)
- A free third party service does all of above things, [OneSignal](https://onesignal.com)