使用branch.io及iOS Branch SDK时,Quick Link参数无法传递至iOS应用
Hey there, let's work through getting those missing parameters showing up in your iOS app from your Branch Quick Link. Here are the key steps to troubleshoot and resolve this:
Double-check how you're attaching parameters to the Quick Link
Make sure you're not using Branch-reserved parameter names (these start with a$, like$campaignor$channel) for your custom parameters—Branch will ignore or override these. Also, confirm you're appending parameters correctly to the end of your Quick Link URL, like:https://REDACTED.app.link/rlaJz0QU5K?user_id=123&product_type=shoesAvoid any typos in parameter names; even a small typo (like
useridvsuser_id) will cause the parameter to not show up.Verify your Branch SDK implementation for parameter handling
Ensure you're correctly initializing the Branch SDK and capturing parameters in the right lifecycle methods.
First, make sure you're handling Universal Links in your app delegate or scene delegate:// For UIKit App Delegate func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool { Branch.getInstance().continue(userActivity) return true } // For Scene Delegate func scene(_ scene: UIScene, continue userActivity: NSUserActivity) { Branch.getInstance().continue(userActivity) }Then, when initializing the SDK, log all received parameters to see exactly what's coming through:
Branch.getInstance().initSession(launchOptions: launchOptions) { params, error in if let error = error { print("Branch init error: \(error.localizedDescription)") } else if let params = params { print("Full Branch parameters received: \(params)") // Access your custom parameters here let userId = params["user_id"] as? String let productType = params["product_type"] as? String } }If the parameter isn't in that printed dictionary, it's not being passed to the SDK at all.
Check your Branch Quick Link settings in the dashboard
Head to your Branch dashboard, open the Quick Link you created, and look at the Deep Link Data section:- If you've set parameters here, make sure you have the Allow query params to override deep link data option enabled. If this is off, any parameters you append to the URL will be ignored in favor of the dashboard-set values.
- Also, ensure there are no conflicting parameter names between your appended params and the ones set in the dashboard.
Enable Branch Debug Logs to diagnose the issue
Turn on Branch's debug mode in your app to see detailed logs about how the link is being processed:// Add this before initializing the Branch SDK (e.g., in AppDelegate's didFinishLaunchingWithOptions) Branch.setDebug()Now check your Xcode console—you'll see logs showing the incoming URL, how Branch parses it, and which parameters are extracted. This will tell you if the parameters are being lost during the link resolution process or not reaching the SDK at all.
Confirm Universal Links are properly configured
If Universal Links aren't working correctly, your app might be falling back to URL Scheme links, which can sometimes cause parameter loss. Verify:- Your
apple-app-site-associationfile is hosted correctly and includes your app's Team ID and Bundle ID. - You've added
applinks:REDACTED.app.linkto the Associated Domains capability in your Xcode project.
- Your
By working through these steps, you should be able to track down why those parameters aren't showing up and get them working as expected.
内容的提问来源于stack exchange,提问作者seanicus

