Can I make iphone app that get coords from gps in 2 seconds and save them in file. In the end of the day I should send via mail?
You cannot tell the Core Location framework to alert your app every 2 seconds with GPS information. Your app can use the Significant-Change Location Service. So if the device is in a car on the highway, that could well be every 2 seconds. But if the device is traveling by foot, then that depends on how fast the user is walking. Then you can use a Local Notification to alert the user and bring the app from the background at the end of the day.
You can never have GPS location in 2 seconds, only the coordinates from triangulation of wifi signals.
You never know how long the device would take to detect the user's location.
You can of course make an app which should check the user's accurate location and then write it to plist and later whenever you planned to share it via email or any other source, you should able to share it easily.
To get the user's most accurate location look up for the accuracy property in CoreLocation framework. If you considering time limit just for the sake that the user need not to wait until the app gets the accurate location, then you should use background location service introduced in iOS 4.0.
Related
For Example, I travel from San Diego to La, I want the iPhone to track how long it was from San Diego to La and tell me the result?
When your app is in the background it could still receive location info when there is a significan location change such as new cell tower. Your app could monitor the significan location changes as well as regular gps when it's available and calculate the time difference.
Check out Starting the Significant-Change Location Service
http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/LocationAwarenessPG/CoreLocation/CoreLocation.html#//apple_ref/doc/uid/TP40009497-CH2-SW10
Also this is a good tutorial for using significan time change notifications:
http://www.mindsizzlers.com/2011/07/ios-background-location/
For basic MapKit usage check out this tutorial.
You can use CoreLocation to track the phone with GPS, storing the position every so often (either do it every X minutes, or every X miles/degrees-latitude-longitude.
The CLLocationManager class is what you want, most likely. You give it a delegate that receives events, and start it polling. To conserve battery, you don't necessarily want it to be polling continuously, but you can set it up to automatically turn off and then back on again in a little while.
Displaying it on a map is slightly more complicated, but still quite easy to do. If you need Geocoding, you'll probably need to use the Google Maps API.
I am developing an iphone app. the iphone which install my app was asked to upload it's location every minute(or hour) to a webservice. So what should i do with this situation?
I know there is a corelocation framework, I could use it for my app. like when I run this app, the corelocation will grab the GPS for my. my question is what if I close the app? Can i still get the GPS and upload it to webservice every minute? If I can't, how could I ?
You could enable background location service, If application is in background and receives a considerable change in location it will activate the app for a brief amount of time, This will give you some time to process. Apple recommends not to use web-service calls during this time, because there wont be any guarantee that the app would be live when it returns back. But since you just want to update the location, you could just post it and dont have to wait for response. Please note that significant location change should be used and this will help you to save your device's battery life. This is when the app is in background state.
May be you could try registering for the proximity/location alert or something. But i am not sure whether it would help when app is closed.
If your app is running in the background then you can get the GPS data but it the application is removed from the Background then you cannot get the GPS data. This is not possible in iPhone.
I was wondering if it was possible to get the location of the iPhone with an app that isnt running, or at least running in the background. What I want to do is have the iPhone send a push notification when it arrives at a certain coordinate. Is this possible? If so, could someone put me in the right direction?
Thanks,
Ben
Yes, it is possible. Your application can ask to be notified of significant location changes or to simply continue using the GPS while executing in the background. The former—the approach recommended by Apple—uses less power at the cost of accuracy (this blog post indicates that the updates are accurate to roughly 500m), while the latter is as accurate as the device can manage. This is all detailed in the iOS Application Programming Guide and and the Location Awareness Programming Guide.
If you simply want your application to be notified when the device moves into a particular region, you may want to look into CLLocationManager's startMonitoringForRegion:desiredAccuracy:. If the device moves into a particular geographical region, your app is launched (even if it's not running!).
Basically, I've been learning Objective-C and how to develop for the iPhone over the past few months and have created a few basic applications. Now I've got an idea for an iPhone app that I'm interested in developing and I'm just looking for a bit of advice on wether it is actually possible. I'm looking to create an app that sends the iPhones location to my server every 15 minutes - even when the app hasn't been opened/isn't opened.
Is this possible? If it is, could you point me in the direction of some more info on this subject.
Thanks.
You can declare your application as needing background location services. But this is available only in iOS 4, and user needs to allow location services for your app.
More info about multitasking can be found here
More info about getting users's location can find here
The answer to your question could be a partial YES or a partial NO. Basically ur app can give location updates even when it is not opened ... and u can handle it to be sent to ur server whenever user location updates .. but it is not possible to send the location update on a time basis like every 15 minutes ..
If you want ur app to register for location updates in background mode, u have two options:-
send location update on significant location change (i.e. a location update is sent when user moves significantly such that the cell tower changes for the user ) in this case u have to use startMonitoringSignificantLocationChanges OR
send continous location updates by using startupdatingLocation and in info.plist file declare background mode key for location updates (uses GPS)
and u have to handle didUpdatetoLocation for location updates in both cases and Ur app will be woken up in background as soon as a location update is recieved (beware of battery usage in 2nd case)
For the sake of this question, assume I plan to build a Google Latitude client app for iOS 4.
my app needs to upload the user gps location every two minutes, and also download the user friends locations. - in the background!
my app can't wait to be woken up by the OS on cellular tower switches (because they may only happen after 2 KM, while my app needs constant gps updating), so I understand I can create a thread, similar to the ones GPS navigators use, to run in the background.
I have no knowledge in iPhone programming, I just need to know if my app is feasible.
Will I be able to access the internet from within the background thread (and upload the user gps location), or is it restricted to only sampling the GPS location.
1.
Will Apple approve such an application, or is this type of use forbidden? because my app isn't realy critical such as a gps navigator
Thanks!
As Don said, iOS will send location events to apps that support it. From there, the app can do what it needs to do with the location event.
Background apps can register for one of three options:
Significant changes only: a low-power way to track location that only wakes the app up when there's a "significant" change in location
Standard location services: compatible with all iOS devices that can use location services, allows you specify change in distance, and works in background. However, if the app has been terminated or suspended, iOS won't attempt to relaunch the app.
Continuous location services: allows the program to receive continuous location updates and iOS will not suspend the application when sent to the background.
More info: Executing Code in the Background and Location Awareness Programming Guide
If you take a look at Executing Code in the Background, Apple provides guidelines on what multitasking-aware apps should and shouldn't do.
You will receive the locationManager:didUpdateToLocation:fromLocation: message in your app. In there, you can do whatever you need to, although you should not update the UI or use Open GL if your are in the background.