Comments (11)
I tried
var locationEnabled;
function checkLocationState(){
cordova.plugins.diagnostic.isLocationEnabled(function(enabled){
locationEnabled = enabled;
}, onError);
}
document.addEventListener('resume', checkLocationState, false);
document.addEventListener('deviceready', checkLocationState, false);
but on coming back it does not trigger the resume event.
Now for the purpose of solution, i am putting a hack, like adding a timer in the app to check wheather location is on or not.
I am using ionic framework
Regard
Shakti
from cordova-diagnostic-plugin.
Solution: https://www.npmjs.com/package/cordova.plugins.diagnostic#registerlocationstatechangehandler
from cordova-diagnostic-plugin.
I could extend switchToLocationSettings to support a Javascript success callback, however when switchToLocationSettings() is called, the Cordova app is switched out into the background when the settings app is switched into the foreground, so the callback wouldn't be executed until the Cordova app is resumed. And in which case, you may as well re-check the location settings when the Cordova app is resumed; this will then also work if the user manually puts your app in the background (e.g using Home button), changes the location settings then returns to your app (this is the approach I've used in my apps).
For example:
var locationEnabled;
function checkLocationState(){
cordova.plugins.diagnostic.isLocationEnabled(function(enabled){
locationEnabled = enabled;
}, onError);
}
document.addEventListener('resume', checkLocationState, false);
document.addEventListener('deviceready', checkLocationState, false);
Note that on Android it's possible to change location settings without putting the app into the background using the quick settings menu via the status bar pull down. Because the app remains in the foreground, the resume event is not fired, so your app may remain unaware of the change. The approach I've taken in my apps is to re-check the location settings state after the first call to the positionError handler function for navigator.geolocation.watchPosition. This way, if the user turns off location settings while the app is in the foreground, the positionError handler will be called and my app will pick up the changed setting.
from cordova-diagnostic-plugin.
Is this still an issue or can it be closed?
from cordova-diagnostic-plugin.
On hitting back button from location screen button, does not trigger any resume and deviceready event, Event i didnt get call back
cordova.plugins.diagnostic.switchToLocationSettings(function(success){ console.log(success);
}, function(error){
console.error("The following error occurred: "+error);
});
It is not solved yet. Although on registring for the ready and resume event open it on the application open.
Please suggest some help.
Thanks in advance.
from cordova-diagnostic-plugin.
Following back button in the bottom will be tigger any thing.
How to i handle it that the back button is pressed.
resume and deviceready event is not fired on hitting the back button.
Please Help.
from cordova-diagnostic-plugin.
@paulogr Plz help and open this issue.
from cordova-diagnostic-plugin.
@Shakti-Sharma This issue is resolved: as explained above, the switchToLocationSettings()
function does not accept a callback function as a parameter due to the fact that the app will be immediately paused when the function is called, so the callback would not be executed until the app is resumed. And therefore, you may as well use the Cordova "resume" event to be notified. Using the back button in Android to return to the app does cause Cordova to fire the "resume" event as Android restores the activity to the foreground. For reference, please see the example project which makes use of the resume event in this way.
from cordova-diagnostic-plugin.
I am having same issue with iOS, I am listening for both "resume" and "deviceReady" events but none of the are triggered if user uses back button from settings, although it does triggered if users go to recent app and then selects app.
from cordova-diagnostic-plugin.
@littlegit That was the solution. Thanks!!!!
from cordova-diagnostic-plugin.
@littlegit sir i will check but after click mobile back button registerLocationStateChangeHandler is not trigger in my case ?
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.