最近将我们的构建目标切换到android 30以添加对Android 11的支持,现在方向和电话呼叫不起作用。
文档中提到了本地深度链接和/或npm包的使用。这是本地完成的吗?还是包是一个选项?
https://reactnative.dev/docs/linking
在运行android 30时,检查是否支持Linking.canOpenURL时,它现在返回false。
Linking.canOpenURL(url)
.then((supported: boolean) => (supported ? Linking.openURL(url) : Alert.alert("Error", "There was an error attempting to opening the location.")))
.catch(() => Alert.alert("Error", "There was an error attempting to opening the location."));
5条答案
按热度按时间lnvxswe21#
答案就在于一项全新的Android安全功能:Package Visibility。这与iOS的
LSApplicationQueriesSchemes
类似。定位Android 11(SDK 30)需要你更新你的
AndroidManifest.xml
,并包含你要查询的应用列表。例如,下面是我在自己的应用中用于检查谷歌Map导航的代码。它还包括HTTP和HTTPS的权限:对于applications matching certain criterias(例如防病毒应用、文件管理器或浏览器),您可以使用
QUERY_ALL_PACKAGES
权限来允许查询任何随机包,类似于早期Android版本:但是,请注意,如果您不符合下列任何应用类型的资格,或者以未经授权的方式使用
QUERY_ALL_PACKAGES
,您的应用将被Google Play拒绝:许可使用涉及必须发现设备上任何和所有已安装应用程序的应用程序,出于认知或互操作性目的,这些应用程序可能有资格获得许可。许可使用包括设备搜索、防病毒应用程序、文件管理器和浏览器。被授予此权限的应用程序必须遵守用户数据政策,包括显著披露和同意要求。不得将其用于未公开或无效的目的。
请参阅使用广泛包(应用程序)可见性(QUERY_ALL_PACKAGES)权限
aurhwmvo2#
在我的例子中,我需要将
android:host="*"
添加到data
标记中,如下所示:对于
Linking.canOpenURL(url)
,返回true
的https://...
URL。u59ebvdq3#
如果您决定使用
谷歌说:
许可使用涉及必须发现设备上任何和所有已安装应用程序的应用程序,出于认知或互操作性目的,这些应用程序可能有资格获得许可。许可使用包括设备搜索、防病毒应用程序、文件管理器和浏览器。被授予此权限的应用程序必须遵守用户数据政策,包括显著披露和同意要求。不得将其用于未公开或无效的目的。
从Google Play更新策略
v1l68za44#
如果您使用expo,则可以通过执行以下操作将此(https://github.com/chirag04/react-native-mail/pull/175/files)添加到manifest文件:
1.在根文件夹中创建一个名为“android-manifest.plugin.js”的新文件,其中包含下一个代码。
1.将上述插件添加到您的expo配置文件
app.json
1.使用
eas build
重建,也可以使用classic(expo build
),但请记住,它很快就会被弃用就是这样。你的APK应该有正常的清单加上上面链接中提到的部分。你也可以使用这种方法来设置你的清单。你也可以使用这个工具来验证你的清单是否被成功修改(如何从APK文件中查看AndroidManifest.xml?)
3qpi33ja5#
通过在清单中添加此内容解决了问题
谢谢大家的支持。