I want to allow document(pdf, doc, docx) selection in my app. And I want to integrate iCloud for this. All I want to do is to open the iCloud drive from my app and there user can select the file and returns back to the origin app. Something like whatsapp has done for document selection in iOS app.
Any idea regarding this?
To access iCloud Drive files in the Files app: Open Files on your iPhone or iPad. Repeatedly tap the Browse button at the bottom until you see a list of Locations. Tap iCloud Drive to view all the files in your iCloud account.
Open a file once with a specific appSelect the file in the Finder, choose File > Open With, then choose an app. Control-click the file, choose Open With, then choose an app. Open the app, then choose File > Open.
Read this below link you will get idea: 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
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With