Bartłomiej Semańczyk
Bartłomiej Semańczyk

Reputation: 61774

How do I access parameters I assigned to URL with branch.io?

I simply create an URL like this:

Branch.getInstance().getShortURL(withParams: ["a": [1, 2, 3], "b": ["c": 34, "d": "Malwina is OK:-)"]]) { url, error in

    let controller = UIActivityViewController(activityItems: [URL(string: url!)!], applicationActivities: nil)
    self.present(controller, animated: true, completion: nil)
}

And I get something like this:

https://fieldserviceios.app.link/Hjp9gesGIB

And from that link I try to open the app and catch that parameters:

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

    let a = Branch.getInstance().getLatestReferringParams() //no my params here
}

Upvotes: 0

Views: 1545

Answers (1)

dwestgate
dwestgate

Reputation: 1054

The way you are creating the link is fine and you are generating a valid link. You can check the contents of any Branch link by appending "?debug=true" to the link and entering it in a browser's address bar.

For your link: https://fieldserviceios.app.link/Hjp9gesGIB?debug=true I see:

{ 
    "$identity_id": "372863071192286427", 
    "$one_time_use": false, 
    "a": [1,2,3], 
    "b": { 
        "c": 34, 
        "d": "Malwina jest OK:-)" 
    }, 
    "~creation_source": 3, 
    "~id": "373038618178427139" 
}

I describe how you should go about reading the parameters from the link in my response to your other Stack Overflow question, here: How do I access metadata when branch link was clicked and opened my app...?, but speaking to the specific code you provide:

Upvotes: 1

Related Questions