您可以像这样从应用程序清单文件中添加自定义协议(您可以添加多个协议)
<iPhone>
...
<InfoAdditions>
<![CDATA[
...
<key>CFBundleURLSchemes</key>
<array>
<string>thisIsSomeCustomAppProtocol</string>
</array>
...
]]>
</InfoAdditions>
...
</iPhone>
你这样调用自定义协议:
<a href="thisIsSomeCustomAppProtocol://SomeCustomDataString_goes_here&use_url_encoded_strings:">This will call the App with some parameters included (if need be)</a>
或者像这样使用 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));
}
要侦听呼叫并实际处理正在传递的数据,请执行以下操作:
NativeApplication.nativeApplication.addEventListener(InvokeEvent.INVOKE,_invokeHandler);
事件处理程序将像这样处理数据:
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
}
//...
}
希望有帮助
干杯:
-缺口