title: Save file after it is imported to app
body: <p>I have an iOS app that I would like to save a file that is given to it when a user on Safari downloads a file and chooses "Import with <em>MYAPP</em>"</p>
  
  <p>I've already got the part where it recognizes that my app supports the file down but when I choose to open the file with the app, it isn't being added.</p>
  
  <p>There is really not much documentation on this, or at least nothing recent. Here is my failed attempt at saving the file:</p>
  
  <pre><code>func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?, openURL Url: NSURL, sourceApplication: String?, annotation: AnyObject?) -&gt; Bool {
  
      let encrypteddata = NSData(contentsOf: Url as URL)
      if(encrypteddata != nil){
  
          let fileManager = FileManager.default
          let paths = (NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as NSString).appendingPathComponent("test.ipa")
          print(paths)
          fileManager.createFile(atPath: paths as String, contents: encrypteddata as Data?, attributes: nil)
  
      }
  return true
  
  }
  </code></pre>
  
  <p>Update:</p>
  
  <p>It seems that the files are stored in the Documents/Inbox directory in the app's sandbox container. How can I list all of the files and read their contents?</p>