分支机构无法打开App Store链接 [英] Branch does not open the App Store link

查看:97
本文介绍了分支机构无法打开App Store链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用分支创建深层链接。我添加了一个新的控制参数ios_has_app_url和ios_url。安装应用程序时单击深层链接,然后一切正常,但是如果未在设备上安装应用程序时单击深层链接,则在启动过程中,我会看到浏览器而不是打开ios_url(App Store链接) ,它将尝试打开ios_has_app_url。我该如何解决?

 私人功能createDeepLink(_ card:CardModel)-> (branchUniversalObject:BranchUniversalObject,branchLinkProperties:BranchLinkProperties){
let branchUniversalObject = BranchUniversalObject(canonicalIdentifier:( cardId / \(card.id)))
branchUniversalObject.title = card.title
branchUniversalObject.contentDescription =
branchUniversalObject.imageUrl = card.photoURLsProperties.originalURL

branchUniversalObject.addMetadataKey(CardKeys.cardID.rawValue,值:card.id)

branchUniversalObject.addMetadataKey( placeAvatarURLString,值:card.photoURLsProperties.originalURL)

branchUniversalObject.addMetadataKey( title,值:card.title)
branchUniversalObject.addMetadataKey( isAutoGeneratedCard ,值: false)

让fullLocationName = card.location.fullLocationName
branchUniversalObject.addMetadataKey( fullLocationName,值:fullLocationName)

branchUniversalObject.addMetadataKey (CardKeys.ownerID.rawValue,值:card.ownerID) availableSeats.description)

让坐标= card.location.coordinate
branchUniversalObject.addMetadataKey( latitude,值:coordinate.latitude.description)
branchUniversalObject.addMetadataKey( longitude ,值:coordinate.longitude.description)

