The branch does not open the link on the App Store

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

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 I click on the deep link, if the application is installed, then the application opens, if not, then the link to the application store.

Update 1: I changed my code this way 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 this if the application is installed and clicking on the link immediately opened the application (or at least the link in the browser, but it was possible to open the application), and if the application is not installed, then clicking on the link, go to the App Store application 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") 
0
source share
2 answers

Alex from Branch.io here:

The good news is that it is much easier than you expect. However, since you made such a complete report, I will go through all the details so that you know exactly what is going on behind the scenes.

Brief explanation

To handle the launch of the application upon installation, you do not need to manually set your custom URI scheme as a value of $ios_has_app_url - Branch and iOS implement this design behavior for you.

If your links do not start your application, you may have a problem setting up Universal Links. I recommend that you review this troubleshooting guide .

Long explanation

Our control parameter $ios_has_app_url depends on the value of boolean has_app , which is monitored by our servers. The has_app value has_app pretty accurate in typical real-time mode (good enough to switch the button between displaying the Open or Install label on a smart application banner, for example), but not 100% accurate in all situations.

This is a limitation of iOS: Apple does not allow web pages to request which applications are installed on the device (for obvious privacy reasons), therefore Branch must rely on cookie compliance. This means that if we cannot match the cookie or have not seen the user recently, or the user will clear the device’s cache, or the user has deleted the application since the last time he saw it, the has_app value will be incorrect. If the has_app value has_app incorrect, the behavior of $ios_has_app_url will also be incorrect.

HOWEVER, although Apple does not allow web pages to request access to this data, iOS itself can still act on it. Universal Links do just that - when a user opens a universal link (which includes branches, provided that you have made the entire configuration), the application will open if it is installed. If it is not installed, the user will be sent to the link URL.

Intended use of $ios_has_app_url

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

You have a boundary case where Universal Links are not supported , and you want to send your users to another web page if Branch knows they are installing your application, and do not give them the opportunity to open it. Obviously, this is a rare situation, usually related only to enterprise-level applications.

Debug has_app

If you are stuck trying to debug a situation where has_app returns the wrong value, you have several options:

  • If you get true and want false , use the private browsing mode in Safari. This prevents the creation of a cookie branch, which means you always get false .
  • Alternatively, follow these steps:
    • Ensure that the setDebug application under test is enabled .
    • Paste the link to the smart banner code page in Notes.
    • Uninstall the application.
    • Settings> General> Safari> Clear website history and data.
    • Settings> General> Safari> Advanced> Website Data> Swipe left and delete each entry.
    • Settings> General> Privacy> Advertising> Reset Advertising ID ...
    • Click the link in Notes (from step 1).
    • The banner should always show “Download” (when it’s not, because cleaning up the website’s data was unsuccessful).
    • Click Download.
    • Launch the application through Xcode (serves to install it).
    • Stop the application in Xcode, then launch it from the phone.
    • Click the note link again - the button should now show "Open" and open the application.
+1
source

I see that instead of opening ios_url (link on the App Store), the browser is trying to open ios_has_app_url. How can i fix this?

By allowing the link:

 "itms-apps://itunes.apple.com/app/idxxxxxxxxxx" 
0
source

Source: https://habr.com/ru/post/1259805/


All Articles