Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Universal link not redirecting to app store

I am trying to implement setup Universal Link for IOS 9 device with both side configuration.Firstly I have done configuration at server Side with steps:

1.created one unsigned apple-app-site-association-unsigned.txt file and file contents is

{
        "activitycontinuation": {
            "apps": [
              "9JA89QQLNQ.com.apple.wwdc"
            ]
          },
        "applinks": {
                "apps": [],
                "details": [
                    {
                        "appID":"9JA89QQLNQ.com.apple.wwdc",
                        "paths": [
                                        "*",
                                        "/"
                                ]
                    }
                ]
            }
     } 

2.Did sign the above mentioned file using

cat apple-app-site-association-unsigned.txt | openssl smime -sign -inkey demo.key -signer demo.crt -certfile demo.pem -noattr -nodetach -outform DER > apple-app-site-association

3.then it is created on signed file i.e apple-app-site-association

4.moved this file into root server where my certificates are available.

5.created one endpoint with node.js

var https = require('https');
var fs=require('fs');
var express = require('express');
var privateKey  = fs.readFileSync(home_path + 'src/Server/API/demo.key', 'utf8');
var certificate = fs.readFileSync(home_path + 'src/Server/API/demo.crt', 'utf8');
var credentials = {key: privateKey, cert: certificate};
var app = express();
var httpsServer = https.createServer(credentials, app);
httpsServer.listen(8443);
console.log('deeplink service listening on port 3501');    
var aasa = fs.readFileSync('./apple-app-site-association');
app.get('/apple-app-site-association', function(req, res, next) {
    console.log("Request landed on 8443 port.");
     res.set('content-type', 'application/pkcs7-mime');
     res.status(200).send(aasa);
});

6.then my end point is:- https://domain.com:8443/apple-app-site-association

7.My app is not installed in device then if I copied universal link i.e https://domain.com:8443/apple-app-site-association in Ios 9 safari browser,it is not redirecting to App store, instead of that it is displaying apple-app-site-association file to download.

Note:- I did only server side configuration,so that if my app in not installed it should redirect to app store.

Any idea on this where I am wrong?

like image 702
Santosh Khavekar Avatar asked Jan 06 '23 04:01

Santosh Khavekar


1 Answers

I believe you may be fundamentally misunderstanding how Universal Links work. You should do some additional research into Universal Links to make sure you have the concept correct. This might be a good place to start.

That said, a few things that may help:

  1. You can't implement Universal Links on just one half of the equation. For anything to work, you need both the server and in-app components.
  2. iOS is very particular about where it looks for the apple-app-site-association file. It will not check on port 8443. The easiest option is to use the standard HTTPS port (443), but assuming your signing attempts are valid, non-HTTPS should also work (port 80).
  3. The URL https://domain.com/apple-app-site-association (extraneous port reference removed) itself is not a Universal Link. This is simply a validation file you need to host so that when you implement Universal Links in your app, iOS is able to confirm you own and control the domain in question.
  4. Universal Links don't automatically handle redirection to the App Store. They simply control whether the app opens (if it is installed) or the website loads (if the app is not installed). The website that is loaded when the app is not installed needs to implement the App Store redirect.

Many apps don't even attempt to handle all of this complexity, especially since Universal Links are still only a partial solution to deep linking (they don't work in Facebook, Twitter, or any app using SFSafariViewController, amongst others), so you may want to look into an external link routing service. Branch.io (full disclosure: I'm on the Branch team) is a good option and handles all of these technical details for you.

like image 132
Alex Bauer Avatar answered Jan 13 '23 08:01

Alex Bauer