Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use Dynamic Javascript in iOS Share Extension

I am developing a share extension for iOS 8 and it seem like i can run javascript code on page to grab some information like markup of the mage

But on the apple document it says that javascript code must be inside a .js file but my javascript code is coming from server and it is dynamic.

Is it possible to run javascript i downloaded from server or can I change js file contents everytime I need to use it?

like image 357
Shashank Kulshrestha Avatar asked Mar 22 '26 06:03

Shashank Kulshrestha


1 Answers

You can't do this using the built-in support in the current share extension system.

The Javascript file needs to be listed by name in the extension's Info.plist, in the value of the NSExtensionJavaScriptPreprocessingFile key. The file named there needs to exist in the app extension's bundle. But bundles are not writeable, so you can't replace or change the file.

You might be able to do something like you describe if you:

  1. Include a basic JS file that just returns the entire page source to your extension.
  2. Use JavaScriptCore.framework to further process that data in your extension.

I don't know of any reason why that wouldn't work, but I haven't tried it, and it's kind of unusual. Still, given your needs, it's worth investigating.

like image 138
Tom Harrington Avatar answered Mar 23 '26 20:03

Tom Harrington



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!