保持iOS App唤醒以监控运动 [英] Keep iOS App Awake To Monitor Movement

查看:171
本文介绍了保持iOS App唤醒以监控运动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法正常使用iOS应用程序的主要功能。我正在尝试创建一个使用CoreMotion来测量几个小时内的移动量的应用。当设备处于唤醒状态时,一切正常,但是问题是,设备会在一段时间后自动锁定并进入后台状态,因此我监视移动暂停的方法。

I'm having trouble getting the main feature of my iOS application to work. I'm trying to create an app that measures the amount of movement over a period of a few hours using CoreMotion. All works fine when the device is awake, however the issue is that the device auto locks after a while and enters the background state, thus my methods for monitoring movement pause.

我正在寻找一种可能的方法来记录设备在锁定状态下的运动,这可能是使应用一次唤醒几个小时。我研究了过去用于此目的的一系列可能的解决方案,但发现这些方法现在可以使该应用程序被Apple拒绝。

I'm searching for a possible solution to recording the device's movement whilst it has been locked, which may be to keep the app awake for a few hours at a time. I've looked into a bunch of possible solutions that have been used for this in the past, yet found out that these ways of doing it can now cause the app to be rejected by Apple.

任何帮助将不胜感激。

推荐答案

对于任何有兴趣或对类似问题感兴趣的人,我想出了解决我问题的方法。我需要利用iPhone的运动协处理器,该协处理器跟踪超时运动并将这些数据存储在设备上。这是CoreMotion框架的一部分,无论应用程序在使用时是否打开,都可以对其进行查询。还值得一提的是,只有iPhone 5s和更高版本具有此硬件,因此较旧的设备将无法利用此功能。

For anyone who is interested or stuck on a similar problem I figured out the solution to my question. I needed to utilise the iPhone's motion coprocessor, which tracks movement overtime and stores this data on the device. This is part of the CoreMotion framework and can be queried regardless of whether the application was open or not at the time of use. It's also worth mentioning that only the iPhone 5s and later have this hardware, so older devices will no be able to take advantage of this.

我希望这对需要的人有所帮助

I hope this helps anyone who needs it.

这篇关于保持iOS App唤醒以监控运动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