如果你需要create您可以使用新的即时动态链接REST API去做吧。在更可能的情况下,您只需要您的应用程序openFirebase 动态链接,除了配置 Expo 应用程序来处理通用链接(即:使用 http/https 的深层链接)之外,您不需要执行任何操作。
检查清单是这样的:
1.配置你的app.json
对于 Android,添加intentFilters
财产给你的android
财产:
"android": {
"intentFilters": [
{
"action": "VIEW",
"data": [
{
"scheme": "https",
"host": "<your-domain>",
"pathPrefix": "/"
},
],
"category": [
"BROWSABLE",
"DEFAULT"
],
"autoVerify": true // required to work on newer android versions
}
]
]
对于 iOS,添加associatedDomains
财产给ios
:
"ios": {
"associatedDomains": ["applinks:<your-domain>"]
}
2. 配置您的域以允许应用程序处理来自该域的链接
如果您从特定位置提供配置文件,Android 和 iOS 将允许您的应用程序打开来自您域的链接:
安卓:https://<your-domain>/.well-known/assetlinks.json
iOS: https://<your-domain>/.well-known/apple-app-site-association
assetlinks.json
看起来像这样:
[{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "<android-package-name>",
"sha256_cert_fingerprints":
["<your-sha256-certificate-fingerprints>"]
}
}]
And the apple-app-site-association
像这样:
{
"applinks": {
"apps": [],
"details": [
{
"appID": "<your-team-id>.<ios-bundle-identifier>",
"paths": [ "*" ]
}
]
}
}
您可以阅读有关这些文件的更多信息here and here.
要获取应用程序签名证书的 SHA256 指纹,您可以使用 keytool:
keytool -list -v -keystore <your-key-file>
输入密钥库密码后,它将打印许多密钥库信息,包括 SHA256 指纹。
如果您的网站托管在 Firebase 上assetlinks.json
and apple-app-site-association
如果您在 Firebase 项目上创建应用程序,则可以自动生成。否则,只需将这些文件放在您的域的根目录下即可。
3. 创建 Firebase 动态链接
我认为这一步基本上是不言自明的,但只有一些注意事项:
- 设置您的短 URL 链接:最后您将获得 / 发送给您的用户
- 设置您的动态链接:您可以在此处定义您的 deelink(您希望应用程序处理的链接)
- 定义 iOS 的链接行为:您最有可能想要单击“打开 iOS 应用程序中的深层链接”并从列表中选择您的应用程序(如果还没有,请为项目上的每个平台创建一个应用程序)
- 定义 Android 的链接行为:与之前相同,但有更多选项可供选择
- 配置(或不配置)营销活动跟踪即可完成。
请记住,您始终应该通过单击而不是直接在浏览器上输入来测试深层链接。例如,您可以在 WhatsApp 上将链接发送给自己,或者安装一些笔记应用程序。
其他可能有帮助的资源:
- https://docs.expo.io/versions/latest/workflow/linking/
- https://reactnavigation.org/docs/deep-linking/