4

I added react-native-maps which running with Google maps to my project. On Huawei devices without GMS (Google Mobile Services) when app starts, I get this prompt:

How to disable this confirmation dialog on devices without GMS? (prefer this answer)

Or

Is there any workaround to install react-native-maps on GMS and @hmscore/react-native-hms-map on HMS and import it in a proper way (depends on device GMS/HMS core) as a module to javascript side ?

karolkarp
  • 271
  • 2
  • 7
  • Have you seen: [Will react native work without Google Services on Huawei phone?](https://stackoverflow.com/q/58631362/295004) – Morrison Chang Feb 18 '21 at 21:52

1 Answers1

2

GMS is not supported on Huawei phones released after the Google ban.

Here I provide three options for you:

Option 1: Release your app both on HUAWEI AppGallery and Google Play, with different packages. The app you release on AppGallery contains only Huawei's logic code. For details about multi-channel packaging, please refer to docs.

Option 2: Release the same app on HUAWEI AppGallery and Google Play. Add the following code to determine whether GMS APIs or HMS APIs are available and call the available APIs:

public boolean  isGMS(){
    return GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(this) == com.google.android.gms.common.ConnectionResult.SUCCESS;
}
public boolean  isHMS(){
    return HuaweiApiAvailability.getInstance().isHuaweiMobileServicesAvailable(this) == com.huawei.hms.api.ConnectionResult.SUCCESS;
}

You can add the code manually, or use HMS ToolKit to realize G+H logic judgment.

Option 3: if you just want to suppress this dialog complaining "No google services available in this device...." in RN that could be achieved by Turning off Google Play Services availability errors:

firebase.utils().errorOnMissingPlayServices = false;
firebase.utils().promptOnMissingPlayServices = false;

for more information please visit this link.

zhangxaochen
  • 32,744
  • 15
  • 77
  • 108
  • But this confirmation dialog is caused by react-native-maps which uses Google under the hood. When I added in index.js : import firebase from '@react-native-firebase/app'; firebase.utils().errorOnMissingPlayServices = false; firebase.utils().promptOnMissingPlayServices = false; nothing was changed. Confirmation dialog still appears. – karolkarp Feb 19 '21 at 08:07
  • hi@karolkarp,have you check this **[link](https://github.com/invertase/react-native-firebase-docs/blob/master/docs/troubleshooting/android.md#turning-off-google-play-services-availability-errors)**?It said that *This must be called at the module scope, outside any classes, preferably before any other usages of react-native-firebase so that it's disabled before the internal logic takes over.* – zhangxaochen Feb 19 '21 at 08:12
  • Yes, I call it before any other usages of react-native-firebase. Still confirmation dialog is showing up. – karolkarp Feb 23 '21 at 09:29