As explained in #11, we can use a JavaScript file to preprocess the webpage before the share extension is activated (See Apple Docs). This is useful if you want to extract the title and URL of the webpage, for example. So far, expo-share-extension used a hard-coded preprocessing.js file to extract some basic data. With this PR, users of this plugin can now provide their own preprocessing file by changing their app.json/app.config.(j|t)s like so:
You must create a class with a run method, which receives an object with a completionFunction method as its argument. This completionFunction method must be invoked at the end of your run method. The argument you pass to it, is what you will receive as the preprocessingResults object as part of initial props.
Using this option enbales NSExtensionActivationSupportsWebPageWithMaxCount: 1 and this is mutually exclusive with NSExtensionActivationSupportsWebURLWithMaxCount: 1, which expo-share-extension enables by default. This means that once you set the preprocessingFile option, you will no longer receive url as part of initial props. However, you can still get the URL via preprocessingResults by using window.location.href in your preprocessing file:
What's new
As explained in #11, we can use a JavaScript file to preprocess the webpage before the share extension is activated (See Apple Docs). This is useful if you want to extract the title and URL of the webpage, for example. So far,
expo-share-extension
used a hard-coded preprocessing.js file to extract some basic data. With this PR, users of this plugin can now provide their own preprocessing file by changing theirapp.json
/app.config.(j|t)s
like so:The
preprocessingFile
option addsNSExtensionActivationSupportsWebPageWithMaxCount: 1
as anNSExtensionActivationRule
. Your preprocessing file must adhere to some rules:run
method, which receives an object with acompletionFunction
method as its argument. ThiscompletionFunction
method must be invoked at the end of yourrun
method. The argument you pass to it, is what you will receive as thepreprocessingResults
object as part of initial props.var
, so that it is globally accessible.For a full example, check this.
Warning
Using this option enbales
NSExtensionActivationSupportsWebPageWithMaxCount: 1
and this is mutually exclusive withNSExtensionActivationSupportsWebURLWithMaxCount: 1
, whichexpo-share-extension
enables by default. This means that once you set thepreprocessingFile
option, you will no longer receiveurl
as part of initial props. However, you can still get the URL viapreprocessingResults
by usingwindow.location.href
in your preprocessing file: