Open iCloud Drive in iOS app

I want to allow the selection of a document (pdf, doc, docx) in my application. And I want to integrate iCloud for this. All I want to do is open the iCloud drive from my application, and the user can select the file and go back to the original application. Something like whatsapp to select a document in an iOS app.

Any idea on this?

+7
ios objective-c iphone icloud icloud-drive
source share
1 answer

Read this link below, you will get a presentation: https://developer.apple.com/library/ios/documentation/FileManagement/Conceptual/DocumentPickerProgrammingGuide/AccessingDocuments/AccessingDocuments.html

Below is the code:

-(IBAction)iCloudDriveFullFolder:(id)sender{ UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[@"public.data"] inMode:UIDocumentPickerModeImport]; documentPicker.delegate = self; documentPicker.modalPresentationStyle = UIModalPresentationFormSheet; [self presentViewController:documentPicker animated:YES completion:nil]; } #pragma mark - iCloud files - (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentAtURL:(NSURL *)url { if (controller.documentPickerMode == UIDocumentPickerModeImport) { // NSString *alertMessage = [NSString stringWithFormat:@"Successfully imported %@", [url lastPathComponent]]; //do stuff } } 
+12
source share

All Articles