通过这个过程,我们在生产应用程序上为 ios + android 提供了通用链接(基于AppC Handoff Sample App:
1) 将 Apple Dev Center 上的关联域添加到应用程序 -> 这将生成一个新的配置文件,您将使用它来构建 Titanium。
2) 您需要显式编辑您的 Entitlments.plist 文件,通常这是由 Ti 自动生成的。要获取此文件的副本,请执行以下操作:
a) Build app for device
b) Navigate to project\build\iphone
c) Find the generated Entitlments.plist file
3) 将此文件复制到项目的根文件夹并在“dict”节点下添加以下内容:
<key>com.apple.developer.associateddomains</key>
<array>
<string>applinks:www.example.com</string>
</array>
这应该创建必要的数据以将应用绑定到正确的网站以进行链接。
4) 现在要实际捕获深层链接点击 + url,您需要监听以下事件:Ti.App.iOS.continueactivity
例如:
Ti.App.iOS.addEventListener('continueactivity', function(e){
//Since this event can be fired from multiple cases
//we need to check if it was a deeplink that fired it
if(e.activityType === "NSUserActivityTypeBrowsingWeb"){
//Since it WAS from a deeplink, the event response contains some
//other useful data (see the docs link)
var deepLinkURL = e.webpageURL;
//From here you can navigate the app to a relevant page etc...
}
};
遗憾的是,此功能在 sdk 5.X 中被破坏,已在此处修复:TIMOB-20220(单行)但据我所知,直到 5.4.0 才会包含在官方 .GA sdk 中(计划于 6 月发布)。
如果您还有其他问题,Ti Slack 群聊也是一个很好的提问场所(一大群活跃用户)。