使用ios 8应用程序[swift]打开邮件附件
在我的应用程序中,我设计了一种新的加密类型数据作为邮件附件。当我从另一个用户收到相同类型的附件(filename.filetype)时,我希望邮件中的附件在我的应用程序中打开。我浏览了动作扩展教程。但是,缺少的是,如何使用我的swift应用程序打开特定类型的附件。我在Obj-C以及以前版本的iOS中得到了答案。我正在iOS8中寻找答案,Swift处理该文件 这是我的信息列表使用ios 8应用程序[swift]打开邮件附件,swift,email,email-attachments,ios-app-extension,uti,Swift,Email,Email Attachments,Ios App Extension,Uti,在我的应用程序中,我设计了一种新的加密类型数据作为邮件附件。当我从另一个用户收到相同类型的附件(filename.filetype)时,我希望邮件中的附件在我的应用程序中打开。我浏览了动作扩展教程。但是,缺少的是,如何使用我的swift应用程序打开特定类型的附件。我在Obj-C以及以前版本的iOS中得到了答案。我正在iOS8中寻找答案,Swift处理该文件 这是我的信息列表 <key>UTExportedTypeDeclarations</key> <array&g
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
<key>UTTypeDescription</key>
<string>pvt file</string>
<key>UTTypeIdentifier</key>
<string>com.pryvateBeta.pvt</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<string>pvt</string>
</dict>
</dict>
</array>
<key>CFBundleDocumentsType</key>
<array>
<dict>
<key>CFBundleTypeIconFiles</key>
<array/>
<key>CFBundleTypeName</key>
<string>pvt file</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSHandlerRank</key>
<string>Owner</string>
<key>LSItemContentTypes</key>
<array>
<string>com.pryvateBeta.pvt</string>
</array>
</dict>
</array>
首先,您需要声明应用程序将在应用程序中处理的文件类型
Info.plist
例如,下面显示的配置声明应用程序能够打开基本上是XML的.lumenconfig
文件
首先,您需要声明应用程序将在应用程序中处理的文件类型
Info.plist
例如,下面显示的配置声明应用程序能够打开基本上是XML的.lumenconfig
文件
我无法解决此Obj-C。我正在用Swift查找参考或答案。我无法解决此Obj-C。我正在用Swift查找参考或答案。这是操作扩展名的info.plist吗?@MohammedJanish否。在应用程序中打开文件不需要扩展名。这是应用程序本身的Info.plist。public.xml UTTypeIdentifier at.zujab.lumen.lumenconfig UTTypeDescription lumen配置文件这些行代表什么?AppDelegate中要给出的url是什么?这是邮件应用程序的url吗?@MohammedJanish在那里我声明了我自己的类型。我正在使用一个名为
lumenconfig
的自定义类型,iOS不知道该类型。当然,URL指向文件(当您点击电子邮件附件并选择“在中打开”时)。这是操作扩展名的info.plist吗?@MohammedJanish否。在应用程序中打开文件不需要扩展名。这是应用程序本身的Info.plist。public.xml UTTypeIdentifier at.zujab.lumen.lumenconfig UTTypeDescription lumen配置文件这些行代表什么?AppDelegate中要给出的url是什么?这是邮件应用程序的url吗?@MohammedJanish在那里我声明了我自己的类型。我正在使用一个名为lumenconfig
的自定义类型,iOS不知道该类型。当然,URL指向该文件(当您点击电子邮件附件并选择“在中打开”时)。
func application(application: UIApplication, openURL Url: NSURL, sourceApplication: String?, annotation: AnyObject?) -> Bool {
let encrypteddata = NSData(contentsOfURL: Url)
return true}
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<!-- The name of this file type. -->
<string>Lumen Configuration</string>
<key>CFBundleTypeIconFiles</key>
<!-- The name of this file type. -->
<array/>
<key>LSItemContentTypes</key>
<!-- The different type identifiers that are handled
as this type of file. -->
<array>
<!-- This is a custom type I declare below -->
<string>at.zujab.lumen.lumenconfig</string>
</array>
</dict>
</array>
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<!-- How these files are structured -->
<array>
<string>public.xml</string>
</array>
<key>UTTypeIdentifier</key>
<!-- This is the identifier for the custom type -->
<string>at.zujab.lumen.lumenconfig</string>
<key>UTTypeDescription</key>
<!-- How your app calls these files. -->
<string>Lumen Configuration File</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<!-- The extension of the files of this type -->
<string>lumenconfig</string>
</dict>
</dict>
</array>
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
//....
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject?) -> Bool {
//url contains a URL to the file your app shall open
//In my EXAMPLE I would want to read the file as a dictionary
let dictionary = NSDictionary(contentsOfURL: url)
}
}