Search code examples
xcode10branch.io

Branch.io not showing the passed values on xcode 10 (reading the link is not working)


I implemented the Branch.io in my another new project, it's redirecting to the app correctly but the information which was I shared is not showing. The same code is implemented in another project it's working well the only difference is Xcode10.

On Xcode 10 link generations working fine but reading the link is not working.

Expected behavior:- The link should redirect to the app and should show the information which was I share while generating the link.
 


Actual behavior It's redirecting to the app and not showing the information. 


Steps to reproduce Implement the branch.io in xcode10 problem occurred.

Download the Sample of working and not working code below

Xcode 10 created the project not working sample_xcode_10

Xcode 9 created the project working sample_xcode_9

Xcode 10 generated a link: "https://x5tu.app.link/QGHaY0p5GR" working well in Xcode 9 not in xcode 10


Solution

  • On Xcode 10 or greater Apple updated Swift version to 4.2, on this Apple made some syntax changes in app life cycle continue UserActity. So in our case the app life cycle event not calling and not getting the details.

    For this kindly update the continue UserActity method callback specification to UIUserActivityRestoring instead of Any.

    Previous Method:

    func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {return true}
    

    Working Method:

    func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
            print("Continue User Activity: ")
            if userActivity.activityType == NSUserActivityTypeBrowsingWeb {
                let url = userActivity.webpageURL!
                print(url.absoluteString)
            }
            return true
        }