Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
415 views
in Technique[技术] by (71.8m points)

networking - Can iphone app woken in background for significant location change do network activity?

I'm working on an app that monitors significant location changes in the background. I've been reading all the answers (well, I think all!) about ios4 and the application lifecycle, but what I can't figure out is whether or not I can do any network access when the app is woken up in the background as a result of a significant location change.

The app currently does network access via TCP sockets. The socket is shutdown when the app is suspended.

Can I re-connect the socket, receive some data, send the new location and then shutdown the socket all while still in the background as a result of receiving the location change event? It's hard to test while stationary in the office! We can assume that the network activity takes less than 10 seconds to complete. Also assume the app isn't registered as a voip app (could/should it be? ...)

Any ideas?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Yep. You can do your network processing based on significant change events.

When you get woken up into the background state on significant change (from terminated or suspended state), you can make your http request. If you find your app is being terminated before you finish your HTTP request, you can ask for additional background processing time via the beginBackgroundTaskWithExpirationHandler: method on UIApplication.

I spent a fair bit of time on short train trips to test this out. :)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...