Use the SDK integration validator to check that you've added the Branch SDK and handle deep links correctly when you first integrate Branch into your app. Validates the following:
Set specific key/value pairs to all requests. This is required for integrating with specific partners like Adobe Analytics, Amplitude, etc. Partner keys can be found in the partner-specific guides.
Set the identity of a user (ID, UUID, etc) for events, deep links, and referrals. Use this method when the user logs into their account in your app.See PII Best Practices for details.
Indicate whether or not this user has a custom identity specified for them. Note that this is independent of installs.If you call the setIdentity method, this device will have that identity associated with this user until the logout method is called.This includes persisting through uninstalls, as device ID is tracked.
Clear the identity set from the setIdentity() method. This method should be called if you know that the user is explicitly logging out or if a different person is about to use the app.
Return the first parameters associated with the link that referred the user. Consider this as the parameters used to retrieve the details from the user's first app session.
If you need to comply with a user's request to not be tracked for GDPR purposes, or otherwise determine that a user should not be tracked, utilize this method to prevent Branch from sending network requests. This setting can also be enabled across all users for a particular link or across your Branch Links.
Argument
Type
Description
value
Boolean
If set to true, disableTracking is enabled.
If set to false, disableTracking is disabled.
With the Branch Flutter SDK, it is possible to inject JavaScript into an in-app web view with event listeners to make calls to one of our mobile SDKs.
In this scenario, the website’s JavaScript posts a message when a button or element on the page is clicked. The app then uses a JavaScript channel to listen for that message. Inside of the callback, a switch statement is used to check the message and trigger a Branch Event.
To implement this approach:
Add JavaScript code to the website to add a listener to the button’s selector and call the postMessage() function:
var _selector = document.querySelector('button[id=BUTTON_ID]');
_selector.addEventListener('click', function(event) {
var message = "LOGIN";
if (messageHandler) {
messageHandler.postMessage(message);
}
});
Add a JavaScript channel to the WebViewController to handle the onMessageRecieved callback and trigger the corresponding Branch Event:
class _MyWebViewState extends State<MyWebView> {
late final WebViewController controller;
@override
void initState() {
super.initState();
controller = WebViewController()
..loadRequest(
Uri.parse('https://YOUR_WEBSITE.com'),
);
controller.setJavaScriptMode(JavaScriptMode.unrestricted);
controller.addJavaScriptChannel('messageHandler',
onMessageReceived: (message) {
switch (message.message) {
case "LOGIN":
BranchEvent event =
BranchEvent.standardEvent(BranchStandardEvent.LOGIN);
FlutterBranchSdk.trackContentWithoutBuo(branchEvent: event);
break;
case "PURCHASE":
BranchEvent event =
BranchEvent.standardEvent(BranchStandardEvent.PURCHASE);
FlutterBranchSdk.trackContentWithoutBuo(branchEvent: event);
break;
}
});
}
}