I can click on any image or file stored under My Files and am able to see my Xamarin form app while clicking the share button.
I am not able to do the same when clicking any photos present in the gallery on iOS.
Are any specific settings required for this?
Below is my info.plist file configuration
<key>NSPhotoLibraryUsageDescription</key>
<string>This app needs access to photos gallery for picking photos and videos.</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>This app needs access to the photo gallery for picking photos and videos.</string>
<dict>
<key>CFBundleTypeName</key>
<string>Image</string>
<key>LSItemContentTypes</key>
<array>
<string>public.image</string>
</array>
</dict>
</array>
</dict>
In iOS, the image uses UIActivityViewController to share items. UIActivityViewController allows app users to easily share data between the current app and services. You can check the usage of UIActivityViewController.
For how to use xamarin.ios code in xamarin.forms applications, you can refer to the DependencyService documentation in Forms.
UpDate: Extensions in Xamarin iOS can help you, and you can refer to the thread for using it in Forms: How to implement Share Extension to Xamarin.Forms - iOS project?
Related
I have been struggling with this for a few hours and couldn't confirm wether the following scenario is possible to achieve anymore or not.
Scenario : I am developing an app that deals (create, store ...) with files (image, video, pdf ..) and want to expose it as a viewer for these type of files to any other app in the device and mainly the photo library.
Current behaviour : my app is visible (and of course handling the files) when hit sharing from files browser on iPhone, google drive, one drive ... except the photo library. The only possible way I found to make it visible there is through creating a Share Extension which does not serve what I am attending to do since it is a limitation that Share Extension can not communicate with the app and attend to open it and pass the image path (or stream).
Here is my info.plist CFBundleDocumentTypes :
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>CFBundleTypeName</string>
<key>LSItemContentTypes</key>
<array>
<string>public.data</string>
</array>
</dict>
</array>
All I found so far is you just need CFBundleDocumentTypes to register your app in the device target apps for opening certain files (by types indicated by LSItemContentTypes). But no one has mentioned (I couldn't find one yet at least), why this sort of config won't get your app visible as a viewer when selecting share photo from photos library.
To Reproduce : just create a native iOS project via XCode or Xamarin.iOS project and introduce the above section into your info.plist. And of course run your app. You'll see it from files explorer, from safari trying to share a pdf to your file..., but not from photos library.
I am trying to pass the current URL from safari to my app using the safari share button and share sheet. I want this to go to my app and not have it be a share extension. From safari, the share sheet does not show my app. I have registered the following document types (UTI) without success:
public.url
public.file-url
public.url-name
My app does show up from a pdf document share using com.adobe.pdf without any issues. Any help sharing the URL from safari would be most appreciated. I am also having a similar issue with using share button from a photo displayed from the apple app.
What are the correct UTI for safari url and a photo via the share button to properly appear on the share sheet? Thanks.
Bob
Go to the project (root element in the Project Navigator) and select your Share target
Go to Info
Open NSEXtension -> NSExtensionAttributes -> NSExtensionActivationRule
For URL Support: Add NSExtensionActivationSupportsWebURLWithMaxCount underneath NSExtensionActivationRule (type is Number, the value is any number higher than 0 depending how many URL's you allow to handle in one share action)
For Photo and/or Video Support add NSExtensionActivationSupportsImageWithMaxCount and/or NSExtensionActivationSupportsMovieWithMaxCount
For other file types add NSExtensionActivationSupportsFileWithMaxCount
In the raw code of the Info.plist file of your Share target it will look like this:
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>NSExtensionActivationRule</key>
<dict>
<key>NSExtensionActivationSupportsFileWithMaxCount</key>
<integer>10</integer>
<key>NSExtensionActivationSupportsImageWithMaxCount</key>
<integer>10</integer>
<key>NSExtensionActivationSupportsMovieWithMaxCount</key>
<integer>10</integer>
<key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
<integer>1</integer>
</dict>
</dict>
<key>NSExtensionMainStoryboard</key>
<string>YourStoryboard</string>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.share-services</string>
</dict>
NOTE for people who don't see their app appearing in Dropbox'es Export sheet: Dropbox passes a URL to the share sheet, you'd have to support NSExtensionActivationSupportsWebURLWithMaxCount
I just dealt w/ this issue. It appears to be a Safari issue and not an App configuration issue. So long as your permissions are set correctly per the documentation, try testing in google chrome. Shares just fine from there...
Recently I started to get this error:
NSPhotoLibraryUsageDescription key must be present in Info.plist to
use camera roll.
I am using React Native to build my app (I am not familiar with ios native development) and I don't know how to add this key to Info.plist
Can you post an example? Thanks
I am using npm package "react-native-camera-roll-picker": "^1.1.7"
Thanks #rmaddy, I added this just after other key-string pairs in Info.plist and fixed the problem:
<key>NSPhotoLibraryUsageDescription</key>
<string>Photo Library Access Warning</string>
Edit:
I also ended up having similar problems on different components of my app. Ended up adding all these keys so far (after updating to Xcode8/iOS10):
<key>NSPhotoLibraryUsageDescription</key>
<string>This app requires access to the photo library.</string>
<key>NSMicrophoneUsageDescription</key>
<string>This app does not require access to the microphone.</string>
<key>NSCameraUsageDescription</key>
<string>This app requires access to the camera.</string>
Checkout this developer.apple.com link for full list of property list key references.
Full List:
Apple Music:
<key>NSAppleMusicUsageDescription</key>
<string>My description about why I need this capability</string>
Bluetooth:
<key>NSBluetoothPeripheralUsageDescription</key>
<string>My description about why I need this capability</string>
Calendar:
<key>NSCalendarsUsageDescription</key>
<string>My description about why I need this capability</string>
Camera:
<key>NSCameraUsageDescription</key>
<string>My description about why I need this capability</string>
Contacts:
<key>NSContactsUsageDescription</key>
<string>My description about why I need this capability</string>
FaceID:
<key>NSFaceIDUsageDescription</key>
<string>My description about why I need this capability</string>
Health Share:
<key>NSHealthShareUsageDescription</key>
<string>My description about why I need this capability</string>
Health Update:
<key>NSHealthUpdateUsageDescription</key>
<string>My description about why I need this capability</string>
Home Kit:
<key>NSHomeKitUsageDescription</key>
<string>My description about why I need this capability</string>
Location:
<key>NSLocationUsageDescription</key>
<string>My description about why I need this capability</string>
Location (Always):
<key>NSLocationAlwaysUsageDescription</key>
<string>My description about why I need this capability</string>
Location (When in use):
<key>NSLocationWhenInUseUsageDescription</key>
<string>My description about why I need this capability</string>
Microphone:
<key>NSMicrophoneUsageDescription</key>
<string>My description about why I need this capability</string>
Motion (Accelerometer):
<key>NSMotionUsageDescription</key>
<string>My description about why I need this capability</string>
NFC (Near-field communication):
<key>NFCReaderUsageDescription</key>
<string>My description about why I need this capability</string>
Photo Library:
<key>NSPhotoLibraryUsageDescription</key>
<string>My description about why I need this capability</string>
Photo Library (Write-only access):
<key>NSPhotoLibraryAddUsageDescription</key>
<string>My description about why I need this capability</string>
Reminders:
<key>NSRemindersUsageDescription</key>
<string>My description about why I need this capability</string>
Siri:
<key>NSSiriUsageDescription</key>
<string>My description about why I need this capability</string>
Speech Recognition:
<key>NSSpeechRecognitionUsageDescription</key>
<string>My description about why I need this capability</string>
MY FAVORITE WAY TO DO IT
1. Open info.plist
2. Click this button to add a new key
3. Scroll down to find Privacy - Photo Library Usage Description
4. Select it, then add your description on the right
Add following code in info.plist file
<key>NSPhotoLibraryUsageDescription</key>
<string>My description about why I need this capability</string>
You need to paste these two in your info.plist, The only way that worked in iOS 11 for me.
<key>NSPhotoLibraryUsageDescription</key>
<string>This app requires access to the photo library.</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>This app requires access to the photo library.</string>
As of now August 2021,
not only we have to add this :
<key>NSPhotoLibraryUsageDescription</key>
<string>We need access to photo library so that photos can be selected</string>
but also need to add this to info.plist file inside iOS folder in order to work properly
<key>NSPhotoLibraryAddUsageDescription</key>
<string>This app requires access to the photo library.</string>
For camera access use:
<key>NSCameraUsageDescription</key>
<string>Camera Access Warning</string>
i faced the same issue few days earlier for my IONIC 4 Project. when i uploaded my IPA, i got this warnings from App Store Connect.
I fixed the "Missing Purpose String in info.plist" issue, by the following steps. hope it will also work for you.
Goto your "info.plist" file.
Find this key, called Privacy - Photo Library Usage Description. if it's not present there, add a new one and it's value, like below image.
Thanks.
In order to save or retrieve an image from the camera roll. Additionally, you need to ask the user for the permission otherwise you'll get this error or your app may get crashed. To save yourself from this add this into your info.plist
<key>NSPhotoLibraryAddUsageDescription</key>
<string>This app requires read and write permission from the user.</string>
In the case of Xamarin.iOS
if you're adding it from the generic editor then "Privacy - Photo Library Additions Usage Description" will be the given option you will find out instead of "NSPhotoLibraryAddUsageDescription".
If you added the key-string pairs in Info.plist (see Murat's answer above ) and still getting the error, try to check if the target you're currently working on has the keys.
In my case I had 2 targets (dev and development). I added the keys in the editor, but it only works for the main target and I was testing on development target. So I had to open XCode, click on the project > Info > Add the key-pair for the development target there.
When using NSCameraUsageDescription the user can access the camera AND select images from the photo library. So I don’t need NSPhotoLibraryUsageDescription, correct?
https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html
"Privacy - Photo Library Additions Usage Description" for iOS 11 and later
"Privacy - Photo Library Usage Description" for iOS 6.0 and later
Open plist file and this code
<key>NSPhotoLibraryUsageDescription</key>
<string>This app requires access to the photo library.</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>This app requires access to the photo library.</string>
I tried this key in plist..
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>All Files</string>
<key>LSItemContentTypes</key>
<array>
<string>public.data</string>
<string>public.content</string>
</array>
</dict>
</array>
this works for file sharing but in case of file attachment from ms-word app this code does not work while Dropbox and Slack still in menu. Also I have tried lots of examples.
This is not just Open In menu, this is Activities menu, that means it displays apps with Share extensions inside. To get into this menu you should create Share extension in your app, and this extension will show in MS Word app.
To create Share extension in your app you should add new Target for it, File > New > Target > Application Extension > Share Extension.
Here is official documentation about share extensions.
It can be little confusing, so I created simple example with empty extension, you can get it here .
Screeshot with example app in Activities menu:
UPD
To see your app next to DropBox icon in Activities menu you should create Action extension for your app. I created another example with empty Action extension here. How DropBox action extension works: it displays Action extension inside MSWord app and uploads selected file to DropBox server.Also, you should know, that these extensions are not App launcher, so you should implement you functionality in extension without you app opening, link
openURL not work in Action Extension
Screeshot with Action extension icon:
I developed an iCloud Drive Export feature for my iOS App and it works.
I can see the exported Documents in our public AppContainerFolder in the iCloud Drive folder on Mac OS X 10.11.
But on iOS, I only can see the AppContainerFolder in the iCloud Drive app. It is disabled and I am not able to open that folder, or see the documents inside.
Image of the disable folder in the iOS iCloud Drive App
From the iCloud Drive settings, I can see that the files I have exported are in that AppContainerFolder in iCloud Drive.
Image of the AppContainerFolder inside the iCloud settings
Has anyone had such an issue with iCloud Drive?
I am using two app containers in my app, one with the "iCloud.com..." identifier for the exports and another with the "TeamIdentifier.com..." identifier for the Ensembles-CoreData syncing.
I explicitly use the URLs for the Containers using the method:
[[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:#"iCloud.com..."]
I already tried to only use the TeamIdentifier-Container, but there was no change in the visibility of the AppContainerFolder.
I tried to bump the BundleVersion, I played around with the Info.plist NSUbiquitousContainers settings. I also made Builds available through TestFlight to external testers, to see if it has something to do with development devices.
The only thing, I hadn't done yet, to release a new version to the AppStore with a new BundleVersion, to see if it has something to do with a productive app vs. an app in development.
Any tips and hints welcome.
After clarification with the Apple Developer Technical Support, I was now able to solve the issue.
My app declares two exported UTI's (own backup files), so that the iCloud container will default to NOT being enabled (or grayed out), when other files than these UTI's are saved into that folder.
Our app is able to create PDF's and CSV's, but these file types were NOT declared as 'Document types' in the info.plist, because our app is not able to display them.
When adding the PDF and CSV document types to the info.plist, the iCloud container gets instantly visible in the iCloud Drive app.
For your reference, here is an extract of the info.plist:
...
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeIconFiles</key>
<array/>
<key>CFBundleTypeName</key>
<string>Adobe PDF</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSHandlerRank</key>
<string>Alternative</string>
<key>LSItemContentTypes</key>
<array>
<string>com.adobe.pdf</string>
</array>
</dict>
<dict>
<key>CFBundleTypeIconFiles</key>
<array/>
<key>CFBundleTypeName</key>
<string>CSV</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSHandlerRank</key>
<string>Alternative</string>
<key>LSItemContentTypes</key>
<array>
<string>public.comma-separated-values-text</string>
</array>
</dict>
</array>
...
The post Why my app is not shown in iCloud Drive Folder seems to indicate your app needs to be approved and released before a public iCloud folder works fully.