Windows Testing
测试深度链接
Create a deep link from the Branch Dashboard.
- 如果安装了生产版本,则从 PC 上删除您的应用。
- 在 PC 上进行编译和测试。
- Paste deep link into an anchor (
<a>
element) in an HTML page. See the example.html for each TestBed app in the repo. - 在浏览器中打开 HTML 页面。
- 点击浏览器中的链接。
- 如果出现对话框,提示您重定向到您的应用,请点击“确定”。
- 该链接应启动您的应用。
测试延迟深度链接
延迟深度链接只是将深度链接到尚未安装的应用。安装应用后,将保留上下文,并且用户首次打开应用时将具有来自原始 Branch link 的深度链数据。要对此进行测试,请从设备中卸载应用,点击 Branch Link,然后从 Visual Studio 中手动启动该应用。此时系统应会将您路由至应用中的正确内容。
启用 Logging
SDK 可以选择支持将诊断消息记录到文件。它按严重性从高到低的顺序支持五个定义的日志级别:Error, Warning, Info, Debug and Verbose。默认日志级别是 Error(发布版本)和 Debug(调试版本)。Debug 和 Verbose 级消息在 Release 版本中编译出来。在发行版中仅提供 Error, Warning 和 Info。如有必要,您必须为日志文件创建包含目录。
启用日志输出有两种方式:
- (Simple) Set two environment variables:
BRANCHIO_LOG_LEVEL
andBRANCHIO_LOG_FILE
. Restart your app after setting these environment variables.

- (Custom) Call
BranchIO::Log::setLevel
andBranchIO::Log::enableFileLogging
. Logging is enabled from the time of the call. Call beforeBranch::create
to ensure logging all available messages.
#include <BranchIO/Util/Log.h>
// Debug and Verbose levels are compiled out in Release builds.
BranchIO::Log::setLevel(Log::Verbose);
// This ia a UTF-8 string, not UTF-16.
// Be sure to escape backslashes in file paths.
BranchIO::Log::enableFileLogging("C:\\path\\to\\logfile.log");
See the setupSDKLogging
method in BranchOperations.cpp
in the TestBed apps in the repo for a full working example of SDK logging to %LocalAppData%
。
使用 Test Key
- Use the Branch
test key
instead of thelive key
- Use in
Branch::create
初始化 Branch - 您应用的 Branch Key 必须与深度链接的 Branch Key 匹配
- 在发布到生产环境之前将其删除
auto* branch = BranchIO::Branch::create(L"key_test_xxxxxxxx", &appInfo);
The Branch key is passed from the app to the Branch SDK as the first parameter when calling create
. You may pass any valid Branch key. For example, the TestBed apps in the repo pass the key using a command-line build parameter, /D "BRANCH_KEY=L\"key_live_xxxxxxxx\""
. This preprocessor definition is then available to pass to the Branch::create
call. This approach allows you to specify a different key per build configuration, e.g. test key for Debug and live key for Release.
注意
If you use a different URI scheme for your app's test key in the Dashboard, you must also adjust the URI scheme you use in the Registry or your MSIX package. See the Basic Integration guide for more details.
示例应用
There are four variants in the GitHub repo of an example application called TestBed. In all cases except TestBed-Conan, you must first install the BranchSDK.msi. Each app has a separate Branch key and domain so that they can all be installed side-by-side on the same PC. Each app has a separate example.html page with a link on that domain to launch the associated app. All apps may be uninstalled along with all Registry configuration via Add or Remove Programs in Windows Settings. All TestBed variants require the Windows 10 SDK version 10.0.18363.0 (1909), available through the Visual Studio Installer.
All TestBed variants leave SDK log files in %LocalAppData%\Branch\TestBed
. Debug builds will generate Verbose-level logs. Release builds generate Info-level logs.
注意
It may be necessary to enable Developer Mode on a Windows device in order to deploy TestBed to the Start menu.
1. TestBed
此应用是根据 Branch SDK 和已安装的 MSI 的所有依赖项构建的。它使用 MSIX 打包 Win32 应用,以使用 URI 协议进行部署以启动该应用。
要构建和测试:
- 确保已为 Visual Studio 安装了 UWP 工作负载(对于 MSIX 是必需的)。
- 安装 MSI。
- 打开 TestBed.sln。
- 选择一个构建配置(Debug 或 Release)和一个体系结构(x86 或 x64),然后选择Build> Deploy Solution。
- 该应用将出现在“开始”菜单中。
- 该应用未安装在系统位置。二进制文件位于 repo 中的本地构建文件夹中。
- 点击 example.html 中的链接以在应用中打开 Branch Link。
此应用是根据本地 repo 中的源代码构建的,仅从安装的 MSI 中获取 Poco 和其他依赖项。它使用 MSIX 打包 Win32 应用,以使用 URI 协议进行部署以启动该应用。
要构建和测试:
- 确保已为 Visual Studio 安装了 UWP 工作负载(对于 MSIX 是必需的)。
- 安装 MSI。
- 打开 TestBed-Local.sln。
- 选择一个构建配置(Debug 或 Release)和一个体系结构(x86 或 x64),然后选择Build> Deploy Solution。
- 该应用将出现在“开始”菜单中。
- 该应用未安装在系统位置。二进制文件位于 repo 中的本地构建文件夹中。
- 点击 example.html 中的链接以在应用中打开 Branch Link。
此应用是根据本地 repo 中的源代码构建的,仅从安装的 MSI 中获取 Poco 和其他依赖项。它使用 Wix 工具集将 Win32 应用打包为带有自定义 Registry 的 MSI 部署,以从 URI 启动该应用。此版本的 TestBed 不使用 MSIX 或需要 UWP 工作负载。
要构建和测试:
- 安装 MSI。
- Install the Wix Toolset from https://github.com/wixtoolset/wix3/releases.
- 安装 Wix Visual Studio 扩展(扩展 > 管理扩展)。
- 打开 TestBed-Basic.sln。
- 选择调试版本配置(对于 Wix 安装程序项目是必需的)。
- 选择 x86 体系结构(对于 Wix 安装程序项目是必需的)。
- 选择 Build > Build Solution
- 该应用将出现在“开始”菜单中。
- 该应用安装在 C:\Program Files (x86)\Branch TestBed (Basic) 中。
- 点击 Welcome.html 中的链接以在 App 中打开 Branch Link。
注意
The Wix Toolset requires .NET Framework 3.5.1. Enable it under Windows Features to install the Wix Toolset.

此 App 使用 Branch SDK 的本地源以及适用于 Poco 的 Conan。它使用 MSIX 打包 Win32 App,使用 URI 协议进行部署来启动该 App。
要构建和测试:
- 确保已为 Visual Studio 安装了 UWP 工作负载(对于 MSIX 是必需的)。
- Install and set up Conan. See Win32 C++ Conan Integration for details.
- 打开 TestBed.sln。
- 选择一个构建配置(Debug 或 Release)和一个体系结构(x86 或 x64)。
- 选择“工具” > “Conan 程序包管理” > “安装(整个解决方案)”。在此步骤生效之前,通常需要执行两次。
- 在“输出”窗格中完成 Conan 安装后,选择“构建” > “部署解决方案”。
- 该应用将出现在“开始”菜单中。
- 该应用未安装在系统位置。二进制文件位于 repo 中的本地构建文件夹中。
- 点击 example.html 中的链接以在应用中打开 Branch Link。
Updated 3 months ago