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

cordova-plugin-gps-dialogs

v1.0.2

Published

Cordova GPS Dialog Plugin

Downloads

9

Readme

cordova-plugin-gps-dialog

Plugin for cordova greater or equal than v3.0.0_ to display a dialog and redirect to GPS settings when de GPS is disable.

Installation

Just type the following statement in your cli Cordova for install.

cordova plugin add https://github.com/CetasLakshman/cordova-plugin-gps-dialogs.git

if you want to install a specific version just add #v<version> to the link

Example:

cordova plugin add https://github.com/CetasLakshman/cordova-plugin-gps-dialogs.git#v0.0.1

Use

After installation , you can access the object dialogGPS embedded in cordova

document.addEventListener("deviceready",function() {
  /**
  * @param message {string}       message to be displayed.
  * @param description {string}   description of the propertie that you want change.
  * @param callback {function}    callback function to send the index when a button is pressed
  * @param title {string}         title of dialog
  * @param buttons {array}        array with the buttons names with a max three names.
  **/
  cordova.plugins.dialogGPS("hello world",function(buttonIndex) {
        //do something with the buttonIndex
    });
});

Remember: Remember, the object cordova.plugins.dialogGPS can only be accessed after the document is fully charged . This occurs when deviceready is called. Therefore it is recommended to make the call to the object within this function .

If cordova.plugins.dialogGPS() was call without options this will be result to a default message. If you want to customize it, you can passed options to the constructor.

Default dialog on android 5.0.2

screenshot on lollipop (android 5.0.2)

Options

Message

First argument, a string with the text to display in the dialog.

Description Second argument, is the text next to the icon of location.

Callback function

If you like use callbacks functions. You can pass a callback function as the third argument. This will result after capture a click event in the dialog:

  • 0, if the cancel button or the negative button was pressed.
  • 1, if the neutral button was pressed.
  • 2, if the positive button was pressed.

Title

The title of dialog indicated with a string as the fourth argument.

Buttons's Array

The buttonsLabels array as the fifth argument, with the name of the each button to be displayed in the dialog. The names must follow the next order: Negative button,Neutral button(optional),positive button.

Example: ["Cancel","Later","Go to Settings"]

Some Examples

You can integrate the plugin with geolocation plugin for doing that just wrapped the call to dialogGPS in a function and called from the error callback from geolocation.

code:

navigatior.geolocation.getCurrentPosition(function(position){},function(error){
  calldialog();
});

function calldialog() {
  document.addEventListener("deviceready",function(){
    //default dialog
    cordova.plugins.dialogGPS();
  });
}

Here is an example with all the arguments passed:

function calldialog() {
 document.addEventListener("deviceready",function() {
  cordova.plugins.dialogGPS("Your GPS is Disabled, this app needs to be enable to works.",//message
                    "Use GPS, with wifi or 3G.",//description
                    function(buttonIndex){//callback
                      switch(buttonIndex) {
                        case 0: break;//cancel
                        case 1: break;//neutro option
                        case 2: break;//user go to configuration
                      }},
                      "Please Turn on GPS",//title
                      ["Cancel","Later","Go"]);//buttons
 });
}

The code above result in this dialog:

custom dialog on lollipop (android 5.0.2)

License

This plugin was created under the MIT license.