Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open iCloud Drive in iOS app

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?

like image 465
Rohitax Rajguru Avatar asked May 31 '16 09:05

Rohitax Rajguru


People also ask

How do I access the iCloud Drive app?

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.

How do I open a File with a specific app iOS?

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.


1 Answers

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

    }
}
like image 147
Bhadresh Mulsaniya Avatar answered Oct 06 '22 01:10

Bhadresh Mulsaniya