Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to turn off unsupported Google Play Service prompt in react-native app

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 ?

like image 460
karolkarp Avatar asked Aug 31 '25 03:08

karolkarp


1 Answers

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.

like image 181
zhangxaochen Avatar answered Sep 02 '25 17:09

zhangxaochen