Comments (20)
As far as I know, it's not possible to open a sub-page (e.g. Location Sevices) in the iOS settings app. The best that can be done, is to switch to the settings page for a specific app which is what switchToSettings()
does on iOS.
I don't know of any other apps that are able to do this, but it's possible Apple's own apps can do it since they have access to private APIs that the rest of us are not privileged to.
See stackoverflow discussions here and here
from cordova-diagnostic-plugin.
FYI, this is what I've done:
var confirm = $ionicPopup.confirm({
title: 'Location',
template: 'Enable locationservices?',
cancelText: 'Nope',
okText: 'Yup'
});
confirm.then(function (confirmed) {
if (confirmed) {
try {
if (ionic.Platform.isIOS()) {
cordova.plugins.diagnostic.switchToSettings();
} else {
cordova.plugins.diagnostic.switchToLocationSettings();
}
} catch (err) {}
}
});
On IOS 9.3 it takes me to the settings of the application.
from cordova-diagnostic-plugin.
There's at least one non-Apple app that I know of that can do that. "Speedtest" by Ookla is an example:
Maybe to much to ask from cordova-diagnostic-plugin to find the desired solution but I am just looking for ideas / alternatives since it does seem doable.
from cordova-diagnostic-plugin.
Interesting. It may be that it's possible but just not well documented (that would be very like Apple). The actual implementation to do it wouldn't be very hard, it just knowing what the appropriate URL string is to open... maybe a question on stackoverflow is in order...
from cordova-diagnostic-plugin.
I've had a quick glance at couple of SO threads but sadly nothing points to the right solutions. IMHO it'd be a much more user friendly way of achieving the goal as it is the page where one actually enables device location. Android beats it in this respect.
from cordova-diagnostic-plugin.
Ah, I think I understand. That dialog and it's buttons you showed in the screenshot are auto-generated by the iOS CLLocationManager (see here). Therefore it's using a private API which is not accessible to non-Apple apps. That dialog is shown in response to an app requesting to use location if location services is currently turned off. So it's not something the plugin can directly hook into to display the Location Settings page.
However, this dialog should be shown if you app requests a location and Location Services is switched off.
from cordova-diagnostic-plugin.
Other than via that auto-generated dialog, if you want the user to get to the Location Settings page, the best you can currently do on iOS is to popup a dialog instructing the user what to do, then use cordova.plugins.diagnostic.switchToSettings
to switch to the Settings app.
from cordova-diagnostic-plugin.
So, does cordova-diagnostic-plugin (or cordova-plugin-geolocation) actually have the capability to pop up the auto-generated dialog / uses the iOS CLLocationManager when needed?
Trying to connect end to end here...
from cordova-diagnostic-plugin.
You'd use cordova-plugin-geolocation
to request a position - if location services is turned off, this should result in displaying the system-generated dialog. See the example app source code for an example.
from cordova-diagnostic-plugin.
Sure @dpa99c , I'll give it a go again even though I went through that possibility by experimenting and don't actually remember the same kind of system dialog popping up.
Thanks or the help so far.
from cordova-diagnostic-plugin.
I basically came to the same conclusion when it comes to using cordova-plugin-geolocation's getCurrentPosition. Its error function will be called if Location Services are disabled at the moment of execution.
iOS doesn't pop any (desired) dialog with a Settings button in it.
Android behaves in the same way, except that as a mid step I get a dialog asking for a permission to use location. Naturally, even if I choose "Allow", the getCurrentPosition error function will be called since device location is off.
I can only see at this either as a deficiency or a bug in the cordova-plugin-geolocation plugin.
Feel free to close this discussion here. It's a real X-Files. I might write in the Cordova dev mailing list to see if anyone knows of a cure / way forward.
from cordova-diagnostic-plugin.
Yes, you're right, that actually is the behaviour of cordova-plugin-geolocation, come to think of it. And if you look at its iOS source code, you can see that if location services is turned off, it just raises an error without even trying to request a location via the location manager (which is what would trigger that dialog) - see here.
So it's not a bug, but intentional behaviour. If you want different behaviour, you'll either have to fork cordova-plugin-geolocation and change its behaviour, or create your own small plugin which makes a direct request to the native location manager to start updating location ([locationManager startUpdatingLocation]
), which will trigger the dialog. But I think this is beyond the scope of cordova-diagnostic-plugin.
from cordova-diagnostic-plugin.
Filed a feature request over at https://issues.apache.org/jira/browse/CB-10478
from cordova-diagnostic-plugin.
On IOS 9.3 it takes me to the settings of the application.
This is the expected behaviour. Note that (as I've said above): it's not possible to open a sub-page (e.g. Location Sevices) in the iOS settings app. The best that can be done, is to switch to the settings page for a specific app which is what switchToSettings()
does on iOS.
from cordova-diagnostic-plugin.
Yep it's a nice solution this way because the user will be able to allow locationservices for the app right away 👍
from cordova-diagnostic-plugin.
can any one suggest me , i am unable check location services in ios turn on or off using this plugin
from cordova-diagnostic-plugin.
@rojarohini it's not possible to programatically turn on/off Location Services on iOS or even open a sub-page (e.g. Location Sevices) in the iOS settings app. The best that can be done, is to switch to the settings page for a specific app which is what switchToSettings()
does on iOS.
Before doing so, you can instruct the user how to manually navigate and enable location for the app.
from cordova-diagnostic-plugin.
@dpa99c actually i want to know few things like
- Local Services settings in my ios mobile turn on or off.
- if off then i need to navigate to settings.
i have tried like switchToSettings() initially only without testing services on or off but not working, can you give me brief description and suggestion if i am trying any thing wrong.
from cordova-diagnostic-plugin.
@zarko-tg I got around to updating cordova-plugin-request-location-accuracy - v2.0.0 now enables a direct location request to be made which triggers the native iOS dialog.
from cordova-diagnostic-plugin.
Much appreciated @dpa99c, I should be trying it out soonish.
from cordova-diagnostic-plugin.
Related Issues (20)
- IOS - isCameraRollAuthorized return "[NSNull isEqualToString:]: unrecognized selector sent to instance" HOT 1
- When installing with lerna no dependency is added
- getBluetoothAuthorizationStatus wrong example HOT 2
- Workaround for Location Auth Status being DENIED_ALWAYS HOT 2
- isRequestingPermission() Always returns false for location
- Support Android 13/API 33 media storage permissions HOT 3
- Permission error HOT 1
- getExternalSdCardDetails for android 13 HOT 2
- No working POST_NOTIFICATIONS HOT 3
- getLocationAuthorizationStatus not working on android 13 with ionic cordova production builds HOT 1
- getBluetoothState() returns OK in SDK 33 even though bluetooth is not enabled/disabled HOT 1
- Android build Error HOT 2
- Storage permission Issue on Android after updating to API 33 HOT 2
- Android Permission for Notification asking in Runtime in Android 13 HOT 1
- cordova diagnostic plugin requestExternalStorageAuthorization is returning DENIES_ALWAYS HOT 1
- Android < 13 ACCESS_BACKGROUND_LOCATION is automatically granted despite it's not true HOT 1
- Specifying modules issue HOT 5
- USB debugging detection is bypassed using the FRIDA tool and some other Root management apps
- requestCalendarAuthorization() always returns DENIED_ALWAYS HOT 2
- Health Connect Authorization
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cordova-diagnostic-plugin.