3

I'm trying to access the last photo from the user's camera roll within an iOS keyboard extension. I have allowed full access to the keyboard and allowed access to the Photo Library. But every time I try to run PHImageManager.default().requestImage... the keyboard is terminated...

Is it not possible to use PHImageManager in a keyboard extension?

Peter Warbo
  • 11,136
  • 14
  • 98
  • 193

1 Answers1

1

According to App Extension Programming Guide it should be possible.

If you request open access by setting this key’s value to YES, your keyboard gains the following capabilities, each with a concomitant responsibility in terms of user trust:

  • Access to Location Services, the Address Book database, and the Camera Roll, each requiring user permission on first access

only allowing full access in the info.plist file is not enough, also the user has to allow full access in the keyboards settings.

On your device go to Settings -> General -> Keyboard -> Keyboards -> %NAME_OF_YOUR_KEYBOARD% and turn on Allow Full Access!

But I'm still facing problems here: although i have added a NSPhotoLibraryUsageDescription to my extensions info.plist my keyboard terminates with following message: [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.

ndreisg
  • 1,119
  • 13
  • 33
  • i found out, that the message `[access] TCCAccessRequest_block_invoke: Connection invalid` indicates, that the user has not granted full access to the keyboard. On your device go to `Settings -> General -> Keyboards -> Keyboards -> %NAME_OF_YOUR_KEYBOARD%` and turn on `Allow Full Access`! Answer updated! – ndreisg Jun 19 '17 at 09:22