문제

This question exists in different flavors on github, but this mine is specific. I'm creating an iPhone app that logs locations. I'm trying to log the location every 5 min even when the app is in the background and when the user is not moving. So far I've tried the following;

Use CoreLocation to fire the events - if the phone is stationary, the location events are not fired, so logging every 4 min in the bg does not work.

Use Perform Fetch to and read last location - this seems to fire when it pleases, can't get it to reliably fire every 5 min

Use a background task and NS Timer havent tried but seems feasable ** since this won't be going in the app store, is there a way to call a bgtask that spins up another bg task before it dies?

**** this app does not need to be approved by apple

도움이 되었습니까?

해결책

If you need to do this for an in-house app - you're saying the app doesn't need to be approved by Apple - then you can set your app to be a VOIP app. In your info.plist file you set the corresponding background mode and then you can call the UIApplication:setKeepAliveTimeout to tell iOS at what interval you want some background processing time. Minimum interval is 10 minutes.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top