Branch Deep link not opening application

末鹿安然 提交于 2019-12-18 11:44:40

问题


I have been trying (unsuccessfully) to use Branch to implement deep linking into our iOS application. The Branch URL redirects directly to App Store and never attempts to open the application. I must be missing something.

What I've done:

  1. Included Branch SDK (CocoaPods) Added branch_key to application plist
  2. Added URL Scheme to URL Types in application plist
  3. EnabledAssociated Domains in both the project and the App ID in the developer console.
  4. Ensured that the entitlements file is included in the build.

  5. Registered deep link handler in AppDelegate

Dashboard: Settings -> Link Settings:

  1. "Always try to open app" is checked
  2. "IOS URI Scheme" is set to the application's custom URI scheme.
  3. "Enable Universal Links" is checked.
  4. Bundle Identifier & Apple App Prefix are both set correctly.

    Within the Branch Dashboard, under "Marketing" tab, I've created a single link. I'm emailing this link to myself and opening it on the device (Mail.app). Safari opens then the App Store is opened as if the application is not installed.

Neither application:openURL:sourceApplication:annotation nor application:continueUserActivity:restorationHandler are called.

AppDelegate Methods:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    let branch: Branch = Branch.getInstance()
    branch.initSessionWithLaunchOptions(launchOptions, andRegisterDeepLinkHandler: { params, error in
        if (error == nil) {
            // params are the deep linked params associated with the link that the user clicked -> was re-directed to this app
            // params will be empty if no data found
            // ... insert custom logic here ...
            NSLog("params: %@", params.description)
        }
    })
    return true
}

func application(application: UIApplication, continueUserActivity userActivity: NSUserActivity, restorationHandler: ([AnyObject]?) -> Void) -> Bool {
    // pass the url to the handle deep link call

    return Branch.getInstance().continueUserActivity(userActivity)
}

func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
    // pass the url to the handle deep link call
    Branch.getInstance().handleDeepLink(url);

    // do other deep link routing for the Facebook SDK, Pinterest SDK, etc
    return true
}

Am I missing a configuration step? Is this because the application is installed via Xcode debug and not through the app store? I'm expecting to see the application delegate methods called, but they are not.


回答1:


It appears that the application must be installed via App Store/Test Flight/Ad Hoc or the application will not be considered installed.

I installed the application to my device using an Ad Hoc provision and everything is working.




回答2:


For me, the link worked even though I installed tethered without Adhoc distribution. Then one day it stopped working. That was because I clicked on the forward link to bnc inside the app.

The fix for that was easy - just long pressed the link. An option shows "Open in App". Click this and the link is handled by app. Next time onwards, link works as expected even without long press as Safari remembers this as the default behavior.




回答3:


I also had same issue, but mine solution is different than yours.

Note: We can open the App in debug mode, (I did it, as pointed out by Alex Bauer in above comment section).

In .plist I added two different keys one is live and another one is test (simultaneously), along with above mentioned configuration settings.

The domain for deep linking which I was using was this. bnc.lt. I mailed to Branch Io support team regarding my issue, then got reply as follows'

The reason you are having issues is because you are still on our legacy bnc.lt link domain. This link domain has been slowly phased out over the past year. Development and functionality have stopped for quite some time in favor of our new link domain (app.link). To fix your issues and get your AASA validator working correctly, you will need to change your link domain from bnc.lt to app.link on your Branch Dashboard (https://dashboard.branch.io/settings/link). Once you have made this change, you will need to update your app to accept the new app.link link domain as well as your old bnc.lt link domain. https://gist.github.com/ethanneff/a2a70d1b3518c638701c28b1bd374e80

Please visit the above link its very helpful.

Hope it solves your issue, Happy Branching :)




回答4:


I had the same issue - some of the answers here are dated so I'll try to provide an update:

The fix for that was easy - just long pressed the link. An option shows "Open in App".

This went away in iOS 11 I believe so unless you're testing in iOS 10 this isn't an option.

It appears that the application must be installed via App Store/Test Flight/Ad Hoc or the application will not be considered installed.

As Alex pointed out in the comments this is not accurate. Branch links work when the app is installed via Xcode.

For me the issue was some sort of caching problem on my device. I have multiple schemes Debug & Release each of which has their own branch key and links. Some how they got mixed up and links wouldn't open in one scheme. I was able to resolve this issue by force restarting the device.



来源:https://stackoverflow.com/questions/35138257/branch-deep-link-not-opening-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!