Giter Site home page Giter Site logo

hasib2cool / cordova-plugin-google-play-services-checker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pavelety/cordova-plugin-google-play-services-checker

0.0 1.0 0.0 14 KB

Cordova/Ionic/Phonegap plugin for checking that the Google Play Services are installed, updated and enabled

License: MIT License

JavaScript 11.15% Java 88.85%

cordova-plugin-google-play-services-checker's Introduction

#Cordova Plugin Google Play Services Checker Cordova/Ionic/Phonegap plugin for checking that the Google Play Services are installed, updated and enabled on Android device.

#Why Users' Google Play Services should be updated if you want to have more accurate and fast GPS. There is a native way to check and update it. No need to ask user to do it manual, just install this plugin.

#Installation The plugin can be installed via Cordova-CLI and is publicly available on NPM.

Execute from the project root folder:

$ cordova plugin add cordova-plugin-google-play-services-checker

Or with Ionic

$ ionic cordova plugin add cordova-plugin-google-play-services-checker

#Usage The plugin creates the object GooglePlayServicesChecker, and it's accessible after deviceready has been fired.

document.addEventListener('deviceready', function () {
  var success = function(installedAndUpdated) {
    if (installedAndUpdated.status) {
      console.log('Google Play Services is installed and updated');        
    } else {
      console.log('Showing user native update window');
    }
  } 
  var failure = function(reason) {
    console.error('error: ' + reason)
  }
  GooglePlayServicesChecker.check(success, failure);
})

Or for Ionic-v4:

import { Platform } from '@ionic/angular';
@Component({...})
export class MyPage {
  constructor(public platform: Platform) {
    platform.ready().then(() => {
      var success = function(installedAndUpdated) {
        if (installedAndUpdated.status) {
          console.log('Google Play Services is installed and updated');        
        } else {
          console.log('Showing user native update window');
        }
      } 
      var failure = function(reason) {
        console.error('error: ' + reason)
      }
      GooglePlayServicesChecker.check(success, failure);
    });
  }
}

Or enhanced example for Ionic-v1:

  var googlePlayCheckedAndInstalled=false;
  function googlePlayCheck() {
    if (window.cordova && !googlePlayCheckedAndInstalled) {
      var success = function (installedAndUpdated) {
        console.log('Google Play Services success: ', installedAndUpdated);
        if (installedAndUpdated.status) {
          console.log('Google Play Services is installed and updated');
          googlePlayCheckedAndInstalled = true;
        } else {
          console.log('Trying to show user native update window');
        }
      }
      var failure = function (reason) {
        console.error('Google Play Services error: ' + reason)
      }
      GooglePlayServicesChecker.check(success, failure);
    }
  }

  googlePlayCheck();
  $ionicPlatform.on('resume', function () {
    googlePlayCheck();
  });

cordova-plugin-google-play-services-checker's People

Contributors

hasib2cool avatar pavelety avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.