# cordova-plugin-gps-dialogs

> Cordova GPS Dialog Plugin

Latest version **1.0.2** (published 2019-01-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install cordova-plugin-gps-dialogs
pnpm add cordova-plugin-gps-dialogs
yarn add cordova-plugin-gps-dialogs
bun add cordova-plugin-gps-dialogs
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2019-01-08 |
| First published | 2019-01-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 81.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Lakshman S |
| Maintainers | cetaslash |
| Keywords | cordova, ecosystem:cordova, cordova-android, gps |

## Links

- npm: https://www.npmjs.com/package/cordova-plugin-gps-dialogs
- Repository: https://github.com/CetasLakshman/cordova-plugin-gps-dialogs
- Homepage: https://github.com/CetasLakshman/cordova-plugin-gps-dialogs#readme
- Issues: https://github.com/CetasLakshman/cordova-plugin-gps-dialogs/issues
- npm.io page: https://npm.io/package/cordova-plugin-gps-dialogs

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2019-01-08
- 1.0.1 — 2019-01-02
- 1.0.0 — 2019-01-02

## 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*
  ```javascript
  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)](img/Screenshot-default-lollipop.png)

## 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:

```javascript
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:

```javascript
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)](img/Screenshot-custom-lollipop.png)

## License

This plugin was created under the MIT license.

---
_Source: https://npm.io/package/cordova-plugin-gps-dialogs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
