iOS键盘扩展访问PHImageManager

时间:2017-06-02 10:14:08

标签: ios keyboard custom-keyboard

我试图在iOS键盘扩展程序中访问用户相机胶卷中的最后一张照片。我已允许完全访问键盘并允许访问照片库。但每次我尝试运行PHImageManager.default().requestImage...键盘都会终止......

是否无法在键盘扩展程序中使用PHImageManager

1 个答案:

答案 0 :(得分:1)

根据App Extension Programming Guide,它应该是可能的。

  

如果您通过将此键的值设置为YES来请求开放访问,则键盘将获得以下功能,每个功能在用户信任方面都具有相应的责任:

     
      
  • 访问位置服务,地址簿数据库和相机胶卷,每个都需要首次访问的用户权限
  •   

仅允许在info.plist文件中完全访问是不够的,用户还必须允许在键盘设置中完全访问。

在您的设备上转到Settings -> General -> Keyboard -> Keyboards -> %NAME_OF_YOUR_KEYBOARD%并开启Allow Full Access

但我仍然在这里遇到问题:虽然我在我的扩展信息中添加了NSPhotoLibraryUsageDescription info.plist 我的键盘终止于以下消息: [access] This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSPhotoLibraryUsageDescription key with a string value explaining to the user how the app uses this data.