0

I save a pdf on local like this :

   func saveMandatPdf(pdfBase64 : String, idMandat : String) -> Bool{
    guard
        var documentsURL = (FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)).last,
        let convertedData = Data(base64Encoded: pdfBase64, options: .ignoreUnknownCharacters)
        else {
            return false
    }
    let fileName = "\(idMandat).pdf"
    documentsURL.appendPathComponent(fileName)
    do {
     try convertedData.write(to: documentsURL, options: .atomic)
        return true
    } catch {
     print(error)
        return false
    }
  }. 

i checked that i can see the pdf with webview, so everything work the file is saved i can see it on seimulator tmp folder

but on a real device when i check on the application "books" i can't find this pdf files

here is the application where is search foe my pdf

thank you for your help

tamtoum1987
  • 1,957
  • 3
  • 27
  • 56
  • This may help: https://stackoverflow.com/questions/15219511/theres-a-way-to-access-the-document-folder-in-iphone-ipad-real-device-no-simu – Dharmesh Kheni Mar 23 '20 at 18:26
  • @DharmeshKheni yes it helps but how can i save my file on a public folder that all the applications can see it ? application like books ? – tamtoum1987 Mar 23 '20 at 18:37
  • 1
    you can use `UIActivityViewController` for that where users can choose if they want to save it to files – Dharmesh Kheni Mar 23 '20 at 18:40
  • save to files, it's exactly what i need i will try it – tamtoum1987 Mar 23 '20 at 19:05
  • @tamtoum1987 you can't save anything to Files. You need to allow the user to do so https://stackoverflow.com/questions/46456481/how-to-write-a-file-to-a-folder-located-at-apples-files-app-in-swift/46457518?r=SearchResults&s=1|51.5553#46457518. If you would like to make your document directory appear on the folder "On My Phone" of the Files app exposing it to other apps I can show you how to accomplish it. – Leo Dabus Mar 24 '20 at 00:34

0 Answers0