Firebase-tools: Upload custom apple-app-site-association file.

Created on 14 Mar 2019  Â·  9Comments  Â·  Source: firebase/firebase-tools

I am trying to upload custom apple-app-site-association files to my domain which I associated with Firebase hosting. The reason for doing this is simple - I have multiple iOS apps associated with my Firebase project and I want to ensure that apple-app-site-association file contains correct paths. The domain will be used for Dynamic Links. The reason why I have multiple apps is that we develop theory test applications and these apps are designed for specific vehicle category (car, motorcycles, etc). I do want to keep them in one project as they are very much related and I might decide to release one combined version at some point.

Here are the approaches which I tried to have a custom apple-app-site-association file:

Uploading custom static file

To make this work, I had to include the "headers" section in my firebase.json to ensure that these files returned as json rather than as dms files. The approach works just fine – I did succeed in replacing the default association file. However, as soon as I tried to add this domain to Dynamic Links I got a warning telling me that I am already serving content through this hosting and I need to use a different path.

Modifying appAssociation value

At some point, I saw that I need to specify "appAssociation": "AUTO" in my firebase.json file. And I obviously thought that instead of AUTO, I need to find a different value. So far, I only managed to confirm that another possible value is NONE. And, as the name suggests, it does ensure that Firebase does not generate these files on its own, which in turn allows me to provide them via a call to my custom function in "rewrites" section. The problem is that this is also considered invalid and I see a message in Dynamic Links section telling me to ensure that I have my "appAssociation" set to "AUTO".

Conclusion

It seems that in order to achieve what I want there are two possible scenarios:

1) Modify "appAssociation" value in firebase.json to such which allows the upload of custom files.
2) Leave the "appAssociation" value at AUTO, but then find a way to ensure that "rewrites" are applied to apple-app-site-association even though such static content exists. As far as I know, regular rewrites are ignored when the requests match a static content. However, maybe there is a way to force the rewrite?

Here is the apple-app-site-association file from our website so that you can see an example of how I want to specify paths.

Most helpful comment

I was able to override the auto-generated apple-app-site-association just now, using the following firebase.json, and identical files src/.well-known/apple-app-site-association and src/apple-app-site-association with my custom data in them.

{
  "hosting": {
    "appAssociation": "AUTO",
    "public": "src",
    "rewrites": [
      {
        "source": "/**",
        "dynamicLinks": true
      }
    ],
    "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"
          }
        ]
      }
    ]
  }
}

Make sure that you have "public" set to the folder that contains the aasa file(s)

Note that you'll have to follow the manual flow for setting up dynamic links with a custom domain.

All 9 comments

Do you need to generate the file dynamically from a function? If you upload a static file in place of the automatically generated one (whether or not you set appAssociation to NONE) it should serve in place of the auto-generated one.

It's also possible that the validation in the FDL console is a little too aggressive, I'll file a bug to look into that internally.

Yes, check on FDL page is likely too aggressive. Can you verify the error that you is on the links management/list page? And if it's blocking anything?

@mbleigh @AndriyGo I think I have a similar problem, having connected a custom domain to firebase hosting and adding the dynamicLinks configuration to firebase.json I am unable to add the url prefix "mycustomdomain.de" to firebase dynamic links. The continue button in step 2 "config" simply stays greyed out, no matter what I do. Google page.link domains work perfectly fine.

@mbleigh I would prefer to upload a static file.

I now figured out a way to do this which works for me.

"appAssociation": "AUTO", "rewrites": [ { "source": "/car_moto/**", "dynamicLinks": true }, { "source": "/lgv_pcv/**", "dynamicLinks": true }, { "source": "/adi/**", "dynamicLinks": true } ]

With such setup in my firebase.json I am able to upload my own apple-app-site-association file and I am able to generate Dynamic Links. However, now I run into #1172 and I am not sure if it is a related bug.

I was going to point to the following snippet : https://gist.github.com/mbleigh/c9140c97a342b9d2e7cd727e21b6268f

@AndriyGo Did you manage to resolve this issue and get your custom aasa file working? I am also stuck on this – I have been generating email verification links using a custom domain, which was working perfectly. However, I am now trying to get iOS AutoFill working correctly, and believe I need to add a webcredentials key to the aasa file in order to support this. I hosted my custom aasa file in the .well-known directory, included the headers in my firebase.json file to ensure the file returned as json, and added webcredentials: to the associated domains section in xcode. After making these changes, my dynamic links stopped working. Additionally, reverting those changes does not fix the dynamic links. From the comments in this issue it sounds like hosting my own aasa file should work (apart from the too aggressive check on the FDL page, mentioned by @mbleigh and @mh6o) – I have a feeling I must have missed a step?

@AndriyGo tried your solution today and can't get it to work :( as long as I set "appAssociation": "AUTO" it auto-generates the file 👎 any idea?

iOS Keychain Autofill will not work if "webcredentials:YOURDOMAIN" is not set. I'm having the same issue as @ingridelin. Can you guys please enabled support for manually editing the AASA file hosted on Firebase? Really need this functionality.

New discussion in here
https://gist.github.com/mbleigh/c9140c97a342b9d2e7cd727e21b6268f

I was able to override the auto-generated apple-app-site-association just now, using the following firebase.json, and identical files src/.well-known/apple-app-site-association and src/apple-app-site-association with my custom data in them.

{
  "hosting": {
    "appAssociation": "AUTO",
    "public": "src",
    "rewrites": [
      {
        "source": "/**",
        "dynamicLinks": true
      }
    ],
    "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"
          }
        ]
      }
    ]
  }
}

Make sure that you have "public" set to the folder that contains the aasa file(s)

Note that you'll have to follow the manual flow for setting up dynamic links with a custom domain.

Was this page helpful?
0 / 5 - 0 ratings