iOS keyboard extension access PHImageManager - ios

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?

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.

Related

Google Maps asking for NSLocationWhenInUseUsageDescription

I have an iOS app that uses the Google maps library which I have added via CocoaPods. This app fetches user location even in background so it asks the user for NSLocationAlwaysUsageDescription.
But upon running the app from Xcode, I get the correct permission alert but I also get the following error message in the console.
This app has attempted to access privacy-sensitive data without a
usage description. The app's Info.plist must contain an
NSLocationWhenInUseUsageDescription key with a string value explaining
to the user how the app uses this data
Doesn't NSLocationAlwaysUsageDescription automatically allow when in usage as well? Because I don't want the When In Use option to be available in the Settings because if the user later changes to that, it will cause the app to behave not as intended.
You have to add a key value pair of NSLocationAlwaysUsageDescription as key and value is like you have to notify user , or something else that user can understand that this app is going to use gps location.
You can try this or add this in your plist
Privacy - Location Always Usage Description as key and
Application would like to use your location. By allowing background locations, we can notify you when a customer is requesting for service. Continued use of GPS running in the background can dramatically decrease battery life as value

Does UIActivityViewController need info.plist privacy keys to save images to photos or email

Does UIActivityViewController require Info.plist privacy keys:
NSContactsUsageDescription or NSPhotoLibraryUsageDescription to email or save images to photo library?
I've never seen it crash during these activities in testing, but I am seeing some crash reports (not many) on iOS 10 devices with CRASHING_DUE_TO_PRIVACY_VIOLATION in the stack trace. The only place the App touches anything to do with privacy is if the user uses the capability I provide via UIActivityViewController activities to share a screenshot via email or save it to the photo library. This is an Apple supplied framework and my App doesn't have actual access to any of that data as far as I know?!
The documentation for UIActivityViewController says nothing about requiring those strings for it's access to contacts or the photo library during those type activities.
NSPhotoLibraryUsageDescription is required to be set in info.plist if UIActivityViewController allows activity: UIActivityTypeSaveToCameraRoll.
This was not showing up as a crash because if the user is logged into iCloud and uses share to photo stream that seemed to work fine without the privacy key, but when the OTHER less prominent option to Save to camera roll is used, that does crash without the key.
You'd think they would mention that in the docs ;)

Is empty NSCameraUsageDescription accepted?

If your app uses camera, you have to set NSCameraUsageDescription in InfoPlist.strings. But what if I don't want to use any custom message? Is it accepted to set empty empty NSCameraUsageDescription like this:
NSCameraUsageDescription = "";
Docs say a bit strange about this:
If your app attempts to access the device’s camera without a corresponding purpose string, your app exits.
What is "exits"? Will my app rejected?
You can use
NSCameraUsageDescription = "";
Without any message, you just need to put the key in the plist. Also in the doc
If your app attempts to access the device’s camera without a
corresponding purpose string, your app exits.
They mentioned exits, it means the app will get closed if you don't put that string but i have checked it now, and the popup is showing without any message just the title.
No it is not accepted .
iOS already required permissions to access microphone, camera, and media library earlier (iOS6, iOS7), but since iOS10 the apps will crash if you don't provide the description why you are asking for the permission.
from : https://stackoverflow.com/a/38498347/3901620

show custom view for iOS location permission dialog

I am new to iOS. Is it possible to show a custom view or dialog in place of the default iOS location permission dialog?
No, this dialog is presented by the operating system and you cannot modify it. It is an important part of privacy management that the dialog is presented in a consistent way for all apps and that apps cannot modify the permission process.
You can display a custom view or alert prior to requesting permissions that explains what is happening and the need to click "allow" on the alert that is about to be presented
Direct Answer is it's not possible
explanation :
Only option is set description string by using Cocoa Keys(The keys associated with the Cocoa touch environments)
Add one of these key to
NSLocationWhenInUseUsageDescription
NSLocationAlwaysUsageDescription
Info.plist and set it's value to whatever which describe the purpose of getting location
ex:
MyApp picks you up from where you are. To book airport rides, choose “Allow” so the app can find your location.
Important: To protect user privacy, an iOS app linked on or after iOS 10.0, and which accesses the user’s location information, must statically declare the intent to do so. Include the NSLocationAlwaysUsageDescription key in your app’s Info.plist file and provide a purpose string for this key. If your app attempts to access the user’s location information without a corresponding purpose string, your app exits.
If you looking for localization for that message
Link

Data upload from custom iOS keyboard

Is it possible to upload data from custom keyboard to the web service? I mean that an app works on custom keyboard and using it for operations belong to web service like registering user to a website or logging in etc.
Yes, but the user must manually switch on "Allow Full Access" in iOS's Settings app (in the same place where the keyboard is installed in the first place). Your keyboard extension must also request open access by setting the RequestsOpenAccess key to true under NSExtensionAttributes in your extension's info plist.
See more about this option under "Designing for User Trust" on Apple's keyboard extension webpage: https://developer.apple.com/library/ios/documentation/General/Conceptual/ExtensibilityPG/Keyboard.html

Resources