Ask iPhone 4 to send back geotag information to server on the background - iphone

I wonder if it is possible for iPhone 4:
I have a server which sends queries about the location of the phone (irregularly) via an iPhone app. Customer can choose a setting that allow the phone to send back geotag information (longitude and lattitude) in the background (without customers doing anything).
If it is possible, how should I do it? If not, what is the closest alternative available?
Thank you.

Yes, you can do this. You have to set the UIBackgroundModes flag in your Info.plist to indicate that you execute in the background.
See: Information Property List Keys
Note that running the GPS from the background will severely impact battery life. In addition your application may be terminated at any time if the system needs the memory.

Related

How to receive acceleration-related data from the onboard hardware, when application in background mode?

Am developing application for calculate count of user moved steps and draw the user activities in the map. And we are using UIAccelerometer delegate for receive acceleration-related data from the onboard hardware. So I need to receive acceleration-related data when the application in background mode too. Last time one of my application got rejected because of using location service in background, Apple suggested me like "you can only use this background mode if your app truly needs this information to provide value for the user". Kindly suggest the best approach for this application.
You cannot run accelerometer in background.
You can track user's location in background... however, if you just keep tracking it and do nothing with that info.. apple is going to reject it and tell you to just get the lates location when app comes to foreground.
what you can try is.. update the user of total distance covered etc on a regular basis (like run keeper) and this will justify tracking location in background.
But first, you can try appealing to the review board explaining that you need to track location in background because you show entire route travelled by user when app comes to foregraound. and compare this to existing apps like run keeper and if you are lucky apple may approve your application without any changes...
This can easily be done.
What happens in that iOS put your application in halt state when your application is not in running in foreground state.
You just need to register your application for background execution.
Refer :
http://dcraziee.wordpress.com/2013/05/20/background_ios/
Also refer :
iOS background application network access
for apple policies about using location service.Which states that you can use location service in background.

Is it possible to send location data silently from the iphone (with users agreement ofcourse)?

I was wondering if it possible to create an application that will send my 9 year old's iPhone location let's say each 30 minutes, even when the iPhone is not active.
If not, then is it possible to send it each time he uses his phone?
Why not using an existing solution?
http://www.apple.com/icloud/features/find-my.html
See find my friends - it has also parental restrictions. This is excatly what you want.
You're probably looking for startMonitoringForReigion:desiredAccuracy:. This function will allow you to set the iPhone to notify your app anytime a defined boundary is crossed. When you receive this notification, I believe you can send that info to a server or wherever.
That said, if monitoring your child's location is what you want, you'll have great luck with the Find My Friends app from Apple.

iPhone alert an alarm if stolen

We are developing an enterprise application .The phones are connected to a Wifi router. The objective is to trigger an alarm if the phone moves out of the secure area .. (outside the building)
What is the best way to check if the iPhone is always inside the building .
some of the options we tried are
1.using Wifi(continous ping to wifi network),if not trigger an alarm .
2.if coordinates change (using GPS)
Are there any other means to achieve this .
You can use Location Services in iOS 4 (with the background location feature) to determine when the phone has moved to a different location.
#indragie's idea of using Location Services is a good one. If you can be sure that the WIFI SID isn't going to change, you could probe to see which access point the iPhone is currently associated to. If you are going to ping, then a better approach is to make the system service agnostic, and simply issue an HTTP query on a regular basis to your enterprise server. The server can then have a policy language on it declaring acceptable access points (from a variety of metrics). This might be set up to allow people to take their iPhones home.
Your best bet is GPS as the phone will not be able to find its location if you rely on WiFi and the device is not connected to a WiFi network.
Check out Apple's documentation for Location Awareness capabilities here http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/LocationAwarenessPG/CoreLocation/CoreLocation.html
You will be able to track "significant" or standard location changes in the background, details can be found here http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html#//apple_ref/doc/uid/TP40007072-CH5
[edit to include]
This might be of interest to you too - http://longweekendmobile.com/2010/07/22/iphone-background-gps-accurate-to-500-meters-not-enough-for-foot-traffic/
It depends on what you want to do. Just to let the iPhone user know that he/she is moving away, using Location Services is good enough.
However, if you want to have a server that makes sure all the devices are within range, then it's more complex because your application may get suspended without a notice from a background state; in other words, you may not be able to catch the moment when your application terminates and take appropriate actions. Therefore you are going to need a heartbeat system like pinging to the server in this case.

iPhone battery life suggestions

I am developing a voice recording application that communicates with the server real-time, therefore requiring persistent Internet connectivity. I have included UIRequiresPersistentWiFi in my info.plist and have also disabled device going to sleep when the app is active. However, this understandably has a serious effect on the battery life of the device. Users end up having to leave this continuously plugged in. For an app that is touted as meant to replace handheld recorders, this is a serious shortcoming. My app also has many xml threads sent from iPhone to server, so wireless connectivity is of paramount importance.
My questions are:
1. Is it possible to somehow switch on UIRequiresPersistentWifi status only when required during a session. For example, can this be switched on only during transfers or xml updates to server and be switched off at other times?
2. Likewise, can IdleTimer be enabled and disabled programmatically at will during a session. For example, enabling idletimer only when no foreground or background tasks are running on the device.
Any other suggestion to ensure normal battery life? All my users will be on iTouch 4 or iPhone 4.
Any help/suggestions would be greatly appreciated.
Answer to part 2: Yes, you can enable and disable the idle timer depending on what the user or app is doing, and how long it's been. I know of a couple apps that disable the idle timer, but then re-enable it if the user doesn't touch any UI elements for 10 minutes, but then re-disables it if the user starts some long operation again. etc.
Partial answer to part 1: Using the radios (sending wifi data) takes power. A good way to save power is to not send data for as long as possible. Maybe buffer large amounts of data on the device, and try to burst upload it later.
My suggestion would be to not communicate with the server continuously, sorry :(
Is it possible to cache chunks of data into a file on the phone and transmit the chunks to the server periodically in one big burst? Same for the XML. Or does your app really really require it to be broadcast real-time?
And as far as I know, if you have specified UIRequiresPersistentWifi, you're stuck with it :(
Sorry, probably not the answer you want!

iPhone background network connection by timer

I need to write an application, that every 10 minutes it should be awaken from suspended mode, get user location via gps and send this information to the server by network.
Depending on the response it should return to the suspended mode or show local notification to the user.
Is there a way to do this on iOS 4?
I've tried different approaches, but the only working for me was to start monitoring user location in backgroind and declare the application as location background application. In that case it worked in background and has a network connection. But this approach takes a lot of power and not accepted cause application should work 24/7.
May be there is a way to write some daemon that should work in background and wake my application every 10 minutes?
Apparently, Pastebot tried to do something similar with the 'audio' multitasking declaration (by playing a silent audiofile) and got rejected.. UNTIL they actually presented a option to the user to pick which audiofile they wanted to play. It's in the appstore now. :)
In this case: What is your reason for not wanting to use the location updates? If battery-usage is a concern, you can use the 'significant location changes only' option, after which you can temporarily change to a more accurate option.
This isn't possible outside of the method you have already tried.
The iPhone background task API will allow you to run a location service in the background.
There is no way to write daemons for the iPhone without jailbreaking, and that is not something I'm able/prepared to help you with.
App store friendly: use new APIs in iOS4, which allows u to make use of GPS location
Anti App store: create a daemon by adding a specific plist file to System/Library/LaunchDaemons/ and put ur app under Applications/. this approach requires a jailbroken iPhone however...
detailed information plz google the following keywords: daemon, multitask, background, etc...
cheers, Lloyd