Skip to content

Instantly share code, notes, and snippets.

@satyajeetjadhav
Created August 28, 2020 05:46
Show Gist options
  • Save satyajeetjadhav/e642cffbdf120d4a4a78fcc35428b760 to your computer and use it in GitHub Desktop.
Save satyajeetjadhav/e642cffbdf120d4a4a78fcc35428b760 to your computer and use it in GitHub Desktop.
Webservice for Safari Push Notifications with Expressjs
// 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