0

Summary

I'm currently implementing a custom iOS keyboard. I need to share data between the keyboard and the containing apps. This works to some extent even if the user has disabled full access. Why?

The Details

To share data between the keyboard and the containing app, I have installed an app group and use

NSFileManager
    .defaultManager()
    .containerURLForSecurityApplicationGroupIdentifier("mySuiteName")

to share files and

NSUserDefaults(suiteName:"mySuiteName")

for other settings.

As far as I understand, the user has to activate full access for my keyboard in the system settings. The App Extension Programming Guide states:

If you request open access by setting this key’s value to YES, your keyboard gains the following capabilities [...]:

  • Option to use a shared container with the keyboard’s containing app, which enables features such as providing a custom lexicon management UI in the containing app

I have added the required property to the plist file and see the according option in the keyboard settings. To test if the user has allowed full access to the keyboard I went with the known approach and test for pasteboard availability

UIPasteboard.generalPasteboard().isKindOfClass(UIPasteboard)

which works as expected.

However, I noticed that if full access is disabled I can still load images from the keyboard using

UIImage(contentsOfFile: imagePath)

with imagePath pointing to a file in the shared container. I have tested this on two devices running iOS 9.2. Shouldn't this be impossible? I'm wondering if I misunderstood the restrictions to the shared container.

4

1 回答 1

3

在 iOS 8.0 和 9.0 之间的某个时间点(我想说 8.3,但我不记得确切的版本)Apple 更改了对自定义键盘的限制,以便它们对共享容器具有只读访问权限 - 两者都是文件系统以及NSUserDefaults与之相关的,即使完全访问被禁用。

文档尚未更新。你应该归档一个雷达。

于 2016-01-17T21:13:38.080 回答