SwiftPackageIndex / SwiftPackageIndex-Server

The Swift Package Index is the place to find Swift packages!
https://swiftpackageindex.com
Apache License 2.0
553 stars 44 forks source link

Universal Links not working #1035

Closed daveverwer closed 3 years ago

daveverwer commented 3 years ago

The AASA file is serving correctly, but it does not open the app 😬

https://staging.swiftpackageindex.com/.well-known/apple-app-site-association

daveverwer commented 3 years ago

Are there any debugging tools to check what's wrong with these files? It looks good to me.

Sherlouk commented 3 years ago

I've used https://branch.io/resources/aasa-validator/#resultsbox before. Looks like they're flagging an incorrect content type.

Your file's 'content-type' header was not found or was not recognized.

https://www.appsflyer.com/tools/app-links-validator/ taking it a step further, failing on all of these:

Invalid JSON schema MIME content type File >= 128Kb

daveverwer commented 3 years ago

I think it's the content-type. As this is being served as a static file from the web server and can't have a json extension, it'll be served as plain text.

We'll need to give this a route and serve it with custom headers. 🙄

The file certainly isn't > 128kb (it's 403 bytes) and is also valid JSON. I bet it's the content type.

finestructure commented 3 years ago

Still not working for me though.

finestructure commented 3 years ago

https://www.appsflyer.com/tools/app-links-validator/

CleanShot 2021-04-16 at 09 50 26@2x

Size error is bizarre, though:

content-length: 403
finestructure commented 3 years ago

https://limitless-sierra-4673.herokuapp.com says

CleanShot 2021-04-16 at 09 52 50@2x
finestructure commented 3 years ago

Which isn't what I was using on the old site. I had

    location /.well-known/apple-app-site-association {
        alias /usr/share/nginx/html/.well-known/apple-app-site-association;
        default_type application/json;
    }

but my AASA file was different:

{
    "applinks": {
        "apps": [],
        "details": [
            {
                "appID": "A42K5AU657.co.finestructure.ArenaUI",
                "paths": ["/app/*"]
            }
        ]
    }
}

I remember trying the "new" syntax and not getting it to work. Let's try "path" to see if this can work in principle.

daveverwer commented 3 years ago

Yea, that's the old syntax. The new syntax isn't that new, but it could be that.

daveverwer commented 3 years ago

Apple's Developer site uses application/json, and also uses paths instead of components.

$ curl -D - https://developer.apple.com/.well-known/apple-app-site-association
HTTP/1.1 200 OK
Server: Apple
Date: Fri, 16 Apr 2021 07:53:15 GMT
Content-Type: application/json
Content-Length: 2943
X-Frame-Options: SAMEORIGIN
Strict-Transport-Security: max-age=31536000; includeSubDomains
Accept-Ranges: bytes
X-XSS-Protection: 1; mode=block
Content-Security-Policy: default-src 'self' data: blob: 'unsafe-inline' 'unsafe-eval' https://*.apple.com http://*.apple.com https://*.mzstatic.com https://*.apple-mapkit.com https://p-events-delivery.akamaized.net http://p-events-delivery.akamaized.net
Access-Control-Allow-Origin: https://developer2.apple.com
Cache-Control: max-age=600, public
Host: developer.apple.com
X-Frame-Options: SAMEORIGIN
rqId: 67de1ddbcf0c2b3c3c4fb986fec2b2df
Age: 369
Via: http/1.1 uklon6-edge-lx-012.ts.apple.com (ApacheTrafficServer/8.1.2), https/1.1 uklon6-edge-bx-010.ts.apple.com (ApacheTrafficServer/8.1.2)
X-Cache: hit-stale, hit-fresh
Connection: keep-alive

