Cordova将文件types注册为“打开”列表

我想注册我的离子应用程序(通过cordova)打开某些文件types。 就像Dropbox一样。 当用户在另一个应用程序(如电子邮件)上有一个文件,他点击“打开”,有一个包含Dropbox应用程序的列表。

下面是来自Apple的教程: https : //developer.apple.com/library/ios/documentation/FileManagement/Conceptual/DocumentInteraction_TopicsForIOS/Articles/RegisteringtheFileTypesYourAppSupports.html

有没有支持Android和iOS的Cordova插件,并提供一个JS API的function? 提前致谢。

您可以在Cordova中实现FileType关联。

它包括2个步骤。

1)在Android Manifest / iOS plist中注册文件为

performance

<intent-filter android:icon='@drawable/ic_launcher' android:label='AndroidMHT File' android:priority='1'> <action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.EDIT" /> <action android:name="android.intent.action.PICK" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:mimeType="*/*" /> <data android:pathPattern="*.mht" /> </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:scheme="http" android:host="*" android:pathPattern=".*\\.mht" /> <data android:scheme="https" android:host="*" android:pathPattern=".*\\.mht" /> </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="message/rfc822" android:scheme="http" /> <data android:mimeType="multipart/related" android:scheme="http" /> <data android:mimeType="message/rfc822" android:scheme="https" /> <data android:mimeType="multipart/related" android:scheme="https" /> </intent-filter> 

plist中

 <key>CFBundleDocumentTypes</key> <array> <dict> <key>CFBundleTypeIconFiles</key> <array> <string>Document-molecules-320.png</string> <string>Document-molecules-64.png</string> </array> <key>CFBundleTypeName</key> <string>Molecules Structure File</string> <key>CFBundleTypeRole</key> <string>Viewer</string> <key>LSHandlerRank</key> <string>Owner</string> <key>LSItemContentTypes</key> <array> <string>com.sunsetlakesoftware.molecules.pdb</string> <string>org.gnu.gnu-zip-archive</string> </array> </dict> </array> 

2)使用Cordova的File Opener插件

您可能需要传递必要的标志来打开这些文件。

参考: Android , iOS和一个phonegap社区论坛主题

希望能帮助到你。

检查这个链接 。 关于Let'sRefactor它是正确的除了fileopener,意图你应该确定什么函数调用(在本地)当用户打开文件与您的应用程序。 这一切都在上面的链接解释。