Muh*_*wad 7 mobile android flutter huawei-mobile-services huawei-developers
由于我的应用程序是跨平台的,所以不会遇到任何问题,但是当涉及到android时,会出现一些问题,例如华为移动设备不再能够访问google play,并且它们有自己的应用程序商店(App Gallery),问题出现是因为我的应用程序的规格之一是强制用户下载最新版本,我不知道如何检测华为设备以让用户直接从应用程序库下载我的应用程序。
您可以按照此文档通过检查设备是否安装了HMS Core APK来检测华为设备。
// Create an HmsApiAvailability instance
HmsApiAvailability client = new HmsApiAvailability();
// 0: HMS Core (APK) is available.
// 1: No HMS Core (APK) is found on device.
// 2: HMS Core (APK) installed is out of date.
// 3: HMS Core (APK) installed on the device is unavailable.
// 9: HMS Core (APK) installed on the device is not the official version.
// 21: The device is too old to support HMS Core (APK).
int status = await client.isHMSAvailable();
Run Code Online (Sandbox Code Playgroud)
更新: device_info 插件现已弃用。
使用https://pub.dev/packages/device_info_plus,它提供了类似的功能。
您可以获取设备制造商来检测华为设备
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
print('Running on ${androidInfo.manufacturer}');
Run Code Online (Sandbox Code Playgroud)
使用的插件 - https://pub.dev/packages/device_info
或者您可以检查设备中
的可用性GooglePlayServices
GooglePlayServicesAvailability availability = await GoogleApiAvailability.instance.checkGooglePlayServicesAvailability();
Run Code Online (Sandbox Code Playgroud)
需要插件 - https://pub.dev/packages/google_api_availability
注意:如果使用GooglePlayServices检查,还需要添加平台检查,因为在 iOS 设备上它会返回 false。
| 归档时间: |
|
| 查看次数: |
4263 次 |
| 最近记录: |