I am experimenting with tabris and am looking into the geo api at the moment.
I am able to get my current position from the Geolocation class via getCurrentPosition(). My problem is that i don't want to perform pull requests all the time to get geo updates.
Instead i would like to get notified of position changes whenever the user moves his device.
To get notified about your location change, just use the method Geolocation.watchPosition() to add a Listener. This can then be used e.g. to update the UI.
Related
Using Apples MapKit API, is there a way to add a listener to determine if the user's current location has changed? Is it also possible to do this in the background while the app is not running?
Please see this post for listener to determine user's location change. This is not possible to be done in background. In iOS, when your app is not running, it cannot report location or anything.
I have an app where I create events. I need to get user's location when the event is ending automatically (set by user while creating event). I tried local notification but in that case, you need to wait for user's interaction and that can cause delay as user might not click right away.
I want user's exact location at a specific time regardless of the state of the app (foreground, background or not running). Let me know if you need any further clarification. Also, any document, tutorial or code will be highly appreciated. Thanks.
I need to track users first and last coordinates scheduled.
For example:
I set to track location from 10.00AM to 12.00AM and I need to store first location(at 10.00AM) and last location(at 12.00AM). I try to use background fetch, but I havent idea to make that work.
I need only this two points. How I can take them?
I cant use server and notifications
Use a silent push notification to trigger background processing, then starting location updates might work.
You'd need get permission from the user to get location updates always, and you'd need to request background time when the push notification came in.
This is my scenario: I need to get the user's current location punctually in order to show them a set of nearby points of interest in an MKMapView. I don't need to keep track of user's location. I need someone to clarify which the best way to do this should be:
1) ASFAIK, is it possible to get the current location by calling mapItemForCurrentLocation. You get an MKMapItem object, and I think that this call does not need to have the location services enabled, but I'm not sure if it is possible to get the coordinates for the location this way... is it?
2) Start a CLLocationManager and listen for location updates. And then just take the first location received and stop listening.
I need this to work for iOS 7+
Thanks
For an MKMapView object to be showing user location you will have to have requested authorisation for iOS8 (ie using requestWhenInUseAuthorization on a CLLocationManager object).
MKMapView objects have a didUpdateUserLocation: delegate method you could use receive user location updates, but this may fire off repeatedly until it reaches the accuracy the map requires - you might need to ignore later updates depending on what you're doing.
Based on your scenario it could be better to use CLLocationManger, then stop requesting updates once you have a fix of required accuracy.
I want implement a geo location notification in iOS, but just in a specific date and time.
The notification will only be launched if the user is in a certain location and at a certain date and time.
Ex.: The user is in Rio de Janeiro and is 12 o'clock.
Does anyone know how to merge these two conditions to launch a notification?
There is nothing built in that I know of -- you will have to code the logic yourself. So you will simply get geo updates from CoreLocation, and you can create a timer to give you time updates, then write some logic that execs periodically and, if the time/place matches your business rules, fire the notification. Note that the app will have to be running to accomplish this. You could send a push notification from an external server, but that server must know where the phone is, and your app must tell it.
Does this help?
It seems that this can be done elegantly as long as location updates are given precedent.
Use this CoreLocation startMonitoringSignificantLocationChanges
To get updates about location, and these updates will be able to start your app in the background (as explained in the docs). Then, in the "application:didFinishLaunchingWithOptions" method of your AppDelegate, include your logic for checking if it is the right time to send a notification (by checking with stuff in CoreData or otherwise).
There shouldn't be a need to create a timer with periodic checks. Just let CoreLocation handle the event's entry point since it'll launch your app in the background at the right location.
This is simple. I assume that you are familiar using the CLLocationManager and the MKReverseGeocoder classes. For your purpose monitoring for only significant location changes would probably be fine (even if that sometimes only happens for moving kilometers). It will help you save battery power on the device.
So, for CLLocationManager's delegate there is a method called locationManager:didUpdateToLocation:fromLocation what you can use. All you need to do is to use reverse geocoding here to determine the actual city's name depending the actual location using the MKReverseGeocoder class. Also, you have to check the local time on the device, match the two, and act accordingly (set up a local notification to wake the app from the background for example).