The output geo coordinates are only accurate on first load, the problem is when the iPhone screen times out and the locations services also timeout. And if I open safari again the geo coordinates are off by 100's of meters. The same thing happens if I push safari app to background. The problem is fixed if I reload the safari tab requesting geolocation or if I clear safari app cache and open up safari again. Why is this happening? My use case involves showing the user an arrow that guides to destination. Thus it is likely the phone times out occasionally for user that leads to location services timeout. iOS chrome does not mimic this behavior and work as expected i.e geo coordinates are always accurate event after tab in focus and /or screen timeout.
I don't know why this happens exactly, but it's happening to me too. I was able to get around the issue by using window.setInterval to call a function every 5 seconds or so that checks whether the location has been updated. If it hasn't, then the function stops and restarts the geolocation watch.
The restarting of the geolocation watch has the same effect as reloading the page, i.e. the accuracy becomes much better again, and location updates resume. Hope that helps!
Related
I am trying to detect iBeacons from a App Killed state on iOS 7.1 + devices . On certain devices (not a specific phone model) the app works without a glitch.
However on some devices the app does not detect the beacons . I have double check the settings on those devices such as location services , permissions, background app fetch , bluetooth etc.
I have enabled "notifyEntryStateOnDisplay" as well . Therefore I am testing by locking the device and turning it back on . However certain devices does detect the beacon.(The battery was full as well).
I thought "notifyEntryStateOnDisplay" will cause to detect iBeacons everytime I turned the device on. What I am missing here ?
The notifyEntryStateOnDisplay option is designed to give you an extra callback to didDetermineState:forRegion: when the user hits the shoulder button to turn on the display. That callback may not happen when the phone first boots up. In fact, my tests show that CoreLocation isn't even active for the first 60 seconds or so after the display first comes on.
A couple of things to check:
Make sure that your logic is inside didDetermineState:forRegion: and not didEnterRegion: or didExitRegion:.
When you boot up, wait 60 seconds before hitting the shoulder button and expecting results.
I'm developing an iOS map application, so it's essential to receive location data consistently.
What is happening now is that the system allows the to app load the map and that's it!
The location getting instruction seems to freeze, even the network traffic indicator at the top bar disappears. Simply when I go to Settings->Privacy->Location Updates, switch off location updates for my app and then switch it back on. The map loads the current location.
What could be the possible causes to this?, please advice.
Use:
[_mapView setUserTrackingMode:MKUserTrackingModeFollow animated:YES];
This will smoothly follow the users current location. If you drag the map it will even set the tracking mode back to MKUserTrackingModeNone which is usually the behaviour you want.
I built this app which is tracking the users position even when running in background. I use the CLLocationManagers method
startUpdatingLocation
I set the CLLocationManager to
desiredAccuracy=kCLLocationAccuracyNearestTenMeters
distanceFilter=250
Everything works fine in foreground and in background. But when I don't move the device for a longer period (hours) I can see that the location arrow disappears. When I switch back to my app I can see that the arrow comes back immediately and that the app did NOT crash. Is this a "feature" of the LocationManager I don't know? Did the LocationManager went into some kind of "standby"? This should NOT be an issue with the app running not in foreground since I can travel with it for an hour and it gives me a perfect track.
Yes, this is a feature. As given in the documentation location manager object manages power aggressively by turning off hardware when it is not needed. Turning off GPS hardware can lead to significant power savings.
First of all I hope don't repeat any topic, I have spent a lot of time reading on internet about this before ask.
I'm developing an app for iOS => 5 and I need get the user location, but I don't need always a great accurate position, so when the app goes to background I change the normal location mode to Significant Location Changes and when the app come to foreground I stop the significant location change mode and get back the normal location mode, that's all goes fine,
my problem is when the app goes to background mode or even the user KILL the app the GPS signal (the purple arrow) still appear ALWAYS, even after restart the device, the only way to make disappear it is un-installing the or disabling the significant location changes when the app goes to background, but I need this mode working when the user goes to background mode, maybe not when the app is killed.
I don't know how to stop the service when the user kill the app... because event "applicationWillTerminate" is not called if you have multitask ON.
My main reason because I don't want the purple arrow appear always, even the app is killed is because I don't want the user think the app is drying the battery... so the user won't want the app installed.
First question: Is normal that the purple arrow appear always, even the app is killed if the Significant location change is enabled for the app?
Second question: Is any way to change this, to stop the service at least when the app is killed to hide the purple arrow?
Thank you all.
Sorry for my english if something is wrong.
After few days researching to be sure about this service, seems like there is NO way to use significant locations change in the background without the arrow in the top bar. I have been testing with different apps and reading through internet and nothing to solve this.
The only ""way to solve"" this is disable multitask mode in the app and disable the significant locations change in the event "applicationWillTerminate" but don't make sense... I'm losing the background location always not only when the app is killed... so is not useful.
It's bad... is a really good service to get locations saving battery but as user and developer I don't want an app that make appear this icon ALWAYS even after the app is killed, as developer I don't want that people uninstall the app for this reason and as normal user I don't know what mean this icon if is normal GPS or Significant locations change and what mean this... if my battery is being drain or not.
The other option to get locations in background task but has a big impact over the battery....
I hope apple fix this in future versions... adding at least a new arrow or showing only when a new location arrive instad of always or allowing to stooped when the app is killed.
All this has been researched over iOS - 6.1
Thanks to all.
When you use the significant location change service, the OS keeps your app running. If the app is in the background and is killed, the OS restarts it, so the purple arrow will always show. When a new location is detected, the app is restarted. From the docs:
If you leave this service running and your app is subsequently suspended or terminated, the service automatically wakes up your app when new location data arrives. At wake-up time, your app is put into the background and given a small amount of time to process the location data. ... To stop the significant change location service, call the stopMonitoringSignificantLocationChanges method.
Hmmm, interesting. I've just seen that problem with another app - seeing the arrow still active made me want to disable location updates for that app so the problem is real. Best thing I can think of is to have some kind of timer to disable the location monitoring after a certain amount of time if that is appropriate for your app.
How is it possible to wake the application from code?
I am writing a simple timer and when time goes out it displays picture on main activity. But this means that application should stay on screen all the time. If user switches to another app (or simply presses Home) my Activity is no longer visible and I need to show it on screen again (switch back to my application) in the way similar to standard Android Phone or Timer pops up.
So there actually are 2 questions:
How to get application on "top" of screen?
How to correctly display application when screen is locked?
For that you would need a service that starts your activity when that timer triggers.
You can take a look at the Android Alarm Clock source code for how to have an Activity Shown even on the lock screen: https://github.com/android/platform_packages_apps_alarmclock/blob/master/src/com/android/alarmclock/AlarmAlertFullScreen.java
Note especially lines 85 to 90, here flags are added so that it is allowed to be shown on the Lock Screen. This should of course work with Mono for Android as well.
There is also a nice answer here to your questions: Wake Android Device up
It should be fairly easy to port to Mono for Android.