Time based GPS location in background (iphone)

后端 未结 3 1857
没有蜡笔的小新
没有蜡笔的小新 2021-01-15 19:05

I want to create an (game based) iPhone application which sends your GPS location on a specific time (like 3-5 times a day) to a server. I found an apple page explaining som

相关标签:
3条回答
  • 2021-01-15 19:39

    You can't "schedule background work". iOS doesn't allow it.

    The solution is to set yourself up for notification on significant change (which is some hit to the battery, but it's not horrible), and then only DO anything with that at occasional intervals.

    0 讨论(0)
  • 2021-01-15 19:59

    It really depends on your usage of the location. If you monitor actively, kiss the battery of your user goodbye. Very detailed accuracy, even bigger hit to battery. The backgrounding of location is all or nothing as far as accuracy goes.

    Less hit, less accuracy is -startMonitoringForSignificantLocationChange. May not be accurate enough for you.

    Better depending on usage, region monitoring. Triggers event on entry or exit of defined region.

    You don't have the benefit of accuracy and timed location based events. You can do it, but is going to require a lot more effort on your end.

    0 讨论(0)
  • 2021-01-15 20:03

    While this is untested, I am planning an app with a similar need. My solution is that on a significant location change, the app will determine what interval exists between the update timestamp, and when I care to know the users location (5pm for instance). If that's below some threshold, it will go into startUpdatingLocation mode (full power, battery draining, which is why that threshold is important) and then, on each location update, check if that target time has passed. if SO, send the update to your server, and go back to monitoring for significant changes. The catch is that if it still requires some movement to trigger the significant change update...so it isn't a perfectly reliable solution, but it may work depending on how you're using the data

    0 讨论(0)
提交回复
热议问题