Capacitor plugin to check GMS and HMS availability
npm install capacitor-plugin-gmshms-checker
capacitor-plugin-hmsgms-checker
Capacitor plugin for checking HMS and GMS availability.
Only Android Platform is supported.
``bash`
npm install capacitor-plugin-hmsgms-checker@latest
Sync native files:
`bash`
npx cap sync
| Capacitor Version | Plugin Version | Install Command |
| --- | --- | --- |
| Capacitor V2 | 1.0.0 | `npm i capacitor-plugin-gmshms-checker@1` |`
| Capacitor V3 | 2.0.0 | npm i capacitor-plugin-gmshms-checker@2.0.0` |`
| Capacitor V4 | 2.1.0 | npm i capacitor-plugin-gmshms-checker@2.1.0` |`
| Capacitor V5 | 3.0.0 | npm i capacitor-plugin-gmshms-checker@3` |`
| Capacitor V6 | 6.0.0 | npm i capacitor-plugin-gmshms-checker@6` |`
| Capacitor V7 | 7.0.0 | npm i capacitor-plugin-gmshms-checker@latest` |
||||
Capacitor v2.x
`java
import com.angelcamacho.plugin.ServiceChecker;
public class MainActivity extends BridgeActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.init(
savedInstanceState,
new ArrayList
{
// Additional plugins you've installed go here
add(ServiceChecker.class);
}
}
);
}
}
`
Capacitor v3.x
`java
import com.angelcamacho.plugin.ServiceChecker;
public class MainActivity extends BridgeActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Additional plugins you've installed go here
registerPlugin(ServiceChecker.class);
}
}
`
Capacitor v4+
`java
import com.angelcamacho.plugin.ServiceChecker;
public class MainActivity extends BridgeActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
// Additional plugins you've installed go here, diffent order compared with capV3
registerPlugin(ServiceChecker.class);
super.onCreate(savedInstanceState);
}
}
`
In your android/build.gradle file add next lines in your buildscript > repositories and buildscript > dependencies entries.
`java`
buildscript{
repositories {
...
maven { url 'https://developer.huawei.com/repo/' }
}
dependencies {
...
classpath 'com.huawei.agconnect:agcp:1.9.0.300'
}
Then, in your allprojects > repositories entry add next line
`java`
allprojects {
repositories {
...
maven { url 'https://developer.huawei.com/repo/' }
}
}
In your android/app/build.gradle file add next line in your repositories entry
`java`
repositories {
...
maven { url 'http://developer.huawei.com/repo/' }
}
WARN: If your gradle version is ^7.x, add allowInsecureProtocol flag, so your build gradle should look like:
`java`
repositories {
...
maven {
url 'http://developer.huawei.com/repo/'
allowInsecureProtocol = true
}
}
> Your Android Gradle plugin must be 4.2.1 or later
Capacitor v2.x
`typescript
// Must import the package once to make sure the web support initializes
...
import 'capacitor-plugin-gmshms-checker';
import { Plugins } from "@capacitor/core";
const { ServiceChecker } = Plugins;
...
/**
* Platform: Android
* Gets true if GMS are available on the device
* @param none
* @returns object {value: boolean} - boolean indicates if GMS are available
*/
ServiceChecker.isGMSAvailable().then(({ value }) => {
// use value to do something
console.log(value);
});
/**
* Platform: Android
* Gets true if HMS are available on the device
* @param none
* @returns object {value: boolean} - boolean indicates if HMS are available
*/
ServiceChecker.isHMSAvailable().then(({ value }) => {
// use value to do something
console.log(value);
});
...
`
Capacitor v3+
`typescript
// Must import the package once to make sure the web support initializes
...
import { ServiceChecker } from 'capacitor-plugin-gmshms-checker';
import 'capacitor-plugin-gmshms-checker';
...
/**
* Platform: Android
* Gets true if GMS are available on the device
* @param none
* @returns object {value: boolean} - boolean indicates if GMS are available
*/
ServiceChecker.isGMSAvailable().then(({ value }) => {
// use value to do something
console.log(value);
});
/**
* Platform: Android
* Gets true if HMS are available on the device
* @param none
* @returns object {value: boolean} - boolean indicates if HMS are available
*/
ServiceChecker.isHMSAvailable().then(({ value }) => {
// use value to do something
console.log(value);
});
...
`
No more steps are needed. This plugin implements play-services-base version 18.1.0.
You may download the google-services.json file and copy it to android/app/ directory of your capacitor project.
No more steps are needed. This plugin implements hms:base version 6.5.0.300.agconnect-services.json
You may download the file and copy it to android/app/ directory of your capacitor project.
- ionic start my-cap-app --capacitorcd my-cap-app
- npm install --save capacitor-plugin-hmsgms-checker
- mkdir www && touch www/index.html
- npx cap add android
- npx cap sync android
- (every time you run npm install)npx cap open android
- google-services.json
- add or/and agconnect-services.json to your android/app folder
Now you should be set to go. Try to run your client using ionic cap run android --livereload --address=0.0.0.0`.
> Tip: every time you change a native code you may need to clean up the cache (Build > Clean Project | Build > Rebuild Project) and then run the app again.