react-native 組件Linking 或 expo-linking 框架在android11+ 版本上使用 canOpenUrl(schemeName) 無法通過 Scheme Name 準(zhǔn)確查到移動設(shè)備上是否安裝某個app。
Linking 引入:
1,import * as Linking from 'expo-linking';
或
2,import { Linking } from 'react-native';

通過上述方式無法在安卓11+版本的設(shè)備上準(zhǔn)確查找是否安裝了某個App。
解決方案:
使用react-native-share 插件里的share接口來通過 packageName 來檢查是否安裝了某個 App。
import Share from 'react-native-share';
Share.isPackageInstalled(packageName)
? ? ? ? ? ? .then(({ isInstalled }) => {
? ? ? ? ? ? ? ? // 處理邏輯
????????????}).catch(() => Promise.resolve(false))
這里 packageName 就是目標(biāo)app的包名。
需要在當(dāng)前項目工程 android 目錄下 AndroidManifest.xml 里
添加 queries 白名單:
<manifest>
<queries>
? ? ? <package android:name="com.weixin.android" />
? </queries>
</manifest>
這樣就可以解決問題。