I ended yesterday’s post (on using a link to sign in to an app) by promising to try out iOS 9’s Universal Links. To do this, you need to serve a JSON file at yourDomain.com/apple-app-site-association — this is a quick way to do that.
There are two steps to this:
The code we’re interested in is pretty much straight off the node.js website:
var http = require(‘http’);
var json = {
“applinks”: {
“apps”: [],
“details”: [
{
“appID”: “5C79KQUVVH.com.constellational”,
“paths”: [ “*” ]
}
]
}
};
var port = process.env.PORT || 3000;
http.createServer(function (req, res) {
res.writeHead(200, {‘Content-Type’: ‘application/json’});
res.end(JSON.stringify(json));
}).listen(port);
To get this running on Heroku, we also need an NPM package.json:
{
“name”: “constellational-web”,
“version”: “1.0.0”,
“main”: “index.js”,
“scripts”: {
“start”: “node index.js”
}
}
An app.json:
{
“name”: “Constellational”,
“repository”: “https://github.com/constellational/web"
}
And a Procfile:
web: npm start
And that’s it! You’ve made your first web app! Make sure your app on Heroku is connected to your Github repository, and click on “Deploy Branch” at the bottom of the deploy page.