[英]How to make two AIR IOS application communicate?
One possible solution is using Custom URL: 一种可能的解决方案是使用自定义URL
I follow the following tutorial and then further explore for the communicate for the two AIR applications in IOS. 我按照以下教程 ,然后进一步探索IOS中两个AIR应用程序的通信。 - The first app uses Custom URI "fbMY_APP_ID" as described in your first step, which is alright to be called by Safari.
- 第一个应用程序使用自定义URI“fbMY_APP_ID”,如第一步所述,可以通过Safari调用。 - The second app uses URLRequest with the Custom URI to communicate with first app.
- 第二个应用程序使用带有自定义URI的URLRequest与第一个应用程序进行通信。
I get the error: "SecurityError: Error #2193: Security sandbox violation: navigateToURL: app:/secondApp.swf cannot access tfbMY_APP_ID://test". 我收到错误:“SecurityError:错误#2193:安全沙箱违规:navigateToURL:app:/secondApp.swf无法访问tfbMY_APP_ID:// test”。
According to security sandbox imposed by Adobe AIR, navigateURL is restricted to well-known protocols such as http:, https:, sms:, tel:, mailto:, file:, app:, app-storage:, vipaccess: and connectpro:. 根据Adobe AIR强加的安全沙箱,navigateURL仅限于众所周知的协议,如http:,https:,sms:,tel:,mailto:,file:,app:,app-storage:,vipaccess:和connectpro: 。 You may find more information via here and here .
您可以在此处和此处找到更多信息。
One way to work around is to utilize an html page as intermediate, where the page would relay the calls. 解决方法之一是使用html页面作为中间页面,页面将中继调用。
You can add a custom protocol from the application manifest file like this (you can add more than one protocol) 您可以从应用程序清单文件中添加自定义协议(您可以添加多个协议)
<iPhone>
...
<InfoAdditions>
<![CDATA[
...
<key>CFBundleURLSchemes</key>
<array>
<string>thisIsSomeCustomAppProtocol</string>
</array>
...
]]>
</InfoAdditions>
...
</iPhone>
and you call the custom protocol like this: 你调用这样的自定义协议:
<a href="thisIsSomeCustomAppProtocol://SomeCustomDataString_goes_here&use_url_encoded_strings:">This will call the App with some parameters included (if need be)</a>
Or use navigateToURL(...) like this: 或者像这样使用navigateToURL(...):
var _customURL_str:String = "thisIsSomeCustomAppProtocol://SomeCustomDataString_goes_here&use_url_encoded_strings";
var _isProtocolAvailable:Boolean= URLUtils.instance.canOpenUrl(_customURL_str);
//
if(_isProtocolAvailable)
{
navigateToURL(new URLRequest(_customURL_str));
}
To listen for the call and actualy process the data that's being passed, do this: 要监听呼叫并实际处理正在传递的数据,请执行以下操作:
NativeApplication.nativeApplication.addEventListener(InvokeEvent.INVOKE,_invokeHandler);
The event handler would process the data like this: 事件处理程序将处理这样的数据:
private function onInvoke(e:InvokeEvent):void
{
//...
var _queryString:String = e.arguments[0] ? e.arguments[0] : "";
//
if(_queryString.length > 0){
//handle the incomming data string
}else{
//no extra data string was sent
}
//...
}
hope that helps 希望有所帮助
Cheers: 干杯:
-Nick -缺口
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.