You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2020/02/14 05:51:56 UTC

[GitHub] [cordova-plugin-file] crapthings edited a comment on issue #377: cordova-plugin file works on simulator but not real device?

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
   
   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
       }
   }
   ```

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org