0% found this document useful (0 votes)
126 views6 pages

Cordova Dialog Gps - Devpost

This plugin displays a dialog and redirects to GPS settings when GPS is disabled on Cordova/Phonegap apps. It can be installed via the Cordova plugin system. The plugin exposes a cordova.dialogGPS object that can display a basic or customized dialog. It was created for both Android and iOS using JavaScript and is released under an MIT license.

Uploaded by

madpop
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
126 views6 pages

Cordova Dialog Gps - Devpost

This plugin displays a dialog and redirects to GPS settings when GPS is disabled on Cordova/Phonegap apps. It can be installed via the Cordova plugin system. The plugin exposes a cordova.dialogGPS object that can display a basic or customized dialog. It was created for both Android and iOS using JavaScript and is released under an MIT license.

Uploaded by

madpop
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

2/2/2017 cordovadialoggps|Devpost

Jobsnyc
TheCommit
Hackathons
Login
Signup

Jobsnyc
TheCommit
Hackathons

Login
Signup
https://devpost.com/software/cordovadialoggps 1/6
2/2/2017 cordovadialoggps|Devpost

cordovadialoggps
Pluginforphonegap/cordovatodisplayadialogandredirecttoGPSsettingswhendeGPSisdisable.

Like1
Comment1

Story

Updates

cordovadialoggps
Pluginforphonegap/cordovagreaterorequalthanv3.0.0todisplayadialogandredirecttoGPSsettingswhen
deGPSisdisable.

Installation
JusttypethefollowingstatementinyourcliCordovaorphonegap.

phonegappluginaddhttps://github.com/rodrigomartinezd/cordovadialoggps.git

orcordovapluginaddhttps://github.com/rodrigomartinezd/cordovadialoggps.git

ifyouwanttoinstallaspecificversionjustadd#v<version>tothelink

Example:

phonegappluginaddhttps://github.com/rodrigomartinezd/cordovadialoggps.git#v0.0.1

Use
Afterinstallation,youcanaccesstheobjectdialogGPSembeddedincordova

document.addEventListener("deviceready",function(){
/**
*@parammessage{string}messagetobedisplayed.
*@paramdescription{string}descriptionofthepropertiethatyouwantchange.
*@paramcallback{function}callbackfunctiontosendtheindexwhenabuttonispressed
*@paramtitle{string}titleofdialog
*@parambuttons{array}arraywiththebuttonsnameswithamaxthreenames.
**/
cordova.dialogGPS("helloworld",function(buttonIndex){
//dosomethingwiththebuttonIndex
});
});

Remember:Remember,theobjectcordova.dialogGPScanonlybeaccessedafterthedocumentisfullycharged.
Thisoccurswhendevicereadyiscalled.Thereforeitisrecommendedtomakethecalltotheobjectwithinthis
function.

Ifcordova.dialogGPS()wascallwithoutoptionsthiswillberesulttoadefaultmessage.Ifyouwantto
customizeit,youcanpassedoptionstotheconstructor.

https://devpost.com/software/cordovadialoggps 2/6
2/2/2017 cordovadialoggps|Devpost

Defaultdialogonandroid5.0.2

screenshotonlollipop(android5.0.2)

Options
Message

Firstargument,astringwiththetexttodisplayinthedialog.

DescriptionSecondargument,isthetextnexttotheiconoflocation.

Callbackfunction

Ifyoulikeusecallbacksfunctions.Youcanpassacallbackfunctionasthethirdargument.Thiswillresultafter
captureaclickeventinthedialog:

0,ifthecancelbuttonorthenegativebuttonwaspressed.
1,iftheneutralbuttonwaspressed.
2,ifthepositivebuttonwaspressed.

Title

Thetitleofdialogindicatedwithastringasthefourthargument.

Buttons'sArray

ThebuttonsLabelsarrayasthefifthargument,withthenameoftheeachbuttontobedisplayedinthedialog.
Thenamesmustfollowthenextorder:Negativebutton,Neutralbutton(optional),positivebutton.

Example:["Cancel","Later","GotoSettings"]

SomeExamples
YoucanintegratethepluginwithgeolocationpluginfordoingthatjustwrappedthecalltodialogGPSina
functionandcalledfromtheerrorcallbackfromgeolocation.

code:

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

functioncalldialog(){
document.addEventListener("deviceready",function(){
//defaultdialog
cordova.dialogGPS();
});
}

Hereisanexamplewithalltheargumentspassed:
functioncalldialog(){
document.addEventListener("deviceready",function(){
cordova.dialogGPS("YourGPSisDisabled,thisappneedstobeenabletoworks.",//message
"UseGPS,withwifior3G.",//description

https://devpost.com/software/cordovadialoggps 3/6
2/2/2017 cordovadialoggps|Devpost

function(buttonIndex){//callback
switch(buttonIndex){
case0:break;//cancel
case1:break;//neutrooption
case2:break;//usergotoconfiguration
}},
"PleaseTurnonGPS",//title
["Cancel","Later","Go"]);//buttons
});
}

Thecodeaboveresultinthisdialog:

customdialogonlollipop(android5.0.2)

License
ThispluginwascreatedundertheMITlicense.

BuiltWith
java
javascript

Tryitout
GitHubRepo

Createdby

NishantSharma

Master'sStudentatSanJoseStateUniveristy

Like1
1personlikesthis:

Sharethisproject:
https://devpost.com/software/cordovadialoggps 4/6
2/2/2017 cordovadialoggps|Devpost

Updates

NishantSharmastartedthisprojectaboutayearago

Leavefeedbackinthecomments!

alfredmosima9monthsago

Wowthanksibeenstrugglinguntilifoundthisitworkedwithnohassles.fewquestions...isthis
supportedforandroidandios?willitworkforallandroidversionsorwhat?

LoginorsignupforDevposttojointheconversation.

Devpost

About
Ourdevteam
Careers
Contact
Help

Jobs

https://devpost.com/software/cordovadialoggps 5/6
2/2/2017 cordovadialoggps|Devpost

Browsejobs
Employers
Jobadvice

Hackathons

Browsehackathons
Exploreprojects
Hostaninpersonhackathon
Hostanonlinehackathon
Hackathonbestpractices

Connect

Legal

Privacypolicy
CommunityGuidelines
Termsofservice

https://devpost.com/software/cordovadialoggps 6/6

You might also like