crapthings edited a comment on issue #377: cordova-plugin file works on 
simulator but not real device?
URL: 
https://github.com/apache/cordova-plugin-file/issues/377#issuecomment-586109132
 
 
   @breautek let me see
   
   it looks i don't have "private in url"
   
   my real device is running on iphone 6s ios 12.0
   
   i've tested 11 ~ 13 on sim, all works well
   
   
   
   this is part of swift code
   
   ```swift
   @objc(ShareExtension) class ShareExtension: CDVPlugin {
       var _command: CDVInvokedUrlCommand?
   
       override func pluginInitialize() {
           super.pluginInitialize()
           NotificationCenter.default.addObserver(
               self,
               selector: #selector(sendUrls),
               name: NSNotification.Name("CDVPluginHandleOpenURLNotification"),
               object: nil
           )
       }
   
       @objc func sendUrls() {
           let userDefaults = UserDefaults(suiteName: 
"group.com.idibwofa6eg9w4.bk46f44qira.shareextension")!
           let urls = userDefaults.array(forKey: "urls")
           let result = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: 
urls)
           result!.keepCallback = true
           self.commandDelegate.send(result, callbackId: _command!.callbackId!)
       }
   
       @objc(onFiles:) func onFiles(command: CDVInvokedUrlCommand) {
           self._command = command
       }
   }
   ```
   
   ```swift
   import MobileCoreServices
   import UIKit
   
   class ShareViewController: UIViewController {
       @IBOutlet weak var textarea: UITextView!
       @IBOutlet weak var done: UIButton!
   
       var userDefaults = UserDefaults(suiteName: 
"group.com.idibwofa6eg9w4.bk46f44qira.shareextension")!
   
       override func viewDidLoad() {
           super.viewDidLoad()
   
           var urls: [String] = []
   
           guard let extensionItems = extensionContext?.inputItems as? 
[NSExtensionItem] else {
               return
           }
   
           let group = DispatchGroup()
   
           for extensionItem in extensionItems {
               if let itemProviders = extensionItem.attachments {
                   for itemProvider in itemProviders {
                       group.enter()
                       itemProvider.loadItem(forTypeIdentifier: kUTTypeItem as 
String, options: nil, completionHandler: { text, error in
                           urls.append("\(text!)")
                           group.leave()
                       })
                   }
               }
           }
   
           group.notify(queue: .main) {
               self.userDefaults.set(urls, forKey: "urls")
               self.userDefaults.synchronize()
               self.textarea.insertText("done \(urls) \n\n")
               self.openURL(URL(string:"openwith://test")!)
               self.extensionContext!.completeRequest(returningItems: [], 
completionHandler: nil)
           }
       }
   
       @IBAction func btn(_ sender: UIButton) {
           self.openURL(URL(string:"openwith://test")!)
           self.extensionContext!.completeRequest(returningItems: [], 
completionHandler: nil)
       }
   
       @objc func openURL(_ url: URL) -> Bool {
           var responder: UIResponder? = self
           while responder != nil {
               if let application = responder as? UIApplication {
                   return application.perform(#selector(openURL(_:)), with: 
url) != nil
               }
               responder = responder?.next
           }
           return false
       }
   }
   ```
   
   and 
   
   console.log(cordova.file)
   
   
![image](https://user-images.githubusercontent.com/1147704/74507254-d6469680-4f36-11ea-9f35-96ff2292834d.png)
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to