Using the UIDocumentPickerViewController, is it possible to show a default service (Dropbox, Google Drive, etc) on first open like in Slack?
Normally, the behavior with UIDocumentPicker is that you present, then the user must use the “Locations” menu on the top right to switch between the services. Is it possible to display either “Dropbox” or “Google Drive” first by default? Almost as if we’re “deeplinking” into the UIDocumentPicker service.
It seems like Slack App is able to do this and also the MyMail App but I wasn’t able to find an API for it. Any ideas?
3 Solutions Collect From Internet About “Using the UIDocumentPickerViewController, is it possible to show a default service (Dropbox, Google Drive, etc) on first open like in Slack?”
Instead of using a UIDocumentPickerViewController, try using a UIDocumentMenuViewController. Here is the relevant documentation.
UIDocumentMenuViewController *documentProviderMenu = [[UIDocumentMenuViewController alloc] initWithDocumentTypes:[self UTIs] inMode:UIDocumentPickerModeImport]; documentProviderMenu.delegate = self; [self presentViewController:documentProviderMenu animated:YES completion:nil];
By default, this will display apps that include a Document Provider extension (such as Dropbox, Google Drive, iCloud, etc.). So if a user has Dropbox or Google Drive installed on their device, these options would show up automatically.
You can also add custom options to the menu by calling the
Swift code example:
let documentProvider = UIDocumentMenuViewController(documentTypes: ["public.image", "public.audio", "public.movie", "public.text", "public.item", "public.content", "public.source-code"], in: .import) documentProvider.delegate = self self.present(documentProvider, animated: true, completion: nil)
This isn’t specifically about Google Drive but at a past job I needed to display Facebook when Apple SDK wasn’t showing me Facebook. (The edge case here was the user’s Facebook account wasn’t in Settings.)
So I grabbed their icon and made a custom entry.
I suspect that you could do the same here. Grab the Google Drive icon and make that a custom Document. And when the user selects it, you hand them off to Google.
This is just a guess since I’ve not used UIDocumentPicker. And also, it is quite hackish.
- Extract Audio from Video AVFoundation
- UILabel (CALayer) is using large amounts of virtual memory
- Bridging an array of enums from Swift to Objective-C
- Objective-C Delegate Type
- Unrecognized selector error for isEqualToString: when setting text of a label
- Switch container view dynamically
- Enforce collectionView to have only 2 rows
- Access an IBOutlet from another class in Swift
- Observing change in frame of a UIView during animation
- Objective-C (cocoa) equivalent to python's endswith/beginswith
- com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: – Error
- Programmatically scroll to a supplementary view within UICollectionView
- _BSMachError XCode 7 Beta
- iOS 7 custom back button
- How can I code sign an iOS .xarchive so a client can resign properly? (using push notifications)