Open file from other app using 'Open with...'

For my app I would like the user to 'share' a file with my app.

Target scenario in iOS:

1. User opens mail with attachment
2. Clicks the file and chooses Share/Open with..
3. From the dialog, the user chooses my app
4. The app opens and gets a parameter with a pointer to the file of some kind

In another app of me (not OutSystems), this is done by changing config.xml:

<platform name="ios">
        <config-file target="*-Info.plist" parent="CFBundleDocumentTypes">

And implementing the function in the app:

window.handleOpenURL(url, delay)

On the other hand, in OutSystems, step 1-3 work, but the function of step 4 (handleOpenURL) is not fired.
How can this be done in OutSystems?

Hello Bram.

Were you able to change the config.xml? And the event still doesn't fire? Or were you unable to change the config.xml?


Thanks for your reply.

The config.xml is changed, since I see the icon in the 'Share with...' dialog. When I tap it, my application launches.

Also, this code is packed in a cordova-plugin which I also use in another app. This way, I know that the change itself should be correct (provided OutSystems works the same way).

A small addition: The function handleOpenURL is added through a included script, by using 'Required scripts' on the module. Relevant part of the script (but tried many other syntaxes):
function handleOpenURL(url delay) { debugger; ... }

Hi Bram,

Which Cordova plugin are you using to implement your scenario? I was never able to get this to work with existing Cordova plugins, so curious to find out if you are more successful. I did create a custom-made plugin that kind of works, i.e. as long as the app is already launched and running in the background.

Hi Denis,

For Android, it is successfully implemented now, with this Cordova plugin: cordova-sharingreceptor.

For iOS, it is successfully implemented in another app, using a custom Cordova plugin.
The relevant part of this (small) plugin is in my first post, and it has a dummy method for Cordova to recognise it. In the end I have the same limitation as in your case.

But in the OutSystems app, the plugin doesn't work anymore. But I understands it works in your case?
Then I am curious: What is the secret of this plugin/OutSystems combination?


I was never able to get the handleOpenURL to fire and work for me, so I gave up on that.  I ended up creating my own iOS plugin, which was a challenge as I am not familiar with Objective-C and iOS and it conflicted with Outsystems' implementation of DeepLinks. But it finally works as long as the app is already launched. Here is my iOS plugin: Sorry, it is not documented.


Hello Bram.

There's a similar issue in this thread: Custom URL Scheme. Someone mentioned:

"Okay - managed to find a workaround: If the handleOpenURL() function has a timeout of 3000 seconds or above - it works (even if the App is initially closed when clicking the external link)."

This seems to be related with the time cordova takes to load. Might be worth a try and taking a closer look at that thread.


Denis Mulder, you are a hero!

It works using your plugin. Many thanks!
I had to make a small adjustment to let it show in the 'Open In..' menu and to pass the whole filepath instead of only the filename. (see attachment)

For firing the event with the app not loaded yet, I couldn't make it work either.
It is hard to debug a Cordova plugin in general, but especially this one, for booting the app (since the debugger is not attached yet). But it looks like the event is not triggered in the plugin itself yet, when I set a local variable in the plugin JavaScript. So it doesn't matter if the app has the subscribe function called yet. But it is sufficient for the app at this moment.

Thanks Cesar as well, but unfortunately this solution didn't work for me.
Since the function exists on the window object it doesn't matter if cordova is initialized yet or not. Even with an interval checking if Cordova exists yet.