Cordova Dialog Gps - Devpost
Cordova Dialog Gps - Devpost
Cordova Dialog Gps - 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