Pankaj Jangid
Pankaj Jangid

Reputation: 832

How to get iCloud image URL in swift

I am using SwiftAssetsPickerController for fetching images from photo library and iCloud. It provides all images, But those images which are stored in iCloud, do not provide image URL. I need iCloud image URL. So how can I get iCloud images URL?

Upvotes: 1

Views: 1414

Answers (1)

Tak Rahul
Tak Rahul

Reputation: 176

import MobileCoreServices

func setDocumentPicker() {
    let importMenu = UIDocumentMenuViewController(documentTypes: [kUTTypeJPEG as String], in: .import)
    importMenu.delegate = self
    importMenu.modalPresentationStyle = .formSheet
    self.present(importMenu, animated: true, completion: nil)
}

after that you have to call the delegate method of DocumentPicker

func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentAt url: URL) {
    print("URL= \(url)")
}

NOTE: You must have to signed in with iCloud account in your device because you can not access iCloud files directly, and you have to enable iCloud functionality in capabilities in also enable & configure in App ID on apple developer account

Upvotes: 2

Related Questions