让linkProperties = BranchLinkProperties()
linkProperties.feature = sharing
linkProperties.addControlParam( $ desktop_url,withValue: http://www.appname.com)
linkProperties.addControlParam( $ ios_has_app_url,withValue: appname://)
linkProperties.addControlParam( $ ios_url,withValue: https://itunes.apple.com/app/idXXXXXXXXXXXXXXX)

返回(branchUniversalObject:branchUniversalObject,branchLinkPrope rties:linkProperties)
}

更新:我的目标是则当您点击深层链接时,如果已安装该应用程序,则将打开该应用程序;如果未安装,则将打开该应用程序商店链接。



更新1: 我这样更改了我的代码,如果我仅单击链接,它将打开App Store,如果我使用3D Touch,则可以选择在何处打开此链接。如果已安装该应用程序,然后单击链接,则可以立即打开该应用程序(或至少是浏览器中的链接,但可以打开该应用程序),并且如果未安装该应用程序,单击链接,转到App Store应用程序页面。

  let linkProperties = BranchLinkProperties()
linkProperties.feature =共享
linkProperties.addControlParam( $ desktop_url,withValue: http://www.appname.com)
linkProperties.addControlParam( $ ios_has_app_url,withValue: https:/ /appname.app.link/)
linkProperties.addControlParam( $ ios_url,withValue: itms-apps://itunes.apple.com/app/idXXXXXX)


解决方案

来自Branch.io的Alex:



好消息是,这比您预期的要容易得多。但是,由于您做出了如此完整的报告,因此我将详细介绍所有细节,以便您确切了解幕后发生的事情。



简短说明



要处理安装后启动应用程序,您无需手动将自定义URI方案设置为 $ ios_has_app_url -分支机构和iOS通过设计为您实现了此行为。



如果您的链接未启动您的应用,则您可能会遇到问题您的通用链接配置。建议您阅读本故障排除指南



详细说明



我们的 $ ios_has_app_url 控制参数依赖于我们的服务器跟踪的布尔 has_app 值。 has_app 的值在典型的实际使用中相当准确(足够好,可以在显示 Open Install <例如,在智能应用横幅上的/ em>标签),但在所有情况下并非准确率都是100%。



这是一个限制iOS版:Apple不允许网页查询设备上安装了哪些应用程序(出于明显的隐私原因),因此Branch必须依靠Cookie匹配。这意味着如果我们无法匹配Cookie,或者最近没有看到用户,或者用户清除了其设备缓存,或者自上次Branch看到用户以来,用户已卸载了该应用程序,则 has_app 不正确。如果 has_app 值不正确,则 $ ios_has_app_url 行为也将是错误的。



但是,即使Apple不允许网页查询访问此数据,iOS本身仍然可以对其进行操作。通用链接正是这样做的-当用户打开通用链接(假设已完成所有配置时,包括分支链接),则该应用程序将在安装后打开。如果未安装,则会将用户发送到链接的URL。



$ ios_has_app_url



分支机构的预期用途 $ ios_has_app_url 参数用于高级实现中的非常特定的用例;我们绝大多数的合作伙伴从不使用它。这是您可能需要的潜在情况:



您有一个极端的例子,其中不支持通用链接,并且您要将用户发送到如果Branch知道他们已经安装了您的应用,而不是让他们选择打开该应用,则网页会出现。显然,这是一种罕见的情况,通常仅与企业级应用相关。 p>

调试 has_app



如果您想尝试调试 has_app 返回错误值的情况,您有两种选择:


  1. 如果您获得 true ,并且想要 false ,请在Safari中使用私有浏览模式。这可以防止Branch使Cookie匹配,这意味着您将始终

  2. 或者,请遵循这些步骤:


    1. 确保正在测试的应用具有已启用setDebug

    2. 将链接粘贴至

    3. 卸载应用程序。

    4. 设置>常规> Safari>清除历史记录和网站数据。
    5. li>
    6. 设置>常规> Safari>高级>网站数据>向左轻扫并删除每个条目。

    7. 设置>常规>隐私>广告>重置广告标识符。 ..

    8. 单击Notes中的链接(来自步骤1)。

    9. 横幅应始终显示下载(如果没有,这是因为清除网站数据失败)。

    10. 点击下载。

    11. 通过Xcode运行该应用程序(用于安装)。

    12. 在Xcode中停止该应用程序,然后从手机启动它。

    13. 再次单击Notes中的链接-按钮现在应显示打开并打开应用程序。

  3. $ li $ b


I use Branch to create deep links. I added a new control parameter ios_has_app_url and ios_url. Clicking on the deep link when the application is installed then everything works correctly, but if you click on the deep link when the application is not installed on the device then during startup, I see that the browser instead of opening ios_url (App Store link), it tries to open ios_has_app_url. How can I fix it?

private func createDeepLink(_ card: CardModel) -> (branchUniversalObject: BranchUniversalObject, branchLinkProperties: BranchLinkProperties) {
    let branchUniversalObject = BranchUniversalObject(canonicalIdentifier: ("cardId/\(card.id)"))
    branchUniversalObject.title = card.title
    branchUniversalObject.contentDescription = ""
    branchUniversalObject.imageUrl = card.photoURLsProperties.originalURL

    branchUniversalObject.addMetadataKey(CardKeys.cardID.rawValue, value: card.id)

    branchUniversalObject.addMetadataKey("placeAvatarURLString", value: card.photoURLsProperties.originalURL)

    branchUniversalObject.addMetadataKey("title", value: card.title)
    branchUniversalObject.addMetadataKey("isAutoGeneratedCard", value: "false")

    let fullLocationName = card.location.fullLocationName
    branchUniversalObject.addMetadataKey("fullLocationName", value: fullLocationName)

    branchUniversalObject.addMetadataKey(CardKeys.ownerID.rawValue, value: card.ownerID)
    branchUniversalObject.addMetadataKey(ParametersKeywords.type.rawValue, value: ModeKeywords.shareCard.rawValue)

    branchUniversalObject.addMetadataKey("availableSeats", value: card.peopleProperties.availableSeats.description)

    let coordinate = card.location.coordinate
    branchUniversalObject.addMetadataKey("latitude", value: coordinate.latitude.description)
    branchUniversalObject.addMetadataKey("longitude",value: coordinate.longitude.description)

    let linkProperties = BranchLinkProperties()
    linkProperties.feature = "sharing"
    linkProperties.addControlParam("$desktop_url", withValue: "http://www.appname.com")
    linkProperties.addControlParam("$ios_has_app_url", withValue: "appname://")
    linkProperties.addControlParam("$ios_url", withValue: "https://itunes.apple.com/app/idXXXXXXXXXXXXXXX")

    return (branchUniversalObject: branchUniversalObject, branchLinkProperties: linkProperties)
}

Update: My goal is that when the deep link is clicked, if the application is installed, then the application is opened, if not, then the app store link.

Update 1: I changed my code like this and it opens the App Store if I just click on the link, and if I use 3D Touch then I can choose where to open this link. Is it possible to do that if the application is installed and clicking on the link immediately opened the application (or at least a link in the browser, but that there was an option to open the application) and if the application is not installed, then clicking on the link, go to the App Store app page .

let linkProperties = BranchLinkProperties()
        linkProperties.feature = "sharing"
        linkProperties.addControlParam("$desktop_url", withValue: "http://www.appname.com")
        linkProperties.addControlParam("$ios_has_app_url", withValue: "https://appname.app.link/")
        linkProperties.addControlParam("$ios_url", withValue: "itms-apps://itunes.apple.com/app/idXXXXXX")

解决方案

Alex from Branch.io here:

The good news is this is much easier than you're expecting. However, since you made such a complete report, I'll go through all the details so you know exactly what happens behind the scenes.

Short Explanation

To handle launching your app when it is installed, you don't need to manually set your custom URI scheme as the value of $ios_has_app_url — Branch and iOS implement this behavior for you by design.

If your links are not launching your app, you may have a problem with your Universal Links configuration. I recommend reviewing this troubleshooting guide.

Long Explanation

Our $ios_has_app_url control parameter relies on a boolean has_app value tracked by our servers. The has_app value fairly accurate in typical real-world use (plenty good enough for switching a button between displaying an Open or an Install label on a smart app banner, for example), but it's not 100% accurate in all situations.

This is a limitation of iOS: Apple doesn't allow web pages to query for which apps are installed on a device (for obvious privacy reasons), so Branch has to rely on cookie matching. This means if we can't match the cookie, or haven't seen the user recently, or the user clears their device cache, or the user has uninstalled the app since the last time Branch saw them, the value of has_app will be incorrect. When the has_app value is incorrect, then the $ios_has_app_url behavior will also be wrong.

HOWEVER, even though Apple doesn't allow web pages to query access this data, iOS itself can still act on it. Universal Links do exactly this — when the user opens a Universal Link (which includes Branch links, assuming you got all the configuration done), the app will open if it is installed. If it is not installed, the user will be sent to the URL of the link.

Intended use of $ios_has_app_url

The Branch $ios_has_app_url parameter is intended for a very specific usecase in advanced implementations; the vast majority of our partners never use it. Here's the potential situation where you might want it:

You have an edge case where Universal Links are not supported, and you want to send your users to a different web page if Branch knows they have your app installed rather than giving them the option to open it. Obviously this is a rare situation, typically relevant only to enterprise-level apps.

Debugging has_app

If you're stuck trying to debug a situation where has_app is returning the wrong value, you have a couple of options:

  1. If you're getting true and you want false, use Private Browsing mode in Safari. This prevents Branch from making a cookie match, meaning you will always get false.
  2. Alternatively, follow these steps:

    1. Ensure the app that is being tested has setDebug enabled.
    2. Paste a link to a page with the smart banner code into Notes.
    3. Uninstall the app.
    4. Settings > General > Safari > Clear History and Website Data.
    5. Settings > General > Safari > Advanced > Website Data > Swipe left and delete every entry.
    6. Settings > General > Privacy > Advertising > Reset Advertising Identifier...
    7. Click on the link in Notes (from step 1).
    8. The banner should always show "Download" (when it does not, it is because clearing the Website Data was unsuccessful).
    9. Tap on Download.
    10. Run the app via Xcode (serves to install it).
    11. Stop the app in Xcode, then launch it from the phone.
    12. Click on the link in Notes again - the button should now show "Open" and open the app.

这篇关于分支机构无法打开App Store链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