从另一个应用程序打开TestFlight应用程序并深入链接到特定应用程序

从另一个应用程序打开TestFlight应用程序并深入链接到特定应用程序

问题描述:

如何从我自己的iOS应用程序中找到另一个应用程序的方案及其深层链接?

How do i find the scheme of another app and deep link to it from my own iOS app?

更具体地说,我想深入链接到Testflight应用程序在某些条件下(由我的代码设置)。我假设这个人安装了Testflight(这可能是一个不好的假设,但我们可以忍受这个假设)。

More specifically, I want to deep link to the Testflight app upon certain conditions (set by my code). I'm assuming the person has Testflight installed, (which might be a bad assumption but we can live with that assumption).

我知道在Android上,你可以查询对于应用程序和发送意图深入链接到其他人的应用程序。 iOS上的等价物是什么?

I know that on Android, you can query for apps and send intents to deep link to someone else's app. What would be the equivalent on iOS?

您需要做两件事。首先,检查是否安装了TestFlight。然后创建一个指向您应用的新链接。

There are two things you need to do. First, check to see if TestFlight is installed. Then create a new link to your app.

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];
}

此特殊 https://beta.itunes。 apple.com URL将直接在TestFlight中打开。

This special https://beta.itunes.apple.com URL will be opened directly in TestFlight.

最后,如果您使用的是iOS 9(或更高版本),则需要制作添加到Info.plist以获取 canOpenURL:方法。

Finally, if you are using iOS 9 (or later), you need to make an addition to your Info.plist to get the canOpenURL: method to work.


如果您的应用在iOS 9.0上或之后链接,则必须声明要传递给此方法的URL
方案。通过在Xcode项目的Info.plist
文件中使用
LSApplicationQueriesSchemes数组来完成此操作。对于您希望应用程序使用此方法的每个URL方案,
将其添加为此数组中的字符串。

If your app is linked on or after iOS 9.0, you must declare the URL schemes you want to pass to this method. Do this by using the LSApplicationQueriesSchemes array in your Xcode project’s Info.plist file. For each URL scheme you want your app to use with this method, add it as a string in this array.



<key>LSApplicationQueriesSchemes</key>
<array>
    <string>itms-beta</string>
</array>