How to show my cordova app in IOS share menu?

2020-03-26 05:38发布

问题:

We have an existing Cordova iOS App for which we need an iOS share extension which will allow Users to to share files from other apps (like Photos, Pages, Numbers, Keynote, etc) with our App (i.e. Export file from Pages to our App).

We need the following delivered:

  • Prototype / Sample iOS Cordova App
  • with a share extension setup up for jpg, png, video, pdf and office (xls, xlsx, doc, docx, ppt, pptx) files
  • Extension to either open the Cordova App directly OR to open the Cordova App as a webview inside the share widget
  • Cordova App must receive parameters about the shared file (filename, path, type, filesize) from extension - the handling of the file afterwards will be done by us.
  • Documentation on how to implement this functionality (share extension) in our existing Cordova App (steps necessary to perform in Xcode etc)

回答1:

There is a cross-platform cordova plugin (iOS and Android) that achieves that: https://github.com/j3k0/cordova-plugin-openwith



回答2:

I think you could find a solution here. It is not clear, but it seems to work.



回答3:

That's a good and still relevant question.

I tried to make use of the awesome cordova-plugin-openwith by Jean-Christophe Hoelt but faced several issues. The plugin is meant to receive share items of one type (say, URL, text or image), which is configured during installation. Also, with its current implementation, writing a note to share and selecting a receiver in a Cordova app are two different steps in different (native and Cordova) context, so it didn't look as a good user experience to me.

I made these and other corrections to this plugin and published it as a separate plugin: https://github.com/EternallLight/cordova-plugin-openwith-ios

Note that it works only for iOS, not for Android.



回答4:

There are few links which could be helpful even if you do not want to use open with plugin

https://irace.me/tumblr-ios-extension

http://engineering.curalate.com/2017/03/09/ios-share-ext-with-ionic.html

In android editing, the manifest worked fine for me. I had to add one more java file added in some already added plugin like below in plugin.xml. Which in turn added in the manifest.

            <intent-filter>
                <action android:name="android.intent.action.SEND" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="image/*" />
                <data android:mimeType="application/pdf"/>
                <data android:mimeType="application/msword"/>
                <data android:mimeType="application/mspowerpoint"/>
                <data android:mimeType="application/powerpoint"/>
                <data android:mimeType="application/vnd.ms-powerpoint"/>
                <data android:mimeType="application/x-mspowerpoint"/>
                <data android:mimeType="application/excel"/>
                <data android:mimeType="application/vnd.ms-excel"/>
                <data android:mimeType="application/x-excel"/>
                <data android:mimeType="application/x-msexcel"/>
                <data android:mimeType="application/vnd.openxmlformats-officedocument.wordprocessingml.document"/>
                <data android:mimeType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"/>
                <data android:mimeType="application/vnd.openxmlformats-officedocument.presentationml.presentation"/>
            </intent-filter>
        </activity>