AIR IOS应用注册文件类型,由第三方APP通过Open with启动

在IOS里,这个叫Document Interaction ,通过在info.plist文件里进行设置实现文件关联
在AIR里,-app.xml文件内iphone/InfoAdditions下的key/value内容都会被添加到info.plist. 内容参考IOS的即可
<key>CFBundleDocumentTypes</key> // 文档类型
  <array>
    <dict>  // 每个Dict对应一个类型
      <key>CFBundleTypeName</key>
      <string>txt</string>
      <key>LSHandlerRank</key>
      <string>Owner</string> // 设为Owner时,文档会COPY到documents/inbox文件夹下
      <key>LSItemContentTypes</key>
      <array>
        <string>com.youapp.txt</string>
        <string>public.plain-text</string>
      </array>  
    </dict>
  </array>
<key>UTExportedTypeDeclarations</key> // 导出类型定义
  <array>
    <dict>  每个Dict对应一个类型
      <key>UTTypeConformsTo</key>
      <array>
        <string>public.plain-text</string>
        <string>public.text</string>
      </array>
      <key>UTTypeDescription</key>
      <string>Text File</string>
      <key>UTTypeIdentifier</key>
      <string>com.youapp.txt</string>
      <key>UTTypeTagSpecification</key>
      <dict>
        <key>public.filename-extension</key>
        <string>txt</string>
        <key>public.mime-type</key>
        <string>text/plain</string>
      </dict>
    </dict>
  </array>
AIR应用通过InvokeEvent事件可接收到文件进行后续处理.

private function preinitializeHandler():void {
  NativeApplication.nativeApplication.addEventListener(InvokeEvent.INVOKE, invokeHandler);
}
private function invokeHandler(event:InvokeEvent):void {
  var items:Array = event.arguments;
  if( items.length > 0 ) {
    var file:File = new File( event.arguments[0] );
    // your code …
  }    
}
来源:Apps开发网