问题
Consider an URL -
example.com/page
which is generated from marketing tab in Branch dashboard.
Now I use this URL to open my iOS application and also have redirect urls for desktop and Android. I append query params to my deep linked URL as below.
example.com/page?currentPage="myPage"
In my application, in branch init session I am able to get the parameters which I added manually.
Now, how can I achieve the same for redirect URL? If I add query params to Branch link then it should be passed on to my redirect URL without any SDK of Branch installed.
It should redirect to URL like below:
mydomain.com/page?currentPage="myPage"
回答1:
You indicate that when you append link parameters to your Branch links and then use those links to open your iOS app, you are able to retrieve the appended parameters from the Branch SDK. Your question, if I am understanding correctly, is how to pass such query parameters to the websites that you are redirecting to when users click on Branch links from non-iOS devices.
When a Branch link is tapped and the user redirected to URLs that you have specified to be the app's (or the link's) "Android URL" or "Desktop URL," Branch will automatically append any parameters that were appended to that link.
For example, the Branch link https://ogt1.app.link/KZGUqrzBdB redirects users on Android devices and Desktops to "http://www.bing.com/search". Appending the query parameter "q=branch+metrics" to the Branch link produces the link "https://ogt1.app.link/KZGUqrzBdB?q=branch+metrics", which will automatically redirect Android and Desktop users to "http://www.bing.com/search?q=branch+metrics".
When the page you redirect to opens, you can retrieve any appended parameters in many ways. Two of the most straightforward approaches are:
- In JavaScript, query window.location.href. This will return the entire referring URL, which you can then parse for the query parameters (see: How can I get query string values in JavaScript?).
- Integrate the Branch Web SDK on the landing page and use Branch methods to retrieve all query parameters. This gives you the ability to read both the Branch link's predefined parameters and any appended key-value pairs - just as you are doing in your iOS app using the Branch iOS SDK. Instructions for using the Branch Web SDK can be found in the GitHub repository's readme.md file, here: https://github.com/BranchMetrics/web-branch-deep-linking
If I have misunderstood what you are asking please provide more detail. Examples and a test plan would be most helpful.
回答2:
Alex from Branch.io here:
This is the default behavior for Branch URL redirects. Query parameters appended to the link are passed through verbatim.
This means if your link is http://example.com/page
and it is set to redirect to http://otherdomain.com/page
when the app is not installed, you can append ?currentPage="myPage"
to make the final URL http://otherdomain.com/page?currentPage="myPage"
Hope that helps!
来源:https://stackoverflow.com/questions/42578781/pass-query-params-to-redirect-url-from-branch