您可以從應用程序清單文件中像這樣(你可以添加多個協議)
<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));
}
要監聽呼叫和實際處理數據tha T的傳遞,這樣做:
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
}
//...
}
希望幫助
乾杯:
-Nick