Created
August 28, 2020 05:46
-
-
Save satyajeetjadhav/e642cffbdf120d4a4a78fcc35428b760 to your computer and use it in GitHub Desktop.
Webservice for Safari Push Notifications with Expressjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// server.js | |
// where your node app starts | |
// we've started you off with Express (https://expressjs.com/) | |
// but feel free to use whatever libraries or frameworks you'd like through `package.json`. | |
const express = require("express"); | |
const app = express(); | |
app.use(express.json()); | |
app.post("/v1/pushPackages/web.com.localhost.pushDemo",(request,response)=>{ | |
// return the push package | |
response.set('Content-Type',"application/zip"); | |
response.download(__dirname + "/assets/pushPackage.zip" , "pushPackage.zip"); | |
}) | |
app.post("/v1/log",(request,response)=>{ | |
// print the logs to the console | |
console.log(request.body.logs); | |
console.log(request.body); | |
response.sendStatus(200); | |
}) | |
app.post("/v1/devices/*/registrations/web.com.localhost.pushDemo",(request,response)=>{ | |
// capture requests to register or deregister the token | |
response.sendStatus(200); | |
}) | |
// listen for requests :) | |
const listener = app.listen(process.env.PORT, () => { | |
console.log("Your app is listening on port " + listener.address().port); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment