Skip to content

Instantly share code, notes, and snippets.

@mbleigh
Created August 2, 2016 18:42
Show Gist options
  • Star 17 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mbleigh/c9140c97a342b9d2e7cd727e21b6268f to your computer and use it in GitHub Desktop.
Save mbleigh/c9140c97a342b9d2e7cd727e21b6268f to your computer and use it in GitHub Desktop.
Firebase Hosting for apple-app-site-association
{
"hosting": {
"headers": [
{
"source": "/.well-known/apple-app-site-association",
"headers": [{"key": "Content-Type", "value": "application/json"}]
}
]
}
}
@Premodial
Copy link

Hi I have the configuration below. But it seem like my https request just get the default firebase index.html and its not opening my app. I tried even deleting the index.html in the public folder.

{
"hosting": {
"public": "public",
"site":"soco-app-v01",
"headers": [
{
"source": "/.well-known/apple-app-site-association",
"headers": [
{
"key": "Content-Type",
"value": "application/json"
}
]
}
],
"appAssociation": "NONE"
}
}

@riazhazan
Copy link

@Blackjacx

which commands do you use to upload the apple-app-site-association file and where exactly must it be? Can somebody pls post how the firebase json has to look that this works?

There are 4 things to check:

  1. The apple-app-site-association file should be placed at the root of your server or in the .well-known subdirectory.
  2. The apple-app-site-association file should be served on the HTTPS. (This is done by Firebase.)
  3. The apple-app-site-association file should be served as the application/json MIME type, without appending .json to the filename. By setting a custom header in firebase.json, it can be done.
  4. Even though the Dynamic Links is not set, the Firebase overrides the apple-app-site-association file in / and /.well-known to its own file by default. To avoid this, the appAssociation property in firebase.json should be set to NONE.

Then the firebase.json file should be like below:

{
  "hosting": {
    "public": "public",
    "headers": [
      {
        "source": "/.well-known/apple-app-site-association",
        "headers": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ]
      }
    ],
    "appAssociation": "NONE"
  }
}

This saved my time. I was chasing this for 2 days and this saved my time.

@Tak783
Copy link

Tak783 commented Apr 24, 2023

Ok, so this is what I did to make it work

  1. Deleted the apple-app-site-association file
  2. Recreated it via terminal with the following command touch apple-app-site-association (note, there is no .json)
  3. Moved the apple-app-site-association to the public folder at the root + also added the well known folder too public/.well-known/apple-app-site-association

I then verified with https://branch.io/resources/aasa-validator/
I also then went to https://_my_redacted_app+name/.well-known/apple-app-site-association and saw the expected JSON from apple-app-site-association

The code looks like this

Firebase.json file

{
    "hosting": {
        "public": "public",
        "headers": [
            {
                "source": "/.well-known/apple-app-site-association",
                "headers": [
                    {
                        "key": "Content-Type",
                        "value": "application/json"
                    }
                ]
            },
            {
                "source": "apple-app-site-association",
                "headers": [
                    {
                        "key": "Content-Type",
                        "value": "application/json"
                    }
                ]
            }
        ],
        "appAssociation": "NONE"
    }
}

apple-app-site-association

{
    "applinks": {
        "details": [
            {
                "appIDs": [ ""_my_redacted_app_id.my_redacted_bundle_id""],
                "components": [
                    {
                        "/": "/public/*",
                        "comment": "my_redacted_comment"
                    }
                ]
            }
        ]
    }
}

@stefannovak
Copy link

"source": "/.well-known/apple-app-site-association",
        "headers": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ]

putting it in public/.well-known solved it for me. Note, I also didn't need to include the appAssociation line in firebase.json, seems they fixed that bug.

@Harikarthyk
Copy link

In the Branch.io aasa validator, I'm getting a successful response.
But when I try hitting the URL in the app, it is not opening the app.

@RanoshTarek
Copy link

I hosted the website in the default domain
then I created another domain
I use the other domain to handle my deep link which works fine on Android but ios, not
ios open the preview screen then redirect to the hosted website (default domain) expected to open ios app like android
firebase.json
{
"hosting": {
"public": "build/web",
"ignore": [
"firebase.json",
"/.*",
"
/node_modules/"
],
"headers": [
{
"source": "/.well-known/apple-app-site-association",
"headers": [
{
"key": "Content-Type",
"value": "application/json"
}
]
},
{
"source": "apple-app-site-association",
"headers": [
{
"key": "Content-Type",
"value": "application/json"
}
]
}
],
"appAssociation": "NONE",
"rewrites": [
{
"source": "
",
"dynamicLinks": true
},
{
"source": "/",
"dynamicLinks": true
},
{
"source": "/links/
",
"dynamicLinks": true
},
{
"source": "/sina-app.com/",
"dynamicLinks": true
},
{
"source": "https://sina-app.com/
",
"dynamicLinks": true
},
{
"source": "sina-app.com/**",
"dynamicLinks": true
},
{
"source": "sina-app.com/*",
"dynamicLinks": true
}
]
}
}

@dleurs
Copy link

dleurs commented Jan 24, 2024

SOLVED my folder was .well_known instead of .well-known

I don't know why I am getting content-type: text/plain; charset=utf-8 when curl -i https://destrompesetvous-b6900.web.app/.well_known/apple-app-site-association

I also placed apple-app-site-association inside root and here it is working, I am getting content-type: application/json when curl -i https://destrompesetvous-b6900.web.app/apple-app-site-association

firebase.json

{
  "hosting": {
    "public": "build/web",
    "headers": [
      {
        "source": "/.well-known/apple-app-site-association",
        "headers": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ]
      },
      {
        "source": "/apple-app-site-association",
        "headers": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ]
      },
      {
        "source": "/.well-known/assetlinks.json",
        "headers": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ]
      }
    ],
    "appAssociation": "NONE"
  }
}

apple-app-site-association and .well_known/apple-app-site-association

{
  "webcredentials":{
     "apps":[
        "JJS627SP9W.fr.trompe.appli"
     ]
  },
  "applinks":{
     "details":[
        {
           "appID":"JJS627SP9W.fr.trompe.appli",
           "paths":[
              "*"
           ],
           "appIDs":[
              "JJS627SP9W.fr.trompe.appli"
           ],
           "components":[
              {
                 "/":"/*"
              }
           ]
        }
     ]
  }
}

And tried adding rewrites rules without success

"rewrites": [ {
      "source": "/.well-known/apple-app-site-association",
      "destination": "/apple-app-site-association"
    } ], 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment