j3k0 / cordova-plugin-openwith

Get your Cordova App in the O.S. "Share" menu on iOS and Android
MIT License
138 stars 114 forks source link

Multiple mime types #44

Open HarelM opened 5 years ago

HarelM commented 5 years ago

I have the following use case which I need to solve: I would like to open a gpx file. seems easy, but the following is what needs to be added to the manifest:

  <intent-filter>
    <action android:name="android.intent.action.VIEW"/>
    <category android:name="android.intent.category.DEFAULT"/>
    <category android:name="android.intent.category.BROWSABLE"/>
    <data android:mimeType="text/xml"/>
    <data android:mimeType="text/plain"/>
    <data android:mimeType="application/gpx"/>
    <data android:mimeType="application/gpx+xml"/>
    <data android:mimeType="application/octet-stream"/>
    <data android:mimeType="application/xml"/>
    <data android:host="*" android:scheme="http"/>
    <data android:host="*" android:scheme="https"/>
    <data android:host="*" android:scheme="content"/>
  </intent-filter>
  <intent-filter>
    <action android:name="android.intent.action.VIEW"/>
    <category android:name="android.intent.category.DEFAULT"/>
    <category android:name="android.intent.category.BROWSABLE"/>
    <data android:mimeType="*/*"/>
    <data android:host="*" android:pathPattern=".*\.gpx" android:scheme="file"/>
    <data android:host="*" android:pathPattern=".*\..*\.gpx" android:scheme="file"/>
    <data android:host="*" android:pathPattern=".*\..*\..*\.gpx" android:scheme="file"/>
    <data android:host="*" android:pathPattern=".*\..*\..*\..*\.gpx" android:scheme="file"/>
  </intent-filter>

How can I achieve this using this plugin?

HarelM commented 5 years ago

In case anyone is interested: I have managed to use config-file to achieve this. can be seen here: https://github.com/IsraelHikingMap/Site/commit/5059ddff7519e1d4ec6f529db1590255ac3acfdc Which is related to this issue: https://github.com/IsraelHikingMap/Site/issues/820 I don't know if this is a valid solution or a workaround though...

trocker commented 2 years ago

@HarelM - Does this mean you ended up manually adding the other mime types you wanted in config.xml?

HarelM commented 2 years ago

Yes, but I also didn't end up using this plugin since it requires a change in cordova-ios for multiple provisioning profiles, which wasn't merged yet... I added these manually to config.xml and used the intent and deep links plugins, and a hack in iOS. Bottom line, this is complicated, annoying and all solutions feels like a hack... Here is my "mainl final code: https://github.com/IsraelHikingMap/Site/blob/e10acfbfcc15d7f4601bb923581254f3d1ee1f68/IsraelHiking.Web/src/application/services/open-with.service.ts Along side some code in index.html file and config.xml.

trocker commented 2 years ago

Thank you for taking the time to help!