Posts

Showing posts from July, 2022

Document picker pdf file upload to server working in simulator but not working on real device iOS swift

 Solution: Because it had security issues for accessing the storage in real device.So follow the below code to copy the data or file to the document directory or your local variable after that upload it to the server.Then no issue will be appear. startAccessingSecurityScop edResource must be called for storage access func   documentPicker ( _  controller:  UIDocumentPickerViewController ,  didPickDocumentsAt  urls: [ URL ]) {              guard  controller. documentPickerMode  == . open ,  let  url = urls. first , url. startAccessingSecurityScop edResource ()  else  {  return  }              defer  {                 DispatchQueue. main . async  {                     url. stopAccessingSecurityScope dResource ()         ...

Select PDF file and upload to server in iOS swift || PDF picker in iOS

  Solution : In iOS we can now upload pdf files from your local device to server.Follow the below steps to achieve.. First you must have the deployment target above 14 in your app. Before you have to import the below frameworks in your project import MobileCoreServices  import UniformTypeIdentifiers Then use the below function      //     MARK: - File selection      @available ( iOS  14.0, *)      func   selectFiles () {          let  supportedTypes = [ UTType . image ,  UTType . text ,  UTType . plainText ,  UTType . utf8PlainText ,     UTType . utf16ExternalPlainText ,  UTType . utf16PlainText ,     UTType . delimitedText ,  UTType . commaSeparatedText ,     UTType . tabSeparatedText ,  UTType . utf8TabSeparatedText ,  UTType . rtf ,     UTType . pdf ,  UTType . webArchive ,...