Wednesday, March 4, 2015

Enable iPhone Location Services using Confirmation Settings alert Message in phonegap

I am working in phonegap application. I want to track the user using GPS lat long based. If there is GPS Setting Disabled. What I want to do is provide a link from the App to “Settings - > Location Services"


navigator.notification.confirm(
                                   'Oops! Failed to Location services to BOSS system, Check your GPS connection ?',  // message
                                   onConfirmGPS,              // callback to invoke with index of button pressed
                                   'Enable GPS Settings',            // title
                                   'Settings,Cancel'          // buttonLabels
                                   );


Edit: you should also be able to specify where in the settings application by using that type of URL, just to clarify.



function onConfirmGPS(buttonIndex)
{
    if(buttonIndex==1)
    {
        window.location="prefs:root=LOCATION_SERVICES;

        }

}


Follow the above procedure for GPS settings in Phonegap. Similarly follow the same procedure for other URL settings provided blow.

prefs:root=General&path=About
prefs:root=General&path=ACCESSIBILITY
prefs:root=AIRPLANE_MODE
prefs:root=General&path=AUTOLOCK
prefs:root=General&path=USAGE/CELLULAR_USAGE
prefs:root=Brightness
prefs:root=General&path=Bluetooth
prefs:root=General&path=DATE_AND_TIME
prefs:root=FACETIME
prefs:root=General
prefs:root=General&path=Keyboard
prefs:root=CASTLE
prefs:root=CASTLE&path=STORAGE_AND_BACKUP
prefs:root=General&path=INTERNATIONAL
prefs:root=LOCATION_SERVICES
prefs:root=ACCOUNT_SETTINGS
prefs:root=MUSIC
prefs:root=MUSIC&path=EQ
prefs:root=MUSIC&path=VolumeLimit
prefs:root=General&path=Network
prefs:root=NIKE_PLUS_IPOD
prefs:root=NOTES
prefs:root=NOTIFICATIONS_ID
prefs:root=Phone
prefs:root=Photos
prefs:root=General&path=ManagedConfigurationList
prefs:root=General&path=Reset
prefs:root=Sounds&path=Ringtone
prefs:root=Safari
prefs:root=General&path=Assistant
prefs:root=Sounds
prefs:root=General&path=SOFTWARE_UPDATE_LINK
prefs:root=STORE
prefs:root=TWITTER
prefs:root=General&path=USAGE
prefs:root=VIDEO
prefs:root=General&path=Network/VPN
prefs:root=Wallpaper
prefs:root=WIFI
prefs:root=INTERNET_TETHERING

2 comments:

  1. It works~ Thanks
    BTW, how did u find this solution?

    ReplyDelete
    Replies
    1. I fount from stackoverflow (http://stackoverflow.com/questions/8246070/ios-launching-settings-restrictions-url-scheme) actually i tried many option and also i created own plugin but didn't work.

      Delete