Reputation: 61774
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
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:
Your continueUserActivity function should not have a getLatestReferringParams call but should have:
Branch.getInstance().continue(userActivity)
You need to initialize Branch in didFinishLaunchingWithOptions, using branch.initSession. For an example, see: https://github.com/BranchMetrics/ios-branch-deep-linking/blob/master/Branch-TestBed-Swift/TestBed-Swift/AppDelegate.swift#L43-L74
Upvotes: 1