问题描述
如果某个应用需要访问 Motion Activity
数据,则会在安装时询问用户。但是,如果用户意外回答'否',那么该应用程序将无法正常工作。
If an app requires access to Motion Activity
data it asks the user at install. However if the user accidentally answers 'No', then the app will not work.
我正在寻找一种方法来检查运动活动是否已启用,以便我如果没有,可以提示用户启用。
I am looking for a way to check if the Motion Activity is enabled, so that I can prompt the user to enable if not.
有人能指出正确的方向吗?
Can someone point me in the right direction code wise please?
根据Doc(谢谢)提供的信息,似乎Apple没有提供检查状态的直接方法隐私中的动作活动
我通过了解错误找到了: -
Following the info from Doc (Thank you), it seems that Apple do not provide a direct method to check the status of Motion Activity
in Privacy. I was able to find out by picking up on the error:-
[stepCounter queryStepCountStartingFrom:[NSDate date]
to:[NSDate date]
toQueue:[NSOperationQueue mainQueue]
withHandler:^(NSInteger numberOfSteps, NSError *error) {
if (error != nil && error.code == CMErrorMotionActivityNotAuthorized) {
// The app isn't authorized to use motion activity support.
}
推荐答案
Apple有,显示如何检查并请求访问所有各种权限(包括动作活动)。我建议你快速看一下 - 这很简单。
Apple has a sample project that shows how to check and request access for all the various permissions (including Motion Activity) here. I suggest you take a quick look at that - it's pretty straightforward.
这篇关于iOS - 在设置中启用动作活动>隐私>动作活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!