Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

202
Vistas
App Extension (Action Extension) doesn’t open

For some reason that I don't understand, the Action Extension Button (in Share menu) doesn't respond. Action extension, at this point, catches the URL from Safari (where it was launched from) to make some things after. As a layer between Web and extension there is JS file (maybe something wrong here, i just copied it)

ViewController:

class ActionViewController: UIViewController {

    var SafariURL: NSURL!

    override func viewDidLoad() {
        super.viewDidLoad()

        
        let extensionItem = extensionContext?.inputItems.first as? NSExtensionItem
               let itemProvider = extensionItem!.attachments?.first as? NSItemProvider
               
               let propertyList = String(kUTTypePropertyList)
               if itemProvider!.hasItemConformingToTypeIdentifier(propertyList) {
                   print("I'm here2")
                   itemProvider!.loadItem(forTypeIdentifier: propertyList, options: nil, completionHandler: { (item, error) -> Void in
                       let dictionary = item as? NSDictionary
                       OperationQueue.main.addOperation {
                           let results = dictionary![NSExtensionJavaScriptPreprocessingResultsKey] as? NSDictionary
                           let urlString = results!["currentUrl"] as? String
                           self.SafariURL = NSURL(string: urlString!)
                       }
                   })
               } else {
                   print("error")
               }
    }

    @IBAction func done() {
        // Return any edited content to the host app.
        // This template doesn't do anything, so we just echo the passed in items.
        self.extensionContext!.completeRequest(returningItems: self.extensionContext!.inputItems, completionHandler: nil)
}

JS File:

var GetURL = function() {};

GetURL.prototype = {
    
run: function(arguments) {
    arguments.completionFunction({ "currentUrl" : document.URL });
},
    
finalize: function(arguments) {
    var message = arguments["statusMessage"];
    
    if (message) {
        alert(message);
    }
}
    
};

var ExtensionPreprocessingJS = new GetURL;
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Finally, you should change a content of override func viewDidLoad to

super.viewDidLoad()

        if let inputItem = extensionContext?.inputItems.first as? NSExtensionItem {
               if let itemProvider = inputItem.attachments?.first {
                   itemProvider.loadItem(forTypeIdentifier: kUTTypePropertyList as String) { [self] (dict, error) in
                       guard let itemDictionary = dict as? NSDictionary else { return }
                       guard let javaScriptValues = itemDictionary[NSExtensionJavaScriptPreprocessingResultsKey] as? NSDictionary else { return }
                       self.Pageurl = javaScriptValues["URL"] as? String ?? ""

JS is ok!

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda