传递查询参数以从 Branch 重定向 url
Pass query params to redirect url from Branch
考虑 URL -
example.com/page
这是从 Branch 仪表板中的营销选项卡生成的。
现在我使用这个 URL 打开我的 iOS 应用程序并且还有桌面和 Android 的重定向 URL。我将查询参数附加到我的深度 linked URL,如下所示。
example.com/page?currentPage="myPage"
在我的应用程序中,在分支初始化会话中,我能够获取我手动添加的参数。
现在,我怎样才能实现相同的重定向 URL? 如果我将查询参数添加到 Branch link 那么它应该被传递到我的重定向 URL 没有安装 Branch 的任何 SDK。
它应该重定向到 URL,如下所示:
mydomain.com/page?currentPage="myPage"
来自 Branch.io 的亚历克斯:
这是 Branch URL 重定向的默认行为。附加到 link 的查询参数逐字传递。
这意味着如果您的 link 是 http://example.com/page
并且它设置为在未安装应用程序时重定向到 http://otherdomain.com/page
,您可以附加 ?currentPage="myPage"
来制作最终 URL http://otherdomain.com/page?currentPage="myPage"
希望对您有所帮助!
您表示当您将 link 参数附加到您的 Branch links,然后使用这些 links 打开您的 iOS 应用程序时,您可以从 Branch SDK 检索附加参数。如果我理解正确的话,你的问题是当用户从非 iOS 设备点击 Branch links 时,如何将此类查询参数传递给你重定向到的网站。
当点击分支 link 并且用户被重定向到您指定为应用程序(或 link 的)URL 时 "Android URL"或 "Desktop URL," 分支将自动附加任何已附加到 link 的参数。
例如,分支 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".
当您重定向到的页面打开时,您可以通过多种方式检索任何附加参数。两种最直接的方法是:
- 在JavaScript中查询window.location.href。这将 return 整个引用 URL,然后您可以解析查询参数(参见:How can I get query string values in JavaScript?)。
- 在着陆页上集成Branch Web SDK,并使用Branch 方法检索所有查询参数。这使您能够读取 Branch link 的预定义参数和任何附加的键值对 - 就像您在 iOS 应用程序中使用 Branch iOS SDK 所做的那样。使用 Branch Web SDK 的说明可以在 GitHub 存储库的 readme.md 文件中找到,此处:https://github.com/BranchMetrics/web-branch-deep-linking
如果我误解了您的问题,请提供更多详细信息。示例和测试计划将是最有帮助的。
考虑 URL -
example.com/page
这是从 Branch 仪表板中的营销选项卡生成的。
现在我使用这个 URL 打开我的 iOS 应用程序并且还有桌面和 Android 的重定向 URL。我将查询参数附加到我的深度 linked URL,如下所示。
example.com/page?currentPage="myPage"
在我的应用程序中,在分支初始化会话中,我能够获取我手动添加的参数。
现在,我怎样才能实现相同的重定向 URL? 如果我将查询参数添加到 Branch link 那么它应该被传递到我的重定向 URL 没有安装 Branch 的任何 SDK。
它应该重定向到 URL,如下所示:
mydomain.com/page?currentPage="myPage"
来自 Branch.io 的亚历克斯:
这是 Branch URL 重定向的默认行为。附加到 link 的查询参数逐字传递。
这意味着如果您的 link 是 http://example.com/page
并且它设置为在未安装应用程序时重定向到 http://otherdomain.com/page
,您可以附加 ?currentPage="myPage"
来制作最终 URL http://otherdomain.com/page?currentPage="myPage"
希望对您有所帮助!
您表示当您将 link 参数附加到您的 Branch links,然后使用这些 links 打开您的 iOS 应用程序时,您可以从 Branch SDK 检索附加参数。如果我理解正确的话,你的问题是当用户从非 iOS 设备点击 Branch links 时,如何将此类查询参数传递给你重定向到的网站。
当点击分支 link 并且用户被重定向到您指定为应用程序(或 link 的)URL 时 "Android URL"或 "Desktop URL," 分支将自动附加任何已附加到 link 的参数。
例如,分支 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".
当您重定向到的页面打开时,您可以通过多种方式检索任何附加参数。两种最直接的方法是:
- 在JavaScript中查询window.location.href。这将 return 整个引用 URL,然后您可以解析查询参数(参见:How can I get query string values in JavaScript?)。
- 在着陆页上集成Branch Web SDK,并使用Branch 方法检索所有查询参数。这使您能够读取 Branch link 的预定义参数和任何附加的键值对 - 就像您在 iOS 应用程序中使用 Branch iOS SDK 所做的那样。使用 Branch Web SDK 的说明可以在 GitHub 存储库的 readme.md 文件中找到,此处:https://github.com/BranchMetrics/web-branch-deep-linking
如果我误解了您的问题,请提供更多详细信息。示例和测试计划将是最有帮助的。