npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

capacitor-plugin-gmshms-checker

v6.0.0

Published

Capacitor plugin to check GMS and HMS availability

Downloads

284

Readme

capacitor-plugin-hmsgms-checker

Platforms Support

Only Android Platform is supported.

Installation

Using npm:

npm install capacitor-plugin-hmsgms-checker@latest

Sync native files:

npx cap sync

Version Compatibility

On capacitor v6 migration, no breaking changes are reported, but major number version jump to 6 to better understanding of this plugin-capacitor compatibility.

| 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 [email protected] | | Capacitor V4 | 2.1.0 | npm i [email protected] | | Capacitor V5 | 3.0.0 | npm i capacitor-plugin-gmshms-checker@3 | | Capacitor V6 | 6.0.0 | npm i capacitor-plugin-gmshms-checker@latest | ||||

On Android, register the plugin in your main activity:

Capacitor v2.x

import com.angelcamacho.plugin.ServiceChecker;

public class MainActivity extends BridgeActivity {

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.init(
        savedInstanceState,
        new ArrayList<Class<? extends Plugin>>() {
          {
            // Additional plugins you've installed go here
            add(ServiceChecker.class);
          }
        }
      );
  }
}

Capacitor v3+

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+

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);
  }
}

Configuration

In your android/build.gradle file add next lines in your buildscript > repositories and buildscript > dependencies entries.

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

allprojects {
    repositories {
        ...
        maven { url 'https://developer.huawei.com/repo/' }
    }
}

In your android/app/build.gradle file add next line in your repositories entry

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:

repositories {
    ...
    maven {
      url 'http://developer.huawei.com/repo/'
      allowInsecureProtocol = true
    }
}

Your Android Gradle plugin must be 4.2.1 or later

Usage

Capacitor v2.x

// 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+

// 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);
});

...

For Google

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.

For Huawei

No more steps are needed. This plugin implements hms:base version 6.5.0.300. You may download the agconnect-services.json file and copy it to android/app/ directory of your capacitor project.

Android setup

  • ionic start my-cap-app --capacitor
  • cd 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
  • add google-services.json 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.