简体   繁体   English

Flutter Web 如何提供文件资产链接。json 用于 ZE84E30B9390CDB64DB6DB2C9AB878 应用程序验证

[英]Flutter Web how to serve file assetlinks.json for Android App Links verification

I am deploying a Flutter Web App on Firebase Hosting .我正在Firebase Hosting上部署Flutter Web 应用程序

And a Flutter App on Android .以及Android 上的 Flutter 应用程序

To use App Links that redirect to my Android application, I need to verify the App Links serving the file assetlinks.json on the web at https://example.com/.well-known/assetlinks.json To use App Links that redirect to my Android application, I need to verify the App Links serving the file assetlinks.json on the web at https://example.com/.well-known/assetlinks.json

How can I make the file available, without 3XX redirects, from my domain, that is Flutter deployed on the web with firebase hosting?如何在没有 3XX 重定向的情况下从我的域(即部署在 web 上的 Flutter 和 firebase 托管)中提供文件?

If I am not mistaken, Firebase stores files in a so called bucket.如果我没记错的话,Firebase 将文件存储在所谓的存储桶中。 The bucket can be directly exposed to the internet or you can use the API to pull the file you need and put it somewhere public on your domain:存储桶可以直接暴露在互联网上,或者您可以使用 API 提取您需要的文件并将其放在您的域中的某个公共位置:

https://firebase.google.com/docs/storage/web/list-files https://firebase.google.com/docs/storage/web/list-files

To see how to publish files in a gloud bucket, here is a good answer:要查看如何在 gloud 存储桶中发布文件,这是一个很好的答案:

How do you make many files public in Google Cloud Storage? 如何在 Google Cloud Storage 中公开许多文件?

Be aware the method described provides public access, so make sure you only expose what you want.请注意,所描述的方法提供了公共访问权限,因此请确保您只公开您想要的内容。

It is enough to add the .well-know folder and the file to the web folder of your Flutter project..well-know文件夹和文件添加到 Flutter 项目的web文件夹中就足够了。

And to change the firebase.json adding headers and rewrites entries.并更改firebase.json添加标题和重写条目。

{
  "hosting": {
    "public": "build/web",
    "appAssociation": "NONE",
    "ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
    "headers": [
      {
        "source": "/.well-known/assetlinks.json",
        "headers": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ]
      }
    ],
    "rewrites": [
      {
        "source": "/.well-known/assetlinks.json",
        "destination": "/.well-known/assetlinks.json"
      },
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  }
}

build and deploy again and the file is now accessible!再次构建和部署,文件现在可以访问了!

Thanks for the easy guide to https://blog.bam.tech/developer-news/universal-links-firebase-hosting-and-flutter-web感谢https 的简单指南://blog.bam.tech/developer-news/universal-links-firebase-hosting-and-flutter-web

Firebase Hosting automatically generates assetlinks.json and apple-app-site-association files when they are requested. Firebase 托管会在请求时自动生成assetlinks.jsonapple-app-site-association文件。 It doesn't require any extra configuration.它不需要任何额外的配置。

You just need to make sure that your app details (package, SHA256 certificate fingerprints, etc.) are correctly setup in the Project Settings and make sure that in your firebase.json the property appAssociation is set to "AUTO" (or omitted, as AUTO is the default value).您只需要确保在 项目设置中正确设置了您的应用程序详细信息(包、SHA256 证书指纹等),并确保在firebase.json中将属性appAssociation设置为"AUTO" (或省略,如AUTO是默认值)。

Example firebase.json :示例firebase.json

{
  "hosting": {
    "public": "build/web",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "appAssociation": "AUTO",
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  }
}

Ref: https://firebase.google.com/docs/hosting/full-config#rewrite-dynamic-links参考: https://firebase.google.com/docs/hosting/full-config#rewrite-dynamic-links

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将图像文件上传到Firebase存储并在Flutter web app中显示 - How to upload an image file to Firebase Storage and show it in the Flutter web app 如何使用深度链接将 Phantom 钱包连接到 Flutter 应用程序? - How to connect Phantom wallet to a Flutter app using deep links? 如何在 Flutter web 应用程序中使用云 Firestore - How to use cloud firestore in Flutter web app Flutter Firebase - 如何在点击 Firebase 发送的 email 验证链接时打开应用程序? - Flutter Firebase - How to open the app when tapping on email verification link send by Firebase? Flutter:如何使用邮箱验证FIrebase Auth - Flutter : How to use Email Verification FIrebase Auth 如何检查我的 Flutter Web 应用程序当前是否正在运行? - How to check if my Flutter Web app is currently running? 1 QuerySnapshot 在 Flutter web 应用程序中返回 null 但在 Android 控制台中给出结果 - 1 QuerySnapshot returning null in Flutter web app but gives result in the Android console 如何发送OTP到email email验证flutter firebase - how to send OTP to email for email verification in flutter firebase Flutter:如何将 Json 文件下载到本地然后访问它 - Flutter: How to download Json file to local then access it 如何让 Android 和 iOS 的 Flutter App 崩溃(测试 Firebase Crashlytics)? - How to crash Flutter App for Android and iOS (to test Firebase Crashlytics)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM