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

191
Vistas
ios share extension - how to get image URL?

I am writing an action extension to transform an image URL and copy to clipboard by clicking the share button of an image on a webpage in Safari.

I created an action extension in Xcode without UI.

In javascript preprocessing script action.js, I can get the URL and title of the whole page.

    run: function(arguments) {
        
        arguments.completionFunction({
            "URL" : document.URL,
            "title": document.title
        })
    },

And that works for the share button of the whole webpage.

But how can I get the URL of the image that is pushed one?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

When you use from URL, its better to use from :

  pod 'SDWebImage'

this is better because of cache

you can Set your URL string with below code:

libraryImageView.sd_setImage(with: URL(string: "your URL string"),
                                  placeholderImage: UIImage(named: Image.placeholder.rawValue))

after that you can get URL with below code:

libraryImageView.sd_ImageURL

enter image description here

about 4 years ago · Juan Pablo Isaza Denunciar

0

Answering my own question. I had to create an action extension with User Interface so that I am working within ActionViewController: UIViewController class. The trick is to look for UTType.url.identifier through the shared items.

The code below works for share button of the whole webpage and an image.

    override func viewDidLoad() {
        super.viewDidLoad()
    
        // search for url
        var found = false
        for item in self.extensionContext!.inputItems as! [NSExtensionItem] {
            for provider in item.attachments! {
                if provider.hasItemConformingToTypeIdentifier(UTType.url.identifier) {
                    provider.loadItem(forTypeIdentifier: UTType.url.identifier, options: nil, completionHandler: { (url, error) in
                        OperationQueue.main.addOperation {
                                if let url = url as? URL {
                             
          // do something with the url here
                            
                       }

                    }})
                    
                    found = true
                    break
                }
            }
            
            if (found) {
                // We only handle one url, so stop looking for more.
                break
            }
        }

        // don't show user interface
        self.done()
    }

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