Creating a Branch Instance takes a Branch Key, and Application Information.
Initialize the AppInfo with settings specific to your app.
// Set AppInfo properties as necessary BranchIO::AppInfo _appInfo; _branchInstance = BranchIO::create("key_live_xxx", &_appInfo);
Creating a Branch Session takes an optional link parameter and a callback.
Often, you might have your own user IDs, or want referral and event data to persist across platforms or
uninstall/reinstall. It's helpful if you know the users access the service from different devices. This where we
introduce the concept of an 'identity'.
To identify a user, just call:
_branchInstance->setIdentity("user id", myCallback);
If you provide a logout function in the app, be sure to clear the user when the logout completes. This will ensure that
all the stored parameters get cleared and all events are properly attributed to the right identity.
logout can be called before
openSession. This will generate an error and have no other effect. Once set or removed, the identity or lack of one is persistent.
Use BranchIO::BranchStandardEvent class to track special user actions or application specific events beyond app installs,
opens, and sharing. You can track events such as when a user adds an item to an on-line shopping cart, or searches for a
keyword etc. BranchEvent provides an interface to add content(s) in order to associate content(s) with events. You can
view analytics for the BranchEvents you fire on the Branch dashboard.
BranchIO::BranchStandardEvent enumerate the most commonly tracked events and event parameters that can be used with
BranchEvent for the best results. You can always use custom event names and event parameters.
BranchStandardEvent ev = new BranchStandardEvent(BranchIO::StandardEvent::Type::ADD_TO_CART) .setDescription("Test description") .setTransactionID("123") .addCustomDataProperty("TestProperty", "TestValue"); _branchInstance->sendEvent(ev, _myCallback);
Branch links can be created in-app (as well as in many other ways - see:
Branch link creation guide.
When they are, and setIdentity has been called to associate a User ID with the current user session, Branch links will
be associated with that User ID.
// you can access this data from any instance that installs or opens the app from this link BranchIO::LinkInfo linkInfo; linkInfo .addTag("Tag1") .setChannel("Sharing_Channel_name") .setFeature("my_feature_name") .addControlParameter("$android_deeplink_path", "custom/path/*") .addControlParameter("$ios_url", "http://example.com/ios") .setDuration(100); // Add some additional control parameters linkInfo .addControlParameter("$canonical_identifier", "item/12345") .addControlParameter("$canonical_url", https://branch.io/deepviews") .addControlParameter("$og_title", "My Content Title") .addControlParameter("$og_description", "my_product_description1") .addControlParameter("$og_image_url", "https://example.com/mycontent-12345.png"); // Generate a long branch link, synchronously. string url = linkInfo.createLongUrl(_branchInstance); // Create a short branch link, asynchronously (requires a server round trip). // Falls back to a long URL in case of request failure. linkInfo.createUrl(_branchInstance, _myCallback);
LinkInfodestructor blocks until the asynchronous URL request completes. Use
LinkInfo::cancel()to force immediate termination of the asynchronous request.
- You can customize the Facebook OG tags of each URL if you want to dynamically share content by using the following
optional keys in the data dictionary. Please use this
Facebook tool to debug the OG tags.
|"$og_title"||The title you'd like to appear for the link in social media.|
|"$og_description"||The description you'd like to appear for the link in social media.|
|"$og_image_url"||The URL for the image you'd like to appear for the link in social media.|
|"$og_video"||The URL for the video.|
|"$og_url"||The URL you'd like to appear.|
|"$og_app_id"||the OG app ID. Optional and rarely used.|
Also, you do custom redirection by inserting the following optional keys in the dictionary:
|"$desktop_url"||Where to send the user on a desktop or laptop. By default it is the Branch-hosted text-me service.|
|"$android_url"||The replacement URL for the Play Store to send the user if they don't have the app. Only necessary if you want a mobile web splash|
|"$ios_url"||The replacement URL for the App Store to send the user if they don't have the app. Only necessary if you want a mobile web splash|
|"$ipad_url"||Same as above but for iPad Store.|
|"$fire_url"||Same as above but for Amazon Fire Store.|
|"$blackberry_url"||Same as above but for Blackberry Store.|
|"$windows_phone_url"||Same as above but for Windows Store.|
You have the ability to control the direct deep linking of each link by inserting the following optional keys in the dictionary:
|"$deeplink_path"||The value of the deep link path that you'd like us to append to the URI. For example, you could specify "$deeplink_path": "radio/station/456" and we'll open the app with the URI "theapp://radio/station/456?link_click_id=branch-identifier". This is primarily for supporting legacy deep linking infrastructure.|
|"$always_deeplink"||true or false. (default is not to deep link first) This key can be specified to have our linking service force try to open the app, even if we're not sure the user has the app installed. If the app is not installed, we fall back to the respective app store or $platform_url key. By default, we only open the app if we've seen a user initiate a session in the app from a Branch link (has been cookied and deep linked by Branch).|
Updated 8 days ago