Dav*_* T. 12 iphone objective-c deep-linking ios
如何从我自己的iOS应用程序中找到另一个应用程序的方案并与其进行深层链接?
更具体地说,我想在某些条件下(由我的代码设置)深入链接到Testflight应用程序.我假设这个人安装了Testflight(这可能是一个不好的假设,但我们可以忍受这个假设).
我知道在Android上,您可以查询应用并发送意图以深入链接到其他人的应用.什么是iOS上的等价物?
pic*_*ano 28
你需要做两件事.首先,检查是否安装了TestFlight.然后创建一个指向您应用的新链接.
NSURL *customAppURL = [NSURL URLWithString:@"itms-beta://"];
if ([[UIApplication sharedApplication] canOpenURL:customAppURL]) {
// TestFlight is installed
// Special link that includes the app's Apple ID
customAppURL = [NSURL URLWithString:@"https://beta.itunes.apple.com/v1/app/978489855"];
[[UIApplication sharedApplication] openURL:customAppURL];
}
Run Code Online (Sandbox Code Playgroud)
此特殊https://beta.itunes.apple.com
URL将直接在TestFlight中打开.
最后,如果您使用的是iOS 9(或更高版本),你需要做的除了你的Info.plist获得canOpenURL:
方法工作.
如果您的应用在iOS 9.0上或之后链接,则必须声明要传递给此方法的URL方案.通过在Xcode项目的Info.plist文件中使用LSApplicationQueriesSchemes数组来完成此操作.对于您希望应用程序与此方法一起使用的每个URL方案,请将其添加为此数组中的字符串.
<key>LSApplicationQueriesSchemes</key>
<array>
<string>itms-beta</string>
</array>
Run Code Online (Sandbox Code Playgroud)
通过查看plist,TestFlight的URL方案是"itms-beta://"我无法设置深层链接,我尝试将Apple ID传递给它,有没有?以及使用appleid =前缀,我将尝试下一个捆绑ID.
要在用户设备上打开TestFlight应用程序,您可以使用:
NSURL *customAppURL = [NSURL URLWithString:@"itms-beta://"];
if ([[UIApplication sharedApplication] canOpenURL:customAppURL]) {
[[UIApplication sharedApplication] openURL:customAppURL];
}
Run Code Online (Sandbox Code Playgroud)
斯威夫特 3/4 回答:
if let customAppURL = URL(string: "itms-beta://"){
if(UIApplication.shared.canOpenURL(customAppURL)){
UIApplication.shared.open(customAppURL, options: [:], completionHandler: nil)
}
}
Run Code Online (Sandbox Code Playgroud)
Apple提供的大多数内置应用程序都响应自定义URL方案; 例如,地图,邮件,YouTube,iTunes和App Store应用程序都将打开以响应自定义URL.但是,还有许多已建立的第三方应用程序具有已发布的URL方案,您可以在自己的应用程序中使用它们.您可以搜索应用程序方案
http://wiki.akosma.com/IPhone_URL_Schemes - 两者都有很好的URL方案列表
获得自定义URL方案后,您可以使用相同的架构深层链接到该应用程序,
NSURL *customAppURL = [NSURL URLWithString:@"urlscheme://"];
//Eg: NSURL *whatsappURL = [NSURL URLWithString:@"whatsapp://send?text=Hello%20World!"];
if ([[UIApplication sharedApplication] canOpenURL:whatsAppURL]) {
[[UIApplication sharedApplication] openURL:whatsAppURL]]];
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
11398 次 |
最近记录: |