iOS Testing
Test Branch functionality and access tools to ensure you've successfully integrated our iOS SDK.
Overview
The test scenarios, tools, and resources in this guide help you make sure that you've integrated the Branch iOS SDK correctly.
To integrate the Branch iOS SDK, follow the steps in our iOS SDK Basic Integration guide.
Test Scenarios
Test AASA File Download
To confirm that the AASA file has successfully downloaded:
- Connect a test device to your Mac.
- Uninstall your app from the test device.
- View the device's console output in the Mac console.
- Install your app and let it launch.
- Filter the console output by "swcd".
You should see content that looks similar to this if the file downloaded successfully:
If the AASA file did not download, then you must uninstall the app, restart the device, and then reinstall the app.
Test Deep Linking
To test whether you can successfully use Branch Deep Links:
- Create a deep link using the Branch Dashboard.
- Make sure your test device is ready to use.
- Delete your app from the device you are testing with.
- Compile and re-install your app on the device.
- Paste the deep link in a note in the Apple Notes app.
- Long-press on the deep link (not 3D touch).
- Click "Open in <app_name>", which should cause your app to open and route to the proper screen.
Please note that you must have our Engagement product to have access to Branch Deep Linking.
Test Deferred Deep Linking
Deferring deep linking means deep linking into an app that is not yet installed.
Once the app is installed, the context from the click is preserved and the user's first app-open event will include deep link data from the original Branch Deep Link.
To test deferring deep linking:
- Enable NativeLink™ Deferred Deep Linking.
- Delete your app from the device you are testing with (must be iOS 15+).
- Compile and re-install your app on the device.
- Paste a Branch Deep Link that contains
ios_nativelink=true
in a note in the Apple Notes app. - Long-press on the deep link (not 3D touch) and have it route through Safari.
- If you enabled NativeLink™ Deferred Deep Linking correctly, then you should get routed to a Branch Deepview prompting you to download the app. Click the call-to-action and ensure that the link is copied to the iOS clipboard.
- Manually launch the app from Xcode. You should be routed to the correct content within your app if you configured deep link routing properly (using URL, URI Schema, or key/value pairs).
Expected behavior:
- Upon clicking the link, the web browser opens and the user sees the NativeLink™ experience.
- When the app opens, the user sees a notification indicating that the app has used the device's clipboard.
- The API call to
api2.branch.io/v1/open
orv1/install
should include a new parameter calledlocal_url
.
Please note that you must have our Engagement product to have access to Branch Deferred Deep Linking.
Test Deep Link Routing
To test deep link routing for your app:
- Append
?bnc_validate=true
to a Branch Deep Link. - Click on this deep link from your mobile device (not the Simulator).
An example link would look like: "https://<yourapp\>.app.link/NdJ6nFzRbK?bnc_validate=true"
Test Install
To ensure the SDK is setup correctly, you no longer need to simulate an install via the SDK itself.
Instead, you can test functionality end to end by completing the following:
- Add a test device to your Branch account.
- Test your Universal Ads campaign setup.
Testing Tools
AASA File Config Validator
To determine if your domain's AASA file is properly configure for Universal Links, use Branch's AASA Validator tool.
Integration Status Tab
For a quick approach to checking your Branch iOS SDK integration status and progress, you can use the Integration Status tab of the Branch Dashboard.
Integration Validator Method
Another simple way to test the status of your Branch iOS SDK integration is using the built-in validateSDKIntegration()
method.
To use this method, add the following code to your AppDelegate file:
Branch.getInstance().validateSDKIntegration()
[[Branch getInstance] validateSDKIntegration];
This method will check to ensure that the Branch keys, package name, URI schemes, Universal Links, and link domain settings from the Branch Dashboard match those in the build.
Check your Xcode logs to make sure all the SDK integration tests pass.
Make sure to comment out or remove validateSDKIntegration()
in your production build.
For more about the validateSDKIntegration()
method, visit our blog.
Branch Test Key
For testing purposes, you can use your Branch test key instead of your live key.
To use your test key:
- Make sure the value of
branch_key
inInfo.plist
is a dictionary and includes your test key. For example:<key>branch_key</key> <dict> <key>live</key> <string>key_live_XXXXX</string> <key>test</key> <string>key_test_XXXXX</string> </dict>
- Add the following line of code before the
initSession()
method:Branch.setUseTestBranchKey(true)
[Branch setUseTestBranchKey:YES];
Make sure the test key of your app matches the test key in the deep link, and that you remove the setUseTestBranchKey()
method before releasing to production.
Enable Logging
Enable logging in your app to catch errors and other useful information coming from Branch. Make sure to only do this for testing, and that you remove the logging code before releasing to production.
Basic Logging
To enable basic logging:
- Make sure that
OS_ACTIVITY_MODE
is not disabled. - Swap out your Branch live key for your Branch test key.
- Add the following line of code before the
initSession()
method:// Enable basic logging Branch.enableLogging()
// Enable basic logging [Branch enableLogging];
- Don't forget to remove the logging code and switch back to your Branch live key before releasing to production.
Advanced Logging
For more advanced logging needs, you can forward logs to a custom callback instead of the default os_log
:
// Enable basic logging
Branch.enableLogging()
// Choose the minimum log level to be logged
Branch.enableLogging(at: .error)
// Forward logs to a custom callback instead of the default os_log
Branch.enableLogging(at: .warning) { message, level, error in
if error != nil {
print("[Branch Error][\(level)] \(message) - \(error)")
} else {
print("[Branch Log][\(level)] \(message)")
}
}
// Enable basic logging
[Branch enableLogging];
// Choose the minimum log level to be logged and forward logs to a custom callback instead of the default os_log
[Branch enableLoggingAtLevel:BranchLogLevelVerbose withCallback:^(NSString * _Nonnull message, BranchLogLevel logLevel, NSError * _Nullable error) {
// Handle the log message and error here. For example, printing to the console:
if (error) {
NSLog(@"[BranchLog] Level: %lu, Message: %@, Error: %@", (unsigned long)logLevel, message, error.localizedDescription);
} else {
NSLog(@"[BranchLog] Level: %lu, Message: %@", (unsigned long)logLevel, message);
}
}];
Link Debugger
You can make sure your Branch Link is properly configured by using Branch's Link Debugger tool. It can help you determine whether the link was properly configured and passed the correct data when it was created.
To use Branch's Link Debugger:
-
Sign in to your Branch Dashboard.
-
Make sure you are in the proper environment for the link you want to debug (live or test).
-
Copy the Branch Link, and append
?debug=1
to the end of it.- For example, the Branch Link
https://branchster.app.link/3vqEJflHrGb
would becomehttps://branchster.app.link/3vqEJflHrGb?debug=1
- For example, the Branch Link
-
Paste this link, including the
?debug=1
flag, into your browser. This will open the Link Debugger view:
This tool includes the Link Routing Debugger, which allows you to view the expected behavior for each operating system and click location.
To use the Link Routing Debugger:
-
Select an operating system and location using the dropdown menus.
-
View the redirect results table for the link.
Based on the operating system and click location you have selected, you’ll see the click redirect outcome for when a user does and does not have the app installed.
Additional Resources
Sample Applications
Troubleshooting Guide
If you're experiencing unexpected behavior with the Branch iOS SDK, start by taking a look at our Troubleshooting guide.
Updated about 1 month ago