每当用户点击我们网站的网址时,我想允许我的用户打开我们的应用(如果安装,否则重定向到App Store应用页面)。
我发现通用链接是从iOS-9开始实现上述要求的一种方式。我也知道Web服务器和Apple Developer门户网站要涵盖的要点。
唯一的问题是如何在Appcelerator Titanium app中启用关联域?
提前感谢任何线索或帮助。
答案 0 :(得分:6)
我们通过此流程在我们的制作应用上为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)现在要实际捕获深层链接点击+网址,您需要收听以下事件: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(一个单行)但它不会被包含在官方的.GA sdk中直到5.4.0听到(计划于6月发布)。
如果您还有其他问题,Ti Slack群组聊天也是一个很好的地方(一大堆活跃用户)。