{
    "applinks": {
        "apps": [

        ],
        "details": [
            {
                "appID": "9JA89QQLNQ.developer.apple.wwdc-Debug",
                "paths": [
                    "/videos/play/app-store-connect*",
                    "/videos/play/developer-stories*",
                    "/videos/play/enterprise*",
                    "/videos/play/insights*",
                    "/videos/play/tech-talks*",
                    "/videos/play/wwdc*",
                    "/fall??/*",
                    "NOT /wwdc??/agreement",
                    "NOT /wwdc??/aow",
                    "NOT /wwdc??/attending",
                    "NOT /wwdc??/childcare",
                    "NOT /wwdc??/consultations",
                    "NOT /wwdc??/events",
                    "NOT /wwdc??/fitness",
                    "NOT /wwdc??/get-togethers",
                    "NOT /wwdc??/guest-speakers",
                    "NOT /wwdc??/index.html",
                    "NOT /wwdc??/more",
                    "NOT /wwdc??/policy",
                    "NOT /wwdc??/register",
                    "NOT /wwdc??/scholarships",
                    "NOT /wwdc??/apple-m2-released-today",
                    "NOT /wwdc??/special-events",
                    "NOT /wwdc??/pro-studio",
                    "NOT /wwdc??/forums",
                    "NOT /news/releases/",
                    "NOT /wwdc",
                    "NOT /wwdc##",
                    "NOT /wwdc??/swift-student-challenge*",
                    "/wwdc??/*",
                    "/news/*",
                    "/??/news/*",
                    "/_dev_app/*"
                ]
            },
            {
                "appID": "9JA89QQLNQ.developer.apple.wwdc-Release",
                "paths": [
                    "/videos/play/app-store-connect*",
                    "/videos/play/developer-stories*",
                    "/videos/play/enterprise*",
                    "/videos/play/insights*",
                    "/videos/play/tech-talks*",
                    "/videos/play/wwdc*",
                    "/fall??/*",
                    "NOT /wwdc??/agreement",
                    "NOT /wwdc??/aow",
                    "NOT /wwdc??/attending",
                    "NOT /wwdc??/childcare",
                    "NOT /wwdc??/consultations",
                    "NOT /wwdc??/events",
                    "NOT /wwdc??/fitness",
                    "NOT /wwdc??/get-togethers",
                    "NOT /wwdc??/guest-speakers",
                    "NOT /wwdc??/index.html",
                    "NOT /wwdc??/more",
                    "NOT /wwdc??/policy",
                    "NOT /wwdc??/register",
                    "NOT /wwdc??/scholarships",
                    "NOT /wwdc??/special-events",
                    "NOT /wwdc??/pro-studio",
                    "NOT /wwdc??/forums",
                    "NOT /news/releases/",
                    "NOT /wwdc",
                    "NOT /wwdc##",
                    "NOT /wwdc??/swift-student-challenge*",
                    "/wwdc??/*",
                    "/news/*",
                    "/??/news/*",
                    "/_dev_app/*"
                ]
            },
            {
                "appID": "BVNY5T73P8.com.apple.Playgrounds",
                "paths": [
                    "/ul/sp0/*"
                ]
            },
            {
                "appID": "BVNY5T73P8.com.apple.PlaygroundsMac",
                "paths": [
                    "/ul/sp0/*"
                ]
            }
        ]
    },
    "activitycontinuation": {
        "apps": [
            "9JA89QQLNQ.developer.apple.wwdc-Debug",
            "9JA89QQLNQ.developer.apple.wwdc-Release"
        ]
    },
    "appclips": {
        "apps": [
            "49FGD8QDJT.com.example.apple-samplecode.AppClipCodesExample.Clip",
            "49FGD8QDJT.com.example.apple-samplecode.AppClipCodesExample",
            "A93A5CM278.com.example.apple-samplecode.AppClipCodesExampleApp1.Clip",
            "A93A5CM278.com.example.apple-samplecode.AppClipCodesExampleApp1",
            "LKPBD94D7D.com.ar.71497523.Clip",
            "LKPBD94D7D.com.ar.71497523",
            "LKPBD94D7D.com.example.apple-samplecode.SampleAppUniqueString", 
            "LKPBD94D7D.com.example.apple-samplecode.SampleAppUniqueString.Clip"
        ]
    }
}%                                               
finestructure commented 3 years ago

Let's let it sit for a moment, too. This goes via Apple's AASA CDN so it might take a while to update.

finestructure commented 3 years ago

We've concluded that universal links aren't actually the right tool for the job, so I'm closing this one.

I've made a note to remove the AASA file.