views:

196

answers:

3

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?

+1  A: 

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.

Jasarien
Jailbreak is not acceptable also cause the application should be available in App Store. May be it's possible to declare it as "voip" application and have a persistent network connection like skype? Or Apple won't let it pass through the review?
sYgiL
Unless it uses VoIP in the application you can't declare it as using VoIP - it will most certainly be rejected during review.
Jasarien
@Jasarien Any proof it will be rejected, or are you speculating?
NateS
The Review Guidelines state in section 2.16 "Multitasking apps may only use background services for their intended purposes: VoIP, audio playback, location, task completion, local notifications, etc".
Jasarien
+1  A: 

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.

TumbleCow
For this moment i've put this problem aside, cause we have another tasks to do. Hopefully I'll find a suitable solution later.
sYgiL
A: 

Hi guys,

I make an NSURLRequest and sent it while in the foreground, and then go into the background and wait for the acknowledgement and it never comes through.

I am using task completion thebeginBackgroundTaskWithExpirationHandler. The request succeeds, can see it on the server but my app never gets informed.

Any clues?

Can an application while in the background receive a network response?

Thanks

Asad Qamber
Do you use async request? As I remember, long task functionality will work only with sync request.
sYgiL
I am using an async request :-( Can you please provide the reference... task completion only works for sync requests
Asad Qamber
I don't remember exactly, I've seen it somewhere on this site, whild was looking for the answer for my question
sYgiL