且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

以编程方式在单一应用模式下锁定iOS应用

更新时间:2023-11-22 17:32:04

据我所熟知的iOS 7有一个新功能,可以完全按照您的要求进行操作。
但是,它仅适用于iOS 7(我相信它仅适用于受监督的设备)。

As I know in iOS 7 there is a new feature which allow to do exactly what you want. However, it's only applicable for iOS 7 (and I believe it's only applicable to a supervised devices).

1)您需要安装限制配置配置文件使用 autonomousSingleAppModePermittedAppIDs 密钥(看看这里

1) You will need to install restriction configuration profile with autonomousSingleAppModePermittedAppIDs key (take a look here)

这是一个步骤,用户需要手动接受此配置文件。

This is one time step and a user will need to manually accept this configuration profile.

还有另一个选项可以使用MDM以静默方式安装它,但这可能对你来说太过分了。

There is another option to use MDM to install it silently, but it could be an overkill for you.

2)你应该使用API​​:

2) You should use API:

UIAccessibilityRequestGuidedAccessSession (to lock/unlock)

定义这里

3)和大多数美化部分。所有这些都是官方文件。因此,您甚至可以将其提交给AppStore。

3) And most beautility part. All of it is officially document. So, you can even submit it to AppStore.

P.S。你为什么关心4.3或5?他们现在的市场份额很小。最有可能的是iOS 6的市场份额已经低于20%。

P.S. Why do you care about 4.3 or 5? They have tiny market share by now. Most likely even iOS 6 has below 20% market share already.

更新1

潜在地,您可以尝试使用发送点击和密钥的API(在iPhone-privateapi标记中搜索GSEvent)。可能正在使用这些API,你可以做三重家庭来打开和关闭可访问性。

Potentially, you can try to use API which sends clicks and keys (search for GSEvent in iPhone-privateapi tag). May be using these API's you can do triple home to toggle accessibility on and off.

如果这项工作,我认为你应该可以覆盖iOS 6.我不确定此API和三次主页点击是否可用。

If this work, I think you should be able to cover iOS 6. I am not sure whether both this API and triple home click were available prior that.

看起来这个私有API在iOS 7中已经无法访问了。所以,你可以忽略这个想法。

It looks like this private API is unaccessible anymore in iOS 7. So, probably you can ignore this idea.