react-native-has-hms
Huawei Mobile Services utility to check if a device is running the HMS service.
Getting started
Only supported for Android.
npm install react-native-has-hms --save
or
yarn add react-native-has-hms
Link up the library
react-native link react-native-has-hms
Huawei Developer Console
- You will need to sign up with a Huawei Developer Account. That can be done here https://developer.huawei.com/consumer/en/
- This guide can also help with the setup of your app. The guide here.
- You will need to get a file with the name
agconnect-services.json
- Add the
agconnect-services.json
file to yourandroid
directory.
Additional android setup
- In
android/build.gradle
- Add minimum SDK version to at least 17
- Add the maven repo for Huawei
- Add dependencies for
com.huawei.agconnect
andcom.google.gms
//...buildscript ext buildToolsVersion = "28.0.3" minSdkVersion = 17 //<----- Change this to at least version 17, this is required by Huawei Mobile Services compileSdkVersion = 28 targetSdkVersion = 28 repositories maven url 'https://developer.huawei.com/repo/' //<----- Add Huawei Maven repository dependencies classpath 'com.android.tools.build:gradle:3.5.3' classpath 'com.huawei.agconnect:agcp:1.2.0.300' // <------ Add Huawei Services Core classpath classpath 'com.google.gms:google-services:4.3.3' // <------ Add Google Services Core classpath //...
- In
android/app/build.gradle
- At the bottom of the file add
apply plugin: 'com.huawei.agconnect'
- At the bottom of the file add
//...apply plugin: 'com.huawei.agconnect'// ...
Usage
; ... hasGoogleMobileServices = async { const hasGMS = await HasHms console return hasGMS} hasHuaweiMobileServices = async { const hasHMS = await HasHms console return hasHMS} ...