getInstance
Method | Description |
---|---|
Get the live, global Branch instance. |
Example Usage
let branch: Branch = Branch.getInstance()
Branch *branch = [Branch getInstance];
initSessionWithLaunchOptions
Method | Description |
---|---|
Initialize a Branch session with your app's specific launch options, and handle the completion with a | |
Initialize a Branch session with your app's specific launch options, and handle the completion with a |
Argument | Type | Description |
---|---|---|
|
| The launch options provided by your AppDelegate file's |
|
| A callback that is called when the session is opened. This will be called multiple times during the app's life, including any time the app goes through a background/foreground cycle. |
Example Usage
// Within the AppDelegate
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let branch: Branch = Branch.getInstance()
branch?.initSession(launchOptions: launchOptions, deepLinkHandler: { params, error in
if error == nil {
// Params are the deep linked params associated with the link that the user clicked
print("params: %@", params.description)
}
})
return true
}
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
// Pass URL to the "handle deep link" call
let branchHandled = Branch.getInstance().application(
application,
open: url,
options: options
)
if (!branchHandled) {
// If not handled by Branch, do other deep link routing for the Facebook SDK, Pinterest SDK, etc
}
return true
}
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
let handledByBranch = Branch.getInstance().continue(userActivity)
return handledByBranch
}
// Within the AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
Branch *branch = [Branch getInstance];
[branch initSessionWithLaunchOptions:launchOptions andRegisterDeepLinkHandler:^(NSDictionary *params, NSError *error) {
// Route user based on params
}];
return YES;
}
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
BOOL branchHandled =
[[Branch getInstance]
application:application
openURL:url
options:options];
if (!branchHandled) {
// Do other deep link routing for the Facebook SDK, Pinterest SDK, etc.
}
return YES;
}
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> *restorableObjects))restorationHandler {
BOOL handledByBranch = [[Branch getInstance] continueUserActivity:userActivity];
return handledByBranch;
}
Parameters Returned
Note: The ~
symbol denotes analytics and +
denotes information added by Branch.
Parameter | Description |
---|---|
| The channel on which the link was shared, specified at Branch Link creation time. |
| The feature, such as |
| Any tags, specified at Branch Link creation time. |
| The campaign the link is associated with, specified at Branch Link creation time. |
| The stage, specified at Branch Link creation time. |
| Where the Branch Link was created ('API', 'Dashboard', 'SDK', 'iOS SDK', 'Android SDK', or 'Web SDK'). |
| True or false as to whether the match was made with 100% accuracy. |
| The referrer for the Branch Link click, if a Branch Link was clicked. |
| The phone number of the user, if the user texted themself the app. |
| Denotes whether this is the first session (install) or any other session (open). |
| Denotes whether or not the user clicked a Branch Link that triggered this session. |
| Epoch timestamp of when the click occurred. |
handleDeepLink
Warning: Handling a new Branch Deep Link in your app will clear the current session data and a new referred "open" will be attributed.
Method | Description |
---|---|
Allow Branch to handle a link that opens the app, and to parse the parameters from it. |
Argument | Type | Description |
---|---|---|
|
| The URL that caused the app to be opened. |
Example Usage
// The following call would return `false`
Branch.getInstance().handleDeepLink("myapp://")
// The following call would return `true`
Branch.getInstance().handleDeepLink("myapp://open?link_click_id=12345")
// The following call would return `YES`
NSURL *URL = [NSURL URLWithString:@"myapp://open?link_click_id=12345"];
[[Branch getInstance] handleDeepLink:URL];
continueUserActivity
Method | Description |
---|---|
(BOOL)continueUserActivity:(nullable NSUserActivity *)userActivity; | Allow Branch to handle restoration from an |
Argument | Type | Description |
---|---|---|
|
| The |
Example Usage
func application(application: UIApplication, continueUserActivity userActivity: NSUserActivity, restorationHandler: ([AnyObject]?) -> Void) -> Bool {
Branch.getInstance().continueUserActivity(userActivity);
return true
}
- (BOOL)application:(UIApplication *)application
continueUserActivity:(NSUserActivity *)userActivity
restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> *))restorationHandler {
[[Branch getInstance] continueUserActivity:userActivity];
return YES;
}
application
Method | Description |
---|---|
Allow Branch to open the URL that gets passed to it. |
Argument | Type | Description |
---|---|---|
|
| The application that was passed to your app delegate. |
|
| The URL that was passed to your app delegate. |
|
| The launch options dictionary that was passed to your app delegate. |
Example Usage
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
Branch.getInstance().application(app, open: url, options:options)
return true
}
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
return [[Branch getInstance] application:app openURL:url options:options];
}
handlePushNotification
Method | Description |
---|---|
(void)handlePushNotification:(nullable NSDictionary *)userInfo; | Allow Branch to handle a push notification with a Branch Link. |
Argument | Type | Description |
---|---|---|
|
| The application that was passed to your app delegate. |
Example Usage
// NSDictionary userInfo = @{@"branch": @"https://bnc.lt/...", ... };
// NSDictionary userInfo = @{@"branch": @"https://app.link/...", ... };
Branch.getInstance().handlePushNotification(response.notification.request.content.userInfo)
// NSDictionary userInfo = @{@"branch": @"https://bnc.lt/...", ... };
// NSDictionary userInfo = @{@"branch": @"https://app.link/...", ... };
[[Branch getInstance] handlePushNotification:userInfo];
enableLogging
Method | Description |
---|---|
Enable sending debug messages to NSLog (the Apple System Log facility). |
Argument | Type | Description |
---|---|---|
|
| The application that was passed to your app delegate. |
Example Usage
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Add `enableLogging` before `initSesssion` in AppDelegate
Branch.enableLogging()
// Listener for Branch Deep Link data
Branch.getInstance().initSession(launchOptions: launchOptions) { (params, error) in
// Do stuff here with Deep Link data (nav to page, display content, etc)
print(params as? [String: AnyObject] ?? {})
}
return true
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Add `enableLogging` before `initSesssion` in AppDelegate
[Branch enableLogging];
// Listener for Branch Deep Link data
[[Branch getInstance] initSessionWithLaunchOptions:launchOptions andRegisterDeepLinkHandler:^(NSDictionary * _Nonnull params, NSError * _Nullable error) {
// Do stuff here with Deep Link data (nav to page, display content, etc)
NSLog(@"%@", params);
}];
return YES;
}
setAPIURL
Method | Description |
---|---|
Set the Branch API URL globally for all Branch operations. |
Argument | Type | Description |
---|---|---|
|
| The new API URL to be used by Branch. |
Example Usage
Branch.setAPIURL("https://api3.branch.io")
[Branch setAPIURL:@"https://api3.branch.io"];
validateSDKIntegration
Method | Description |
---|---|
Check that you've added the Branch iOS SDK successfully to your app and are able to handle Branch Deep Links. After you run your app, check the project's Xcode logs to make sure all the SDK Integration tests pass. |
Example Usage
// 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
Branch.getInstance().validateSDKIntegration()
// 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
[[Branch getInstance] validateSDKIntegration];
addAllowedScheme
Method | Description |
---|---|
Allow a URI scheme to be tracked by Branch. |
Argument | Type | Description |
---|---|---|
|
| URI scheme allowed to be tracked, for example |
Example Usage
Branch.getInstance().addAllowedScheme("https")
[[Branch getInstance] addAllowedScheme:@"https"];
setAllowedSchemes
Method | Description |
---|---|
Allow an array of URI schemes to be tracked by Branch. |
Argument | Type | Description |
---|---|---|
|
| An array of URI schemes allowed to be tracked. |
Example Usage
var allowedSchemes = ["http", "https", "myapp"]
Branch.getInstance().setAllowedSchemes(allowedSchemes)
[[Branch getInstance] addAllowedScheme:@[@"http", @"https", @"myapp"]];
checkPasteboardOnInstall
Method | Description |
---|---|
Implement deferred deep linking via Branch NativeLink™. |
Example Usage
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// The `checkPasteboardOnInstall` call must be made before `initSesssion`
Branch.getInstance().checkPasteboardOnInstall()
// Listener for Branch Deep Link data
Branch.getInstance().initSession(launchOptions: launchOptions) { (params, error) in
// Do stuff here with Deep Link data (nav to page, display content, etc)
print(params as? [String: AnyObject] ?? {})
}
return true
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// The `checkPasteboardOnInstall` call must be made before `initSesssion`
[[Branch getInstance] checkPasteboardOnInstall];
// Listener for Branch Deep Link data
[[Branch getInstance] initSessionWithLaunchOptions:launchOptions andRegisterDeepLinkHandler:^(NSDictionary * _Nonnull params, NSError * _Nullable error) {
// Do stuff here with Deep Link data (nav to page, display content, etc)
NSLog(@"%@", params);
}];
return YES;
}
Visit the iOS Advanced Features page for more examples using the checkPasteboardOnInstall()
method.
willShowPasteboardToast
Method | Description |
---|---|
Check whether the Branch iOS SDK will trigger a pasteboard toast message for the end user. |
Example Usage
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// The `checkPasteboardOnInstall` call must be made before `initSesssion`
Branch.getInstance().checkPasteboardOnInstall()
// Check if pasteboard toast will show for end user
if Branch.getInstance().willShowPasteboardToast(){
// You can give the user information about what just occurred here
}
// Listener for Branch Deep Link data
Branch.getInstance().initSession(launchOptions: launchOptions) { (params, error) in
// Do stuff here with Deep Link data (nav to page, display content, etc)
print(params as? [String: AnyObject] ?? {})
}
return true
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// The `checkPasteboardOnInstall` call must be made before `initSessionWithLaunchOptions`
Branch.getInstance().checkPasteboardOnInstall()
// Check if pasteboard toast will show for end user
if ([[Branch getInstance] willShowPasteboardToast]) {
// You can give the user information about what just occurred here
}
// Listener for Branch Deep Link data
[[Branch getInstance] initSessionWithLaunchOptions:launchOptions andRegisterDeepLinkHandler:^(NSDictionary * _Nonnull params, NSError * _Nullable error) {
// Do stuff here with Deep Link data (nav to page, display content, etc)
NSLog(@"%@", params);
}];
return YES;
}
setAppClipAppGroup
Method | Description |
---|---|
Set the AppGroup used to share data between the App Clip and your full app. |
Argument | Type | Description |
---|---|---|
|
| The AppGroup to use. |
Example Usage
// Within the AppDelegate
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// The `setAppClipAppGroup()` call must be made before `initSession()`
Branch.getInstance().setAppClipAppGroup("group.io.branch")
BranchScene.shared().initSession(launchOptions: launchOptions) { (params, error, scene) in
if let dict = params {
if Monster.shared.waitingForData {
let name = (dict["monster_name"] as? String) ?? "Branchster"
Monster.shared.update(name: name)
}
}
}
return true
}
// Within the AppDelegate
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
Branch *branch = [Branch getInstance];
// The `setAppClipAppGroup()` call must be made before `initSessionWithLaunchOptions()`
[branch setAppClipAppGroup:@"group.io.branch"];
[branch initSessionWithLaunchOptions:launchOptions
andRegisterDeepLinkHandlerUsingBranchUniversalObject:
^ (BranchUniversalObject *BUO, BranchLinkProperties *linkProperties, NSError *error) {
}];
return YES;
}
handleATTAuthorizationStatus
Method | Description |
---|---|
Pass the |
Example Usage
if #available(iOS 14.0, *) {
// Check that `trackingAuthorizationStatus` is `notDetermined`, otherwise prompt will not display
if ATTrackingManager.trackingAuthorizationStatus == .notDetermined {
ATTrackingManager.requestTrackingAuthorization { (status) in
// `handleATTAuthorizationStatus()` should be called from the callback of `requestTrackingAuthorization()`
Branch.getInstance().handleATTAuthorizationStatus(status.rawValue)
}
}
}
if (@available(iOS 14.0, *)) {
// Check that `trackingAuthorizationStatus` is `notDetermined`, otherwise prompt will not display
if (ATTrackingManager.trackingAuthorizationStatus == ATTrackingManagerAuthorizationStatusNotDetermined) {
[ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
// `handleATTAuthorizationStatus()` should be called from the callback of `requestTrackingAuthorization()`
[[Branch getInstance] handleATTAuthorizationStatus:status];
}];
}
}
addFacebookPartnerParameterWithName
Method | Description |
---|---|
(void)addFacebookPartnerParameterWithName:(NSString )name value:(NSString )value; | Add a Partner Parameter for Facebook. This allows you to pass additional hashed information to the SDK for Facebook Advanced Matching. |
Argument | Type | Description |
---|---|---|
|
| Partner Parameter name. See Facebook's documentation for details on valid parameters. |
|
| Partner Parameter value. See Facebook's documentation for details on valid parameters. |
Example Usage
Branch.getInstance().addFacebookPartnerParameter(withName: "ph", value: "0000xxxx")
// Call `initSession()` after `addFacebookPartnerParameter()`
Branch.getInstance().addFacebookPartnerParameter(withName: "ph", value: "0000xxxx")
// Call `initSession()` after `addFacebookPartnerParameter()`
[[Branch getInstance] addFacebookPartnerParameterWithName:@"ph" value:@"0000xxxx"];
// Call `initSession()` after `addFacebookPartnerParameterWithName()`
addSnapPartnerParameterWithName
Method | Description |
---|---|
(void)addSnapPartnerParameterWithName:(NSString )name value:(NSString )value; | Add a Partner Parameter for Snap. |
Argument | Type | Description |
---|---|---|
|
| Partner Parameter name. See Snap's documentation for details on valid parameters. |
|
| Partner Parameter value. See Snap's documentation for details on valid parameters. |
Example Usage
Branch.getInstance().addSnapPartnerParameter(withName: "ph", value: "0000xxxx")
// Call `initSession()` after `addSnapPartnerParameter()`
[[Branch getInstance] addSnapPartnerParameterWithName:@"ph" value:@"0000xxxx"];
// Call `initSession()` after `addSnapPartnerParameterWithName()`
clearPartnerParameters
Method | Description |
---|---|
Clears all Partner Parameters. |
Example Usage
Branch.getInstance().clearPartnerParameters()
[[Branch getInstance] clearPartnerParameters];
setRetryInterval
Method | Description |
---|---|
Specify the time to wait in seconds between retries in the case of a Branch server error. |
Argument | Type | Description |
---|---|---|
|
| Number of seconds to wait between retries. |
Example Usage
Branch.getInstance().setRetryInterval(10.0)
[[Branch getInstance] setRetryInterval:10.0];
setMaxRetries
Method | Description |
---|---|
Specify the max number of times to retry in the case of a Branch server error. |
Argument | Type | Description |
---|---|---|
|
| Number of retries to make. |
Example Usage
Branch.getInstance().setMaxRetries(3)
[[Branch getInstance] setMaxRetries:3];
setNetworkTimeout
Method | Description |
---|---|
Specify the amount of time to wait before a request should be considered timed out. |
Argument | Type | Description |
---|---|---|
|
| Number of seconds to wait before a request is considered timed out. |
Example Usage
Branch.getInstance().setNetworkTimeout(10.0)
[[Branch getInstance] setNetworkTimeout:10.0];
disableAdNetworkCallouts
Method | Description |
---|---|
Disable callouts to ad networks for all events (by default, Branch sends callouts to ad networks). |
Argument | Type | Description |
---|---|---|
|
| When set to |
Example Usage
Branch.getInstance().disableAdNetworkCallouts(true)
[[Branch getInstance] disableCallouts:YES];
isBranchLink
Method | Description |
---|---|
Check if a URL is likely a Branch link. |
Argument | Type | Description |
---|---|---|
|
| The URL to check. |
Example Usage
Branch.isBranchLink("https://example.app.link/fzmLEhobLD?$custom_data=123&hello=world")
[Branch isBranchLink:@"https://example.app.link/fzmLEhobLD?$custom_data=123&hello=world"];
setRequestMetadataKey
Method | Description |
---|---|
(void)setRequestMetadataKey:(NSString )key value:(NSString )value | Add key-value pairs to the metadata of every request. |
Argument | Type | Description |
---|---|---|
|
| Key to be included in request metadata. |
|
| Value to be included in request metadata. |
Example Usage
General example:
// Inside the `didFinishLaunchingWithOptions` method
// Replace <analytics_id> with your Data Integration Partner's key
Branch.getInstance().setRequestMetadataKey("<analytics_id>", "<value>")
// Inside the `didFinishLaunchingWithOptions` method
// Replace <analytics_id> with your Data Integration Partner's key
[[Branch getInstance] setRequestMetadataKey:@"<analytics_id>" value: @"<value>"];
Example using Braze as the 3rd party Data Integration Partner:
// Inside the `didFinishLaunchingWithOptions` method
Branch.getInstance.setRequestMetadataKey("$braze_install_id", braze.deviceId)
// Inside the `didFinishLaunchingWithOptions` method
[[Branch getInstance] setRequestMetadataKey:@"$braze_install_id" value: braze.deviceId];
Visit the iOS Advanced Features page to learn more about the setRequestMetadataKey()
method.
setTrackingDisabled (deprecated)
Method | Description |
---|---|
Disable the Branch SDK from tracking the user. This is useful for GDPR privacy compliance. |
Argument | Type | Description |
---|---|---|
|
| When set to |
Implications of Using setTrackingDisabled
Action | Will work? |
---|---|
Opening Branch Deep Links with an explicit URL | Y |
Deferred deep linking | N |
Generating short links | N (returns long links) |
Sending user tracking events such as | N |
User rewards and credits | N |
Setting a user identity and logging a user identity out | N |
Example Usage
// Call takes place at the SDK level
Branch.setTrackingDisabled(true)
// Call takes place at the SDK level
[Branch setTrackingDisabled:YES];
trackingDisabled (deprecated)
Method | Description |
---|---|
Check whether user tracking is currently disabled. |
Example Usage
func trackingStatus() -> Bool {
// Call takes place at the SDK level
return Branch.trackingDisabled()
}
// Call takes place at the SDK level
[Branch trackingDisabled];
setReferrerGbraidValidityWindow
Method | Description |
---|---|
Sets the time window for which |
Argument | Type | Description |
---|---|---|
|
| The number of seconds |
Example Usage
Branch.setReferrerGbraidValidityWindow(10.0)
[Branch setReferrerGbraidValidityWindow:10.0]
setDMAParamsForEEA
Warning:
NULL
by DefaultPlease note that the 3 parameters passed to
setDMAParamsForEEA()
are allNULL
by default.Failure to include user consent signals may result in attribution or campaign performance degradation. For additional information, please reach out to your Google AM.
Method | Description |
---|---|
Sets the value of parameters required by Google Conversion APIs for DMA Compliance in the EEA region. |
Argument | Type | Description |
---|---|---|
|
| Set to |
|
| Set to |
|
| Set to |
Example Usage
// Example for an EEA resident who has denied both ad personalization and data usage consent
Branch.getInstance().setDMAParamsForEEA(true,false,false)
// Example for an EEA resident who has denied both ad personalization and data usage consent
[[Branch getInstance]
setDMAParamsForEEA:YES
adPersonalizationConsent:NO
adUserDataUsageConsent:NO];
// Example for an EEA resident who has consented to ad personalization but denied data usage consent
Branch.getInstance().setDMAParamsForEEA(true,true,false)
// Example for an EEA resident who has consented to ad personalization but denied data usage consent
[[Branch getInstance]
setDMAParamsForEEA:YES
adPersonalizationConsent:YES
adUserDataUsageConsent:NO];
// Example for an EEA resident who has denied ad personalization but granted data usage consent
Branch.getInstance().setDMAParamsForEEA(true,false,true)
// Example for an EEA resident who has denied ad personalization but granted data usage consent
[[Branch getInstance]
setDMAParamsForEEA:YES
adPersonalizationConsent:NO
adUserDataUsageConsent:YES];
Read more about the setDMAParamsForEEA()
method and Google DMA compliance in iOS Advanced Features guide.
setConsumerProtectionAttributionLevel
Method | Description |
---|---|
(void)setConsumerProtectionAttributionLevel:(BranchAttributionLevel)level; | Set the Consumer Protection Preference level. |
Argument | Type | Description |
---|---|---|
|
| The Consumer Protection Preference level to set for the user, based on the consent they have granted you. |
Consumer Preference Level | Description | Swift | Obj-C |
---|---|---|---|
Full Attribution | This is the default level. This level includes advertising IDs and device IDs, as well as other data. |
|
|
Privacy Attribution | This level does not include advertising IDs, but does include data from privacy frameworks like SKAN and Privacy Sandbox. |
|
|
Analytics Only | This level includes device IDs, but does not include data from privacy frameworks. |
|
|
No Attribution | This level only includes deterministic deep linking. Appropriate for users that fall under GDPR or CCPA regulations. |
|
|
Example Usage
// Set consumer preference level to "Privacy Attribution"
Branch.getInstance().setConsumerProtectionAttributionLevel(.reduced)
// Set consumer preference level to "Full Attribution"
[Branch setConsumerProtectionAttributionLevel:BranchAttributionLevelFull];
To learn more about setting Consumer Protection Preference levels, visit our guide.
getFirstReferringBranchUniversalObject
Method | Description |
---|---|
(nullable BranchLinkProperties *)getFirstReferringBranchLinkProperties; | Get the |
Example Usage
Branch.getInstance.getFirstReferringBranchUniversalObject()
const char *_getFirstReferringBranchUniversalObject() {
BranchUniversalObject* universalObject = [[Branch getInstance] getFirstReferringBranchUniversalObject];
return jsonCStringFromDictionary(dictFromBranchUniversalObject(universalObject));
}
getFirstReferringBranchLinkProperties
Method | Description |
---|---|
(nullable BranchLinkProperties *)getFirstReferringBranchLinkProperties; | Get the |
Example Usage
Branch.getInstance.getFirstReferringBranchLinkProperties()
[[Branch getInstance] getFirstReferringBranchLinkProperties]
getFirstReferringParams
Method | Description |
---|---|
Get the parameters used the first time this user was referred (can be empty). |
Example Usage
// In AppDelegate file, inside `didFinishLaunchingWithOptions()` method
// Listener for Branch Deep Link data
Branch.getInstance().initSession(launchOptions: launchOptions) { params, error in
print(params as? [String: AnyObject] ?? {})
}
// Get first referring params for Deep Link
let installParams = Branch.getInstance().getFirstReferringParams()
// In AppDelegate file, inside `didFinishLaunchingWithOptions()` method
// Listener for Branch Deep Link data
[[Branch getInstance] initSessionWithLaunchOptions:launchOptions
andRegisterDeepLinkHandler:^(NSDictionary * _Nullable params,
NSError * _Nullable error) {
if (!error) {
//Referring params
NSLog(@"Referring link params %@",params);
}
}];
// Get first referring params for Deep Link
NSDictionary *installParams = [[Branch getInstance] getFirstReferringParams];
getLatestReferringBranchUniversalObject
Method | Description |
---|---|
(nullable BranchUniversalObject *)getLatestReferringBranchUniversalObject; | Get the |
Example Usage
Branch.getInstance.getLatestReferringBranchUniversalObject()
[[Branch getInstance] getLatestReferringBranchUniversalObject];
getLatestReferringBranchLinkProperties
Method | Description |
---|---|
(nullable BranchLinkProperties *)getLatestReferringBranchLinkProperties; | Get the |
Example Usage
Branch.getInstance.getLatestReferringBranchLinkProperties()
[[Branch getInstance] getLatestReferringBranchLinkProperties];
getLatestReferringParams
Method | Description |
---|---|
Get the parameters used the most recent time this user was referred (can be empty). |
Example Usage
// In AppDelegate file, inside `didFinishLaunchingWithOptions()` method
// Listener for Branch Deep Link data
Branch.getInstance().initSession(launchOptions: launchOptions) { params, error in
print(params as? [String: AnyObject] ?? {})
}
// Get latest referring params for Deep Link
// Warning: This method may return results from a previous referral
let sessionParams = Branch.getInstance().getLatestReferringParams()
// In AppDelegate file, inside `didFinishLaunchingWithOptions()` method
// Listener for Branch Deep Link data
[[Branch getInstance] initSessionWithLaunchOptions:launchOptions
andRegisterDeepLinkHandler:^(NSDictionary * _Nullable params,
NSError * _Nullable error) {
if (!error) {
//Referring params
NSLog(@"Referring link params %@",params);
}
}];
// Get latest referring params for Deep Link
// Warning: This method may return results from a previous referral
NSDictionary *sessionParams = [[Branch getInstance] getLatestReferringParams];
getLatestReferringParamsSynchronous
Method | Description |
---|---|
(nullable NSDictionary *)getLatestReferringParamsSynchronous; | Get the parameters used the most recent time this user was referred (can be empty). |
Example Usage
// Warning: This method blocks the calling thread until the latest results are available
Branch.getInstance.getLatestReferringParamsSynchronous()
// Warning: This method may block the current thread until the latest results are available
[[Branch getInstance] getLatestReferringParamsSynchronous];
resetUserSession
Method | Description |
---|---|
Tells Branch to act as though |
Example Usage
Branch.getInstance.resetUserSession()
[[Branch getInstance] resetUserSession];
isUserIdentified
Method | Description |
---|---|
Indicates whether or not this user has a custom identity specified for them. This is independent of installs. |
Example Usage
// Warning: only invoke `isUserIdentified()` after `initSession()` completes
Branch.getInstance.isUserIdentified()
// Warning: only invoke `isUserIdentified() after `initSession()` completes
[[Branch getInstance] isUserIdentified];
setIdentity
Method | Description |
---|---|
Set the user's identity to a unique ID used by your system, so that it is identifiable by you elsewhere. | |
(void)setIdentity:(nullable NSString *)userId withCallback:(nullable callbackWithParams)callback; | Set the user's identity to a unique ID used by your system, so that it is identifiable by you elsewhere and receive a completion callback, notifying you whether it succeeded or failed. |
WARNINGS:
If you use the same ID between users on different sessions/devices, their actions will be merged.
This request is not removed from the queue upon failure - it will be retried until it succeeds.
Argument | Type | Description |
---|---|---|
|
| The ID that Branch should use to identify this user. |
|
| The callback to be called once the request has completed (success or failure). |
Example Usage Without Callback
// Login
Branch.getInstance().setIdentity("your_user_id")
// Logout
Branch.getInstance().logout()
//Login
Branch *branch = [Branch getInstance];
[branch setIdentity:@"test_user" withCallback:^(NSDictionary *params, NSError *error) {
NSLog(@"callback in setIdentity %@", params);
}];
// Logout
[[Branch getInstance] logout]; // Or replace with .logoutWithCallback() to customize further
logout
Method | Description |
---|---|
Clear all of the current user's session items. |
Example Usage
Branch.getInstance().logout()
[[Branch getInstance] logout];
logoutWithCallback
Method | Description |
---|---|
(void)logoutWithCallback:(nullable callbackWithStatus)callback; | Clear all of the current user's session items. |
Argument | Type | Description |
---|---|---|
|
| The callback to be called once the request has completed (success or failure). |
Example Usage
let branch = Branch.getInstance()
branch.logoutWithCallback { (changed, error) in
if (error != nil || !changed) {
print(String(format: "Logout failed: %@", error!))
} else {
print("Logout succeeded")
}
}
Branch *branch = [Branch getInstance];
[branch logoutWithCallback:^(BOOL changed, NSError *error) {
if (error || !changed) {
NSLog(@"Logout failed: %@", error);
} else {
NSLog(@"Logout succeeded");
}
}];
getShortURL (sync)
Warning: This method makes a synchronous URL request.
Method | Description |
---|---|
Get a short URL without any items specified. The usage type will default to unlimited. |
Example Usage
Branch.getInstance().getShortURL()
[[Branch getInstance] getShortURL];
getShortURLWithParams (sync, without tags)
Warning: The variations of getShortURLWithParams()
in this table make a synchronous URL request.
Method | Description |
---|---|
(NSString *)getShortURLWithParams:(nullable NSDictionary *)params; | Get a short URL with specified parameters. |
Get a short URL with specified parameters, channel, and feature. | |
Get a short URL with specified parameters, channel, feature, and stage. | |
Get a short URL with specified parameters, channel, feature, stage, and alias. | |
Get a short URL with specified parameters, channel, feature, stage, and type. | |
Get a short URL with specified parameters, channel, feature, stage, and match duration. |
Argument | Type | Description |
---|---|---|
|
| Dictionary of parameters to include in the short URL. |
|
| Channel for the short URL. Examples include Facebook, Twitter, and SMS (depending on where it will be shared). |
|
| Feature that the short URL is utilizing. Examples could be Sharing, Referring, Inviting, etc. |
|
| The stage used for the short URL, indicating what part of a funnel the user is in. |
|
| The alias for a short URL. Warning: If you pass an alias that is already taken, the method call will fail. |
|
| The type of short URL this is, either single use or unlimited use. Single use means once per user. |
|
| How long to keep an unmatched link click in Branch's backend server queue before discarding. |
Example Usage
// For all variations of `getShortURLWithParams()` the usage type will default to unlimited
let params: [String: Any] = [
"key1": "value1",
"key2": "value2"
]
let shortURL = Branch.getInstance().getShortURL(withParams: params)
// For all variations of `getShortURLWithParams()` the usage type will default to unlimited
NSDictionary *params = @{
@"key1": @"value1",
@"key2": @"value2"
};
NSString *shortURL = [[Branch getInstance] getShortURLWithParams:params];
getShortURLWithParams (sync, with tags)
Warning: The variations of getShortURLWithParams()
in this table make a synchronous URL request.
Method | Description | |
---|---|---|
Get a short URL with specified parameters, tags, channel, feature, and stage. | ||
Get a short URL with specified parameters, tags, channel, feature, stage, and alias. | ||
Get a short URL with specified parameters, tags, channel, feature, stage, and type. | ||
Get a short URL with specified parameters, tags, channel, feature, stage, and match duration. | ||
Get a short URL with specified parameters, tags, alias, channel, feature, stage, and match duration. | ||
Get a short URL with specified parameters, tags, alias, channel, feature, stage, campaign, and match duration. | ||
Get a short URL with specified tags, params, channel, feature, stage, and match duration. | ||
Get a short URL with specified params, channel, feature, stage, campaign and match duration. |
Argument | Type | Description |
---|---|---|
|
| Dictionary of parameters to include in the short URL. |
|
| An array of tags to associate with this short URL. Useful for tracking. |
|
| Channel for the short URL. Examples include Facebook, Twitter, and SMS (depending on where it will be shared). |
|
| Feature that the short URL is utilizing. Examples could be Sharing, Referring, Inviting, etc. |
|
| The stage used for the short URL, indicating what part of a funnel the user is in. |
|
| The alias for a short URL. Warning: If you pass an alias that is already taken, the method call will fail. |
|
| The type of short URL this is, either single use or unlimited use. Single use means once per user. |
|
| How long to keep an unmatched link click in Branch's backend server queue before discarding. |
|
| Use this field to organize the links by actual marketing campaign. |
|
| The User Agent string to tell the server to ignore the next request - prevents it from treating a preview scrape as a link click. |
|
| Whether we should create a link from the Branch key even if |
Example Usage
// For all variations of `getShortURLWithParams()` the usage type will default to unlimited
let params: [String: Any] = [
"key1": "value1",
"key2": "value2"
]
let shortURL = Branch.getInstance().getShortURL(withParams:params andTags:["one", "two", "three"])
// For all variations of `getShortURLWithParams()` the usage type will default to unlimited
NSDictionary *params = @{
@"key1": @"value1",
@"key2": @"value2"
};
NSString *shortURL = [[Branch getInstance] getShortURLWithParams:params andTags:@["one", "two", "three"]];
getLongURLWithParams
Method | Description |
---|---|
(NSString )getLongURLWithParams:(nullable NSDictionary )params; | Get a long URL with specified parameters. |
Get a long URL with specified parameters and feature. | |
Get a long URL with specified parameters, feature, and stage. | |
Get a long URL with specified parameters, feature, stage, and tags. | |
Get a long URL with specified parameters, feature, stage, and alias. | |
Get a long URL with specified parameters, channel, tags, feature, stage, and alias. |
Argument | Type | Description |
---|---|---|
|
| Dictionary of parameters to include in the long URL. |
|
| An array of tags to associate with this long URL. Useful for tracking. |
|
| Channel for the long URL. Examples include Facebook, Twitter, and SMS (depending on where it will be shared). |
|
| Feature that the long URL is utilizing. Examples could be Sharing, Referring, Inviting, etc. |
|
| The stage used for the long URL, indicating what part of a funnel the user is in. |
|
| The alias for a long URL. Warning: If you pass an alias that is already taken, the method call will fail. |
|
| Use this field to organize the links by actual marketing campaign. |
Example Usage
// For all variations of `getLongURLWithParams()` the usage type will default to unlimited
let params: [String: Any] = [
"key1": "value1",
"key2": "value2"
]
let longUrl = Branch.getInstance().getLongURL(withParams: params, andChannel: "channel", andTags: ["tag1"], andFeature: "feature", andStage: "stage", andAlias: "testingLinkAlias123")
// For all variations of `getLongURLWithParams()` the usage type will default to unlimited
NSDictionary *params = @{
@"key1": @"value1",
@"key2": @"value2"
};
NSString *longUrl = [[Branch getInstance] getLongURLWithParams:params andChannel:@"channel" andTags:@[@"tag1"] andFeature:@"feature" andStage:@"stage" andAlias:@"testingLinkAlias123"];
getLongAppLinkURLWithParams
Method | Description |
---|---|
Get a long app.link URL with specified parameters, channel, tags, feature, stage, and alias. Warning: If you pass an alias that is already taken, the method call will fail. |
Argument | Type | Description |
---|---|---|
|
| Dictionary of parameters to include in the long app.link URL. |
|
| Channel for the long app.link URL. Examples include Facebook, Twitter, and SMS (depending on where it will be shared). |
|
| An array of tags to associate with this long app.link URL. Useful for tracking. |
|
| Feature that the long app.link URL is utilizing. Examples could be Sharing, Referring, Inviting, etc. |
|
| The stage used for the long app.link URL, indicating what part of a funnel the user is in. |
|
| The alias for the long app.link URL. Warning: If you pass an alias that is already taken, the method call will fail. |
Example Usage
// The usage type of `getLongAppLinkURLWithParams()` will default to unlimited
let params: [String: Any] = [
"key1": "value1",
"key2": "value2"
]
let longAppUrl = Branch.getInstance().getLongAppLinkURL(withParams: params, andChannel: "channel", andTags: ["tag1"], andFeature: "feature", andStage: "stage", andAlias: "testingLinkAlias123")
// The usage type of `getLongAppLinkURLWithParams()` will default to unlimited
NSDictionary *params = @{
@"key1": @"value1",
@"key2": @"value2"
};
NSString *longAppUrl = [[Branch getInstance] getLongAppLinkURLWithParams:params andChannel:@"channel" andTags:@[@"tag1"] andFeature:@"feature" andStage:@"stage" andAlias:@"testingLinkAlias123"];
getShortURLWithCallback (async)
Warning: This method should only be invoked after initSession()
completes, either within the callback or after a delay. If it is invoked before, Branch will silently initialize the SDK before the callback has been set, in order to carry out this method's required task. As a result, you may experience issues where the initSession()
callback does not fire.
Method | Description |
---|---|
(void)getShortURLWithCallback:(nullable callbackWithUrl)callback; | Get a short URL without any items specified. |
Argument | Type | Description |
---|---|---|
|
| Callback called with the short URL. |
Example Usage
// The usage type of `getShortURLWithCallback()` will default to unlimited
Branch.getInstance().getShortURLWithCallback { (url, error) in
print("Generated short URL: \(url)")
}
// The usage type of `getShortURLWithCallback()` will default to unlimited
NSDictionary *params = @{
@"key1": @"value1",
@"key2": @"value2"
};
[[Branch getInstance] getShortURLWithCallback:^(NSString * _Nullable url, NSError * _Nullable error) {
NSLog(@"Generated short URL: %@", url);
}];
getShortURLWithParams (async, without tags)
Warning: The variations of getShortURLWithParams()
in this table should only be invoked after initSession()
completes, either within the callback or after a delay. If it is invoked before, Branch will silently initialize the SDK before the callback has been set, in order to carry out this method's required task. As a result, you may experience issues where the initSession()
callback does not fire.
Method | Description |
---|---|
Get a short URL without any items specified. | |
Get a short URL with the specified parameters, channel, and feature. | |
Get a short URL with the specified parameters, channel, feature, and stage. | |
Get a short URL with the specified parameters, channel, feature, stage, and alias. Warning: If you pass an alias that is already taken, the method call will fail. | |
Get a short URL with the specified parameters, channel, feature, stage, and link type. | |
Get a short URL with the specified parameters, channel, feature, stage, and match duration. |
Argument | Type | Description |
---|---|---|
|
| Dictionary of parameters to include in the short URL. |
|
| Callback called with the short URL. |
|
| The channel for the short URL. Examples include Facebook, Twitter, and SMS, depending on where it will be shared. |
|
| The feature the short URL is utilizing. Examples include Sharing, Referring, Inviting, etc. |
|
| The stage used for the generated short URL, indicating what part of a funnel the user is in. |
|
| The alias for the short URL. Warning: If you pass an alias that is already taken, the method call will fail. |
|
| The type of short URL this is, either single use or unlimited use. Single use means once per user. |
|
| How long to keep an unmatched link click in Branch's backend server queue before discarding. |
Example Usage
// Warning: This method should only be invoked after `initSession()` completes, either within the callback or after a delay
// The usage type of `getShortURLWithParams()` will default to unlimited
let linkProperties: BranchLinkProperties = BranchLinkProperties()
linkProperties.channel = "facebook"
linkProperties.feature = "sharing"
linkProperties.campaign = "content 123 launch"
linkProperties.stage = "new user"
linkProperties.alias = "myapp.com/customalias"
linkProperties.matchDuration = 0
func getShortUrl(params: [AnyHashable : Any], linkProperties: BranchLinkProperties, completion: @escaping (String?, Error?)->(Void)) -> Void {
Branch.getInstance().getShortUrl(withParams: params, andChannel: linkProperties.channel, andFeature: linkProperties.feature, andStage: linkProperties.stage, andAlias: linkProperties.alias) { (url, error) in
if (error == nil) {
completion(url, nil)
} else {
completion(nil, error)
}
}
}
// Warning: This method should only be invoked after `initSession()` completes, either within the callback or after a delay
// The usage type of `getShortURLWithParams()` will default to unlimited
Branch *branch = [Branch getInstance];
[branch getShortURLWithParams:nil andChannel:@"facebook" andFeature:nil andCallback:^(NSString *url, NSError *error) {
// Do stuff with URL here
}];
getShortURLWithParams (async, with tags)
Warning: The variations of getShortURLWithParams()
in this table should only be invoked after initSession()
completes, either within the callback or after a delay. If it is invoked before, Branch will silently initialize the SDK before the callback has been set, in order to carry out this method's required task. As a result, you may experience issues where the initSession()
callback does not fire.
Method | Description |
---|---|
Get a short URL with the specified parameters, tags, channel, feature, and stage. | |
Get a short URL with the specified parameters, tags, channel, feature, stage, and alias. Warning: If you pass an alias that is already taken, the method call will fail. | |
Get a short URL with the specified parameters, tags, channel, feature, stage, and link type. | |
Get a short URL with the specified parameters, tags, channel, feature, stage, and match duration. | |
Get a short URL with the specified parameters, tags, alias, match duration, channel, feature, and stage. Warning: If you pass an alias that is already taken, the method call will fail. | |
Get a short URL with the specified parameters, tags, alias, match duration, channel, feature, stage, and campaign. Warning: If you pass an alias that is already taken, the method call will fail. |
Argument | Type | Description |
---|---|---|
|
| Dictionary of parameters to include in the short URL. |
|
| An array of tags to associate with the short URL. Useful for tracking. |
|
| Callback called with the short URL. |
|
| The channel for the short URL. Examples include Facebook, Twitter, and SMS, depending on where it will be shared. |
|
| The feature the short URL is utilizing. Examples include Sharing, Referring, Inviting, etc. |
|
| The stage used for the generated short URL, indicating what part of a funnel the user is in. |
|
| The alias for the short URL. Warning: If you pass an alias that is already taken, the method call will fail. |
|
| The type of short URL this is, either single use or unlimited use. Single use means once per user. |
|
| How long to keep an unmatched link click in Branch's backend server queue before discarding. |
Example Usage
// Warning: This method should only be invoked after `initSession()` completes, either within the callback or after a delay
// The usage type of `getShortURLWithParams()` will default to unlimited
let linkProperties: BranchLinkProperties = BranchLinkProperties()
linkProperties.channel = "facebook"
linkProperties.feature = "sharing"
linkProperties.campaign = "content 123 launch"
linkProperties.stage = "new user"
linkProperties.tags = ["one", "two", "three"]
linkProperties.alias = "myapp.com/customalias"
linkProperties.matchDuration = 0
func generateShortUrl(params: [AnyHashable : Any], linkProperties: BranchLinkProperties, completion: @escaping (String?, Error?)->(Void)) -> Void {
Branch.getInstance().getShortUrl(withParams: params, andTags: linkProperties.tags, andAlias: linkProperties.alias, andMatchDuration: linkProperties.matchDuration, andChannel: linkProperties.channel, andFeature: linkProperties.feature, andStage: linkProperties.stage, andCampaign: linkProperties.campaign) { (url, error) in
if (error == nil) {
completion(url, nil)
} else {
completion(nil, error)
}
}
}
// Warning: This method should only be invoked after `initSession()` completes, either within the callback or after a delay
// The usage type of `getShortURLWithParams()` will default to unlimited
BranchLinkProperties *linkProperties = [[BranchLinkProperties alloc] init];
linkProperties.feature = @"share";
linkProperties.channel = @"facebook";
linkProperties.stage = @"new user";
linkProperties.tags = @["one", "two", "three"]
Branch *branch = [Branch getInstance];
[branch getShortURLWithParams:nil andTags:linkProperties.tags andChannel:linkProperties.channel andFeature:linkProperties.feature andStage:linkProperties.stage andCallback:^(NSString *url, NSError *error) {
// Do stuff with URL here
}];
getSpotlightUrlWithParams (async)
Warning: This method should only be invoked after initSession()
completes, either within the callback or after a delay. If it is invoked before, Branch will silently initialize the SDK before the callback has been set, in order to carry out this method's required task. As a result, you may experience issues where the initSession()
callback does not fire.
Method | Description |
---|---|
(void)getSpotlightUrlWithParams:(NSDictionary *)params callback:(callbackWithParams)callback; | Get a Spotlight URL with specified parameters. |
Argument | Type | Description |
---|---|---|
|
| Dictionary of parameters to include in the Spotlight URL. |
|
| Callback called with the Spotlight URL. |
Example Usage
// Warning: This method should only be invoked after `initSession()` completes, either within the callback or after a delay
let params: [String: Any] = [
"key1": "value1",
"key2": "value2"
]
Branch.getInstance().getSpotlightUrl(withParams: params) { (returnedParams, error) in
if let url = returnedParams?["url"] as? String {
print("Got spotlight URL with params: \(url)")
}
}
// Warning: This method should only be invoked after `initSession()` completes, either within the callback or after a delay
NSDictionary *params = @{
@"key1": @"value1",
@"key2": @"value2"
};
[[Branch getInstance] getSpotlightUrlWithParams:params callback:^(NSDictionary * _Nullable returnedParams, NSError * _Nullable error) {
NSLog(@"Got spotlight URL with params: %@", returnedParams[@"url"]);
}];
createDiscoverableContentWithTitle
Warning: The variations of createDiscoverableContentWithTitle
in this table are only useable in iOS 9 or above - earlier versions will simply receive the callback with an error.
Method | Description |
---|---|
(void)createDiscoverableContentWithTitle:(NSString *)title description:(NSString *)description; | Take the current screen and make it discoverable, adding it to Apple's Core Spotlight index. It will not be public by default. Type defaults to |
Take the current screen and make it discoverable, adding it to Apple's Core Spotlight index. It will not be public by default. Type defaults to | |
Take the current screen and make it discoverable, adding it to Apple's Core Spotlight index. Will be public if specified. Type defaults to | |
Take the current screen and make it discoverable, adding it to Apple's Core Spotlight index. Will be public if specified. You can override the type as desired, using one of the types provided in | |
Take the current screen and make it discoverable, adding it to Apple's Core Spotlight index. Will be public if specified. You can override the type as desired, using one of the types provided in | |
Take the current screen and make it discoverable, adding it to Apple's Core Spotlight index. Will be public if specified. You can override the type as desired, using one of the types provided in | |
Take the current screen and make it discoverable, adding it to Apple's Core Spotlight index. Will be public if specified. You can override the type as desired, using one of the types provided in | |
Take the current screen and make it discoverable, adding it to Apple's Core Spotlight index. Will be public if specified. You can override the type as desired, using one of the types provided in | |
Take the current screen and make it discoverable, adding it to Apple's Core Spotlight index. Will be public if specified. You can override the type as desired, using one of the types provided in | |
Take the current screen and make it discoverable, adding it to Apple's Core Spotlight index. Will be public if specified. You can override the type as desired, using one of the types provided in | |
Take the current screen and make it discoverable, adding it to Apple's Core Spotlight index. Will be public if specified. You can override the type as desired, using one of the types provided in | |
Take the current screen and make it discoverable, adding it to Apple's Core Spotlight index. Will be public if specified. You can override the type as desired, using one of the types provided in | |
Take the current screen and make it discoverable, adding it to Apple's Core Spotlight index. Will be public if specified. You can override the type as desired, using one of the types provided in | |
Take the current screen and make it discoverable, adding it to Apple's Core Spotlight index. Will be public if specified. You can override the type as desired, using one of the types provided in | |
Take the current screen and make it discoverable, adding it to Apple's Core Spotlight index. Will be public if specified. You can override the type as desired, using one of the types provided in |
Argument | Type | Description |
---|---|---|
|
| Title for the Spotlight preview item. |
|
| Description for the Spotlight preview item. |
|
| Callback called with the Branch URL this will fallback to. |
|
| Whether or not this item should be added to Apple's public search index. |
|
| The type to use for the |
|
| URL to an image to be used for the thumbnail in Spotlight. |
|
| A set of keywords to be used in Apple's search index. |
|
| Additional params to be added to the |
|
| Expiration date after which this will not appear in Apple's search index |
|
| The canonical identifier for the content for deduplication. |
|
| Callback called with the Branch URL this will fallback to. |
Example Usage
Branch.getInstance().createDiscoverableContent(withTitle: "Discover Branch", description: "Content Description")
[[Branch getInstance] createDiscoverableContentWithTitle:self.title
description:self.contentDescription
thumbnailUrl:[NSURL URLWithString:self.imageUrl]
canonicalId:self.canonicalIdentifier
linkParams:metadataAndProperties.copy
type:self.type
publiclyIndexable:publiclyIndexable
keywords:[NSSet setWithArray:self.keywords]
expirationDate:self.expirationDate
spotlightCallback:spotlightCallback];
indexOnSpotlightWithBranchUniversalObject
Warning: This method is only useable in iOS 9 or above - earlier versions will simply receive the callback with an error.
Method | Description |
---|---|
Get a Spotlight URL with specified parameters. |
Argument | Type | Description |
---|---|---|
|
| Dictionary of parameters to include in the Spotlight URL. |
|
| Callback called with the Spotlight URL. |
|
| Callback called when all Branch Universal Object instance are indexed. Dynamic URL generated and saved as Spotlight identifier. |
Example Usage
let buo = BranchUniversalObject(canonicalIdentifier: "item/12345")
let lp = BranchLinkProperties()
Branch.getInstance().indexOnSpotlight(with: buo, linkProperties: lp) { (universalObject, url, error) in
print("Indexed Branch Universal Object instance on Spotlight.")
}
BranchUniversalObject *buo = [[BranchUniversalObject alloc] initWithCanonicalIdentifier:@"item/12345"];
BranchLinkProperties *lp = [[BranchLinkProperties alloc] init];
[[Branch getInstance] indexOnSpotlightWithBranchUniversalObject:buo linkProperties:lp completion:^(BranchUniversalObject * _Nonnull universalObject, NSString * _Nonnull url, NSError * _Nonnull error) {
NSLog(@"Indexed Branch Universal Object instance on Spotlight.");
}];
indexOnSpotlightUsingSearchableItems
Warning: This method is only useable in iOS 9 or above - earlier versions will simply receive the callback with an error.
Method | Description |
---|---|
Index multiple Branch Universal Object instances using |
Argument | Type | Description |
---|---|---|
|
| Multiple Branch Universal Object instances are indexed on Spotlight using Spotlight metadata. |
|
| Callback called when all Branch Universal Object instances are indexed. The dynamic URL generated is returned as the |
Example Usage
let buoArray: [BranchUniversalObject] = [
BranchUniversalObject(canonicalIdentifier: "item/12345"),
BranchUniversalObject(canonicalIdentifier: "item/6789")
]
Branch.getInstance().indexOnSpotlight(usingSearchableItems: buoArray) { (universalObjects, error) in
print("Indexed Branch Universal Object instance on Spotlight.")
}
NSArray<BranchUniversalObject *> *buoArray = @[
[[BranchUniversalObject alloc] initWithCanonicalIdentifier:@"item/12345"],
[[BranchUniversalObject alloc] initWithCanonicalIdentifier:@"item/6789"]
];
[[Branch getInstance] indexOnSpotlightUsingSearchableItems:buoArray completion:^(NSArray<BranchUniversalObject *> * _Nonnull universalObjects, NSError * _Nonnull error) {
NSLog(@"Indexed Branch Universal Object instance on Spotlight.");
}];
removeSearchableItemWithBranchUniversalObject
Warning: This method is only useable in iOS 9 or above - earlier versions will simply receive the callback with an error.
Method | Description |
---|---|
Remove indexing of a Branch Universal Object instance, which is indexed using |
Argument | Type | Description |
---|---|---|
|
| The Branch Universal Object instance that is to be removed from indexing. |
|
| Called when the request has been journaled by the index. Here “journaled” means that the index makes a note that it has to perform this operation. Note that the request may not have completed. |
Example Usage
let buo = BranchUniversalObject(canonicalIdentifier: "item/12345")
Branch.getInstance().removeSearchableItem(with: buo) { (universalObject, error) in
print("Removed Branch Universal Object instance from Spotlight.")
}
BranchUniversalObject *buo = [[BranchUniversalObject alloc] initWithCanonicalIdentifier:@"item/12345"];
[[Branch getInstance] removeSearchableItemWithBranchUniversalObject:buo completion:^(BranchUniversalObject * _Nonnull universalObject, NSError * _Nonnull error) {
NSLog(@"Removed Branch Universal Object instance on Spotlight.");
}];
removeSearchableItemsWithBranchUniversalObject
Warning: This method is only useable in iOS 9 or above - earlier versions will simply receive the callback with an error.
Method | Description |
---|---|
Remove indexing of an array of Branch Universal Object instances, which are indexed using |
Argument | Type | Description |
---|---|---|
|
| The Branch Universal Object instances to remove from Spotlight indexing. Note: The Spotlight identifier of the BUO is used to remove indexing. |
|
| Called when the request has been journaled by the index. Here “journaled” means that the index makes a note that it has to perform this operation. Note that the request may not have completed. |
Example Usage
let buoArray: [BranchUniversalObject] = [
BranchUniversalObject(canonicalIdentifier: "item/12345"),
BranchUniversalObject(canonicalIdentifier: "item/6789")
]
Branch.getInstance().removeSearchableItems(with: buoArray) { (universalObjects, error) in
print("Removed Branch Universal Object instances on Spotlight.")
}
NSArray<BranchUniversalObject *> *buoArray = @[
[[BranchUniversalObject alloc] initWithCanonicalIdentifier:@"item/12345"],
[[BranchUniversalObject alloc] initWithCanonicalIdentifier:@"item/6789"]
];
[[Branch getInstance] removeSearchableItemsWithBranchUniversalObject:buoArray completion:^(NSArray<BranchUniversalObject *> * _Nonnull universalObjects, NSError * _Nonnull error) {
NSLog(@"Indexed Branch Universal Object instance on Spotlight.");
}];
removeAllPrivateContentFromSpotLightWithCallback
Warning: This method is only useable in iOS 9 or above - earlier versions will simply receive the callback with an error.
Method | Description |
---|---|
Remove all content Spotlight indexed, through either |
Argument | Type | Description |
---|---|---|
|
| Called when the request has been journaled by the index. Here “journaled” means that the index makes a note that it has to perform this operation. Note that the request may not have completed. |
Example Usage
Branch.getInstance().removeAllPrivateContentFromSpotLight { (error) in
print("Removed all private content from Spotlight.")
}
[[Branch getInstance] removeAllPrivateContentFromSpotLightWithCallback:^(NSError * _Nullable error) {
NSLog(@"Removed all private content from Spotlight.");
}];
passPasteItemProviders
Warnings:
This function only works with iOS 16 or above.
Do not call both
checkPasteboardOnInstall()
andpassPasteItemProviders()
, or useBranchPasteControl
without properly version checking, ascheckPasteboardOnInstall()
will be called on iOS 16+ as well.
Method | Description |
---|---|
(void)passPasteItemProviders:(NSArray<NSItemProvider > )itemProviders API_AVAILABLE(ios(16)); | Pass pasteboard items to the Branch SDK when the user implements |
Argument | Type | Description |
---|---|---|
|
| An array of item providers collected from the pasteboard. |
Example Usage
// Inside the ViewController
override func paste(itemProviders: [NSItemProvider]) {
if #available(iOS 16.0, *) {
Branch.getInstance().passPaste(itemProviders)
} else {
// Fallback on earlier versions
}
}
// Inside the ViewController
if (@available(iOS 16.0, *)) {
[[Branch getInstance] passPasteItemProviders:itemProviders]
}
setLogInAppPurchasesAsEventsEnabled
Method | Description |
---|---|
Log in-app purchases as Branch Events. |
Argument | Type | Description |
---|---|---|
|
| Set to |
Example Usage
Branch.getInstance().setLogInAppPurchasesAsEventsEnabled(true)
[[Branch getInstance] setLogInAppPurchasesAsEventsEnabled:YES];
logInAppPurchasesBranchEventsEnabled
Method | Description |
---|---|
Check to see if you are tracking in-app purchases as Branch Events. |
Example Usage
Branch.getInstance().logInAppPurchasesBranchEventsEnabled()
[[Branch getInstance] logInAppPurchasesBranchEventsEnabled];
logEventWithCompletion
Method | Description |
---|---|
(void)logEventWithCompletion:(void (^_Nullable)(BOOL success, NSError * _Nullable error))completion; | Logs the event on the Branch server. This version will callback on success/failure. |
Argument | Type | Description |
---|---|---|
|
| Completion handler containing any potential error. |
Example Usage
// This method should only be invoked after `initSession()`
// If it's invoked before, Branch will silently initialize the SDK before the callback has been set
let event = BranchEvent(standardEvent: .addToCart)
event.logEvent { (success, error) in
print("Event logged: \(success)")
}
// This method should only be invoked after `initSession()`
// If it's invoked before, Branch will silently initialize the SDK before the callback has been set
// Example 1
event = [BranchEvent standardEvent:BranchStandardEventInitiatePurchase];
[event logEventWithCompletion:^(BOOL success, NSError * _Nullable error) {
if (success) {
[self showAlert:@"Succesfully logged commerce event" withDescription:@""];
} else {
[self showAlert:@"Error sending commerce event:" withDescription:error.description];
}
}];
// Example 2
BranchEvent *event = [BranchEvent standardEvent:BranchStandardEventAddToCart];
[event logEventWithCompletion:^(BOOL success, NSError * _Nullable error) {
NSLog(@"Event logged: %@", @(success));
}];
logEvent
Method | Description |
---|---|
Logs the event on the Branch server. This version automatically caches and retries as necessary. |
Example Usage
// This method should only be invoked after `initSession()`
// If it's invoked before, Branch will silently initialize the SDK before the callback has been set
// Create a Branch Event (this example uses the `Purchase` event)
let event = BranchEvent.standardEvent(.purchase)
// Add a populated `BranchUniversalObject` to the event
let buo = BranchUniversalObject(canonicalIdentifier: "item/12345")
event.contentItems = [ buo ]
// Add additional event data
event.alias = "my custom alias"
event.transactionID = "12344555"
event.eventDescription = "event_description"
event.searchQuery = "item 123"
event.customData = [
"Custom_Event_Property_Key1": "Custom_Event_Property_val1",
"Custom_Event_Property_Key2": "Custom_Event_Property_val2"
]
// Log the event
event.logEvent()
// This method should only be invoked after `initSession()`
// If it is invoked before, Branch will silently initialize the SDK before the callback has been set
// Create a Branch Event (this example uses the `BranchStandardEventAddToCart` event)
BranchEvent *event = [BranchEvent standardEvent:BranchStandardEventAddToCart];
// Add a populated `BranchUniversalObject` to the event
BranchUniversalObject *buo = [[BranchUniversalObject alloc] initWithCanonicalIdentifier:@"item/12345"];
event.contentItems = (id) @[ buo ];
// Add additional event data
event.alias = @"my custom alias";
event.transactionID = @"12344555";
event.eventDescription = @"event_description";
event.searchQuery = @"item 123";
event.customData = (NSMutableDictionary*) @{
@"Custom_Event_Property_Key1": @"Custom_Event_Property_val1",
@"Custom_Event_Property_Key2": @"Custom_Event_Property_val2"
};
// Log the event
[event logEvent];
logEventWithTransaction
Method | Description |
---|---|
(void) logEventWithTransaction:(SKPaymentTransaction*_Nonnull)transaction; | Log an |
Argument | Type | Description |
---|---|---|
|
| The |
Example Usage
let event = BranchEvent(name: "PURCHASE")
event.logEvent(with: transaction as! SKPaymentTransaction)
BranchEvent *event = [[BranchEvent alloc] initWithName:@"eventName"];
[event logEventWithTransaction:(SKPaymentTransaction *)transaction];
addControlParam
Method | Description |
---|---|
(void)addControlParam:(NSString )controlParam withValue:(NSString )value; | Add a control parameter to a Branch Link Properties object. |
Argument | Type | Description |
---|---|---|
|
| The name of the control parameter. |
|
| The value of the control parameter. |
Example Usage
let lp = BranchLinkProperties()
lp.addControlParam("$desktop_url", withValue: "http://example.com/desktop")
lp.addControlParam("$ios_url", withValue: "http://example.com/ios")
lp.addControlParam("$ipad_url", withValue: "http://example.com/ios")
lp.addControlParam("$android_url", withValue: "http://example.com/android")
lp.addControlParam("$match_duration", withValue: "2000")
lp.addControlParam("custom_data", withValue: "yes")
lp.addControlParam("look_at", withValue: "this")
lp.addControlParam("nav_to", withValue: "over here")
lp.addControlParam("random", withValue: UUID.init().uuidString)
BranchLinkProperties *lp = [[BranchLinkProperties alloc] init];
lp.feature = @"facebook";
lp.channel = @"sharing";
lp.campaign = @"content 123 launch";
lp.stage = @"new user";
lp.tags = @[@"one", @"two", @"three"];
[lp addControlParam:@"$desktop_url" withValue: @"http://example.com/desktop"];
[lp addControlParam:@"$ios_url" withValue: @"http://example.com/ios"];
[lp addControlParam:@"$ipad_url" withValue: @"http://example.com/ios"];
[lp addControlParam:@"$android_url" withValue: @"http://example.com/android"];
[lp addControlParam:@"$match_duration" withValue: @"2000"];
[lp addControlParam:@"custom_data" withValue: @"yes"];
[lp addControlParam:@"look_at" withValue: @"this"];
[lp addControlParam:@"nav_to" withValue: @"over here"];
[lp addControlParam:@"random" withValue: [[NSUUID UUID] UUIDString]];
getBranchLinkPropertiesFromDictionary
Method | Description |
---|---|
(BranchLinkProperties )getBranchLinkPropertiesFromDictionary:(NSDictionary )dictionary; | Converts a given dictionary into a |
Argument | Type | Description |
---|---|---|
|
| A dictionary containing key-value pairs that map to the properties of a |
Example Usage
let lp = BranchLinkProperties.getBranchLinkProperties(from: lpDictionary)
// Example 1
NSDictionary *params = [self getFirstReferringParams];
if ([[params objectForKey:BRANCH_INIT_KEY_CLICKED_BRANCH_LINK] isEqual:@1]) {
return [BranchLinkProperties getBranchLinkPropertiesFromDictionary:params];
}
// Example 2
BranchLinkProperties *lp = [BranchLinkProperties getBranchLinkPropertiesFromDictionary:lpDictionary];
initWithFrame (BranchPasteControl)
Method | Description |
---|---|
Use the wrapper class |
Argument | Type | Description |
---|---|---|
|
| A |
|
| An optional |
Example Usage
// Inside the ViewController
if #available(iOS 16.0, *) {
// Setup `UIPasteControl` configuration
let pcConfig = UIPasteControl.Configuration()
pcConfig.baseBackgroundColor = UIColor.blue
pcConfig.displayMode = UIPasteControl.DisplayMode.iconOnly
// Create frame and button
let frameDimension = CGRect(x: 0, y: 0, width: 40, height: 40)
let bc = BranchPasteControl(frame: frameDimension, andConfiguration: pcConfig)
// Add `BranchPasteControl` button to superview
view.addSubview(bc)
}
// Inside the ViewController
if (@available(iOS 16.0, *)) {
// Setup `UIPasteControl` configuration
UIPasteControlConfiguration *pcConfig = [[UIPasteControlConfiguration alloc] init];
pcConfig.baseBackgroundColor = UIColor.blueColor;
pcConfig.displayMode = UIPasteControlDisplayModeIconOnly;
// Create frame and button
CGRect frameDimension = CGRectMake(0, 0, 120.0, 30.0);
BranchPasteControl *bc = [[BranchPasteControl alloc] initWithFrame:frameDimension AndConfiguration:pcConfig];
// Add `BranchPasteControl` button to superview
[view addSubview:bc];
}
showShareSheetWithQRCodeFromViewController
Method | Description |
---|---|
Create a Branch QR Code image and display it in a Share Sheet. |
Argument | Type | Description |
---|---|---|
|
| The ViewController. |
|
| Specifies the anchor UI element for presenting the Share Sheet. Accepts either a |
|
| The Branch Universal Object instance to share. |
|
| The Branch Link Properties object to associate with the Branch QR Code. |
|
| Completion handler containing any potential error. |
Example Usage
let qrCode = BranchQRCode()
qrCode.codeColor = UIColor.white
qrCode.backgroundColor = UIColor.blue
qrCode.centerLogo = "https://cdn.branch.io/branch-assets/1598575682753-og_image.png"
qrCode.width = 1024
qrCode.margin = 1
qrCode.imageFormat = .JPEG
let buo = BranchUniversalObject(canonicalIdentifier: "item/12345")
let lp = BranchLinkProperties()
// Display the QR code directly in a share sheet
qrCode.showShareSheetWithQRCode(from: self, anchor: nil, universalObject: buo, linkProperties: lp) { error in
// Showing a share sheet with the QR code
}
BranchQRCode *qrCode = [BranchQRCode new];
qrCode.codeColor = [[UIColor new] initWithRed:0.1 green:0.8392 blue:0.8667 alpha:1.0];
qrCode.backgroundColor = [UIColor whiteColor];
qrCode.width = @700;
qrCode.margin = @1;
qrCode.centerLogo = @"https://cdn.branch.io/branch-assets/1598575682753-og_image.png";
qrCode.imageFormat = BranchQRCodeImageFormatPNG;
BranchUniversalObject *buo = [[BranchUniversalObject alloc] initWithCanonicalIdentifier:@"item/12345"];
BranchLinkProperties *lp = [BranchLinkProperties new];
// Display the QR code directly in a share sheet
[qrCode showShareSheetWithQRCodeFromViewController:self anchor:nil universalObject:buo linkProperties:lp completion:^(NSError * _Nullable error) {
// Showing a share sheet with the QR code
}];
getQRCodeAsData
Method | Description |
---|---|
Create a Branch QR Code image. Return the QR code as |
Argument | Type | Description |
---|---|---|
|
| The Branch Universal Object instance to share. |
|
| The Branch Link Properties object to associate with the Branch QR Code. |
|
| Completion handler containing a Branch QR Code image or an error. |
Example Usage
let qrCode = BranchQRCode()
qrCode.codeColor = UIColor.white
qrCode.backgroundColor = UIColor.blue
qrCode.centerLogo = "https://cdn.branch.io/branch-assets/1598575682753-og_image.png"
qrCode.width = 1024
qrCode.margin = 1
qrCode.imageFormat = .JPEG
let buo = BranchUniversalObject(canonicalIdentifier: "item/12345")
let lp = BranchLinkProperties()
qrCode.getAsData(buo, linkProperties: lp) { qrCodeImage, error in
// Do something with your QR code here...
}
BranchQRCode *qrCode = [BranchQRCode new];
qrCode.codeColor = [[UIColor new] initWithRed:0.1 green:0.8392 blue:0.8667 alpha:1.0];
qrCode.backgroundColor = [UIColor whiteColor];
qrCode.width = @700;
qrCode.margin = @1;
qrCode.centerLogo = @"https://cdn.branch.io/branch-assets/1598575682753-og_image.png";
qrCode.imageFormat = BranchQRCodeImageFormatPNG;
BranchUniversalObject *buo = [[BranchUniversalObject alloc] initWithCanonicalIdentifier:@"item/12345"];
BranchLinkProperties *lp = [BranchLinkProperties new];
[qrCode getQRCodeAsData:buo linkProperties:lp completion:^(UIImage * _Nonnull qrCode, NSError * _Nonnull error) {
// Do something with the QR code here...
}];
getQRCodeAsImage
Method | Description |
---|---|
Create a Branch QR Code image. Return the QR code as |
Argument | Type | Description |
---|---|---|
|
| The Branch Universal Object instance to share. |
|
| The Branch Link Properties object to associate with the Branch QR Code. |
|
| Completion handler containing a Branch QR Code image or an error. |
Example Usage
let qrCode = BranchQRCode()
qrCode.codeColor = UIColor.white
qrCode.backgroundColor = UIColor.blue
qrCode.centerLogo = "https://cdn.branch.io/branch-assets/1598575682753-og_image.png"
qrCode.width = 1024
qrCode.margin = 1
qrCode.imageFormat = .JPEG
let buo = BranchUniversalObject(canonicalIdentifier: "item/12345")
let lp = BranchLinkProperties()
qrCode.getAsImage(buo, linkProperties: lp) { qrCodeImage, error in
// Do something with your QR code here...
}
BranchQRCode *qrCode = [BranchQRCode new];
qrCode.codeColor = [[UIColor new] initWithRed:0.1 green:0.8392 blue:0.8667 alpha:1.0];
qrCode.backgroundColor = [UIColor whiteColor];
qrCode.width = @700;
qrCode.margin = @1;
qrCode.centerLogo = @"https://cdn.branch.io/branch-assets/1598575682753-og_image.png";
qrCode.imageFormat = BranchQRCodeImageFormatPNG;
BranchUniversalObject *buo = [[BranchUniversalObject alloc] initWithCanonicalIdentifier:@"item/12345"];
BranchLinkProperties *lp = [BranchLinkProperties new];
[qrCode getQRCodeAsImage:buo linkProperties:lp completion:^(UIImage * _Nonnull qrCode, NSError * _Nonnull error) {
// Do something with the QR code here...
}];
initSessionWithLaunchOptions (UIScene)
This method is part of the BranchScene : NSObject
interface. Learn more about apps using scenes.
Method | Description |
---|---|
Initialize a Branch session with your app's specific launch options. Callback may contain a |
Argument | Type | Description |
---|---|---|
|
| The launch options provided by your AppDelegate file's |
|
| A callback that is called when the session is opened. This will be called multiple times during the app's life, including any time the app goes through a background/foreground cycle. |
Example Usage
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch
BranchScene.shared().initSession(launchOptions: launchOptions, registerDeepLinkHandler: { (params, error, scene) in
})
return true
}
}
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[[BranchScene shared] initSessionWithLaunchOptions:launchOptions registerDeepLinkHandler:^(NSDictionary * _Nullable params, NSError * _Nullable error, UIScene * _Nullable scene) {
}];
return YES;
}
scene (UIScene)
This method is part of the BranchScene : NSObject
interface. Learn more about apps using scenes.
Example Usage
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
// Use `scene` to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead)
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let _ = (scene as? UIWindowScene) else { return }
// Workaround for SceneDelegate `continueUserActivity` not getting called on cold start:
if let userActivity = connectionOptions.userActivities.first {
BranchScene.shared().scene(scene, continue: userActivity)
} else if !connectionOptions.urlContexts.isEmpty {
BranchScene.shared().scene(scene, openURLContexts: connectionOptions.urlContexts)
}
}
}
@interface AppDelegate ()
@interface SceneDelegate ()
@end
@implementation SceneDelegate
// Use `scene` to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead)
- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
// Workaround for SceneDelegate `continueUserActivity` not getting called on cold start
NSUserActivity *activity = [[connectionOptions userActivities] allObjects].firstObject;
if (activity) {
[[BranchScene shared] scene:scene continueUserActivity:activity];
} else if ([[connectionOptions URLContexts] count] != 0) {
[[BranchScene shared] scene:scene openURLContexts: [connectionOptions URLContexts]];
}
}
@end
initWithUniversalObject
This method is part of the BranchShareLink : NSObject <UIActivityItemSource>
interface.
Method | Description |
---|---|
Create a |
Argument | Type | Description |
---|---|---|
|
| The Branch Universal Object instance to associate with the |
|
| The Branch Link Properties object to associate with the |
Example Usage
let buo = BranchUniversalObject(canonicalIdentifier: "item/12345")
let lp = BranchLinkProperties()
let sharelink = BranchShareLink(universalObject: buo, linkProperties: lp)
BranchUniversalObject *buo = [[BranchUniversalObject alloc] initWithCanonicalIdentifier:@"item/12345"];
BranchLinkProperties *lp = [BranchLinkProperties new];
BranchShareLink *shareLink =
[[BranchShareLink alloc]
initWithUniversalObject:buo
linkProperties:lp];
activityItems
This method is part of the BranchShareLink : NSObject <UIActivityItemSource>
interface.
Method | Description |
---|---|
Use a |
Example Usage
let buo = BranchUniversalObject(canonicalIdentifier: "item/12345")
let lp = BranchLinkProperties()
let shareLink = BranchShareLink(universalObject: buo, linkProperties: lp)
shareLink.activityItems()
BranchUniversalObject *buo = [[BranchUniversalObject alloc] initWithCanonicalIdentifier:@"item/12345"];
BranchLinkProperties *lp = [BranchLinkProperties new];
BranchShareLink *shareLink =
[[BranchShareLink alloc]
initWithUniversalObject:buo
linkProperties:lp];
[shareLink activityItems];
presentActivityViewControllerFromViewController
This method is part of the BranchShareLink : NSObject <UIActivityItemSource>
interface.
Method | Description |
---|---|
Use a |
Argument | Type | Description |
---|---|---|
|
| The parent view controller from which to present the activity sheet. |
|
| The anchor point for the activity sheet. Used for iPad form factors. |
Example Usage
let buo = BranchUniversalObject(canonicalIdentifier: "item/12345")
let lp = BranchLinkProperties()
let shareLink = BranchShareLink(universalObject: buo, linkProperties: lp)
shareLink.presentActivityViewController(from: self, anchor: nil)
BranchUniversalObject *buo = [[BranchUniversalObject alloc] initWithCanonicalIdentifier:@"item/12345"];
BranchLinkProperties *lp = [BranchLinkProperties new];
BranchShareLink *shareLink =
[[BranchShareLink alloc]
initWithUniversalObject:buo
linkProperties:lp];
[shareLink presentActivityViewControllerFromViewController:self anchor:nil];
addLPLinkMetadata
This method is part of the BranchShareLink : NSObject <UIActivityItemSource>
interface.
Warning: This method is only available on iOS 13.0 or greater.
Method | Description |
---|---|
Create and attach an |
Argument | Type | Description |
---|---|---|
|
| The string that will appear in the share sheet preview. |
|
| The image used for the share sheet preview icon. |
Example Usage
let buo = BranchUniversalObject(canonicalIdentifier: "item/12345")
let lp = BranchLinkProperties()
let shareLink = BranchShareLink(universalObject: buo, linkProperties: lp)
shareLink.addLPLinkMetadata("LPLinkMetaData Link Title", icon: iconImg)
BranchUniversalObject *buo = [[BranchUniversalObject alloc] initWithCanonicalIdentifier:@"item/12345"];
BranchLinkProperties *lp = [BranchLinkProperties new];
BranchShareLink *shareLink =
[[BranchShareLink alloc]
initWithUniversalObject:buo
linkProperties:lp];
[shareLink addLPLinkMetadata:@"LPLinkMetadata Link Title" icon:iconImg];
registerView
This method is part of the BranchUniversalObject : NSObject
interface.
Method | Description |
---|---|
List a Branch Universal Object instance on Spotlight and log a |
Example Usage
let buo = BranchUniversalObject(canonicalIdentifier: "item/12345")
buo.registerView()
BranchUniversalObject *buo = [[BranchUniversalObject alloc] initWithCanonicalIdentifier:@"item/12345"];
[buo registerView]
registerViewWithCallback
This method is part of the BranchUniversalObject : NSObject
interface.
Method | Description |
---|---|
Log a User Content View Branch Event. |
Argument | Type | Description |
---|---|---|
|
| Callback containing a dictionary of parameters or an error. |
Example Usage
let buo = BranchUniversalObject(canonicalIdentifier: "item/12345")
buo.registerView { (params: [AnyHashable: Any]?, error: Error?) in
print("BUO was listed on spotlight and event was logged: \(String(describing: params))")
}
BranchUniversalObject *buo = [BranchUniversalObject new];
buo.canonicalIdentifier = @"Uniq!";
buo.title = @"Object Title";
// Example 1
[buo registerViewWithCallback:^(NSDictionary * _Nullable params, NSError * _Nullable error) {
XCTAssertNil(error);
}];
// Example 2
[buo registerViewWithCallback:^(NSDictionary * _Nullable params, NSError * _Nullable error) {
NSLog(@"BUO was listed on spotlight and event was logged: %@", params);
}];
getShortUrlWithLinkProperties
This method is part of the BranchUniversalObject : NSObject
interface.
Method | Description |
---|---|
(nullable NSString )getShortUrlWithLinkProperties:(nonnull BranchLinkProperties )linkProperties; | Returns a Branch short URL for the specified Branch Universal Object instance and includes the passed Link Properties object. |
Returns a Branch short URL for the specified Branch Universal Object instance and includes the passed Link Properties object. Callback may contain URL or error. |
Argument | Type | Description |
---|---|---|
|
| The Branch Link Properties object to associate with the Branch short URL. |
|
| Callback containing a string URL or an error. |
Example Usage
let buo = BranchUniversalObject(canonicalIdentifier: "item/12345")
let lp = BranchLinkProperties()
buo.getShortUrl(with: lp) { (url, error) in
if (error == nil) {
print("Got my Branch link to share: (url)")
} else {
print(String(format: "Branch error : %@", error! as CVarArg))
}
}
BranchUniversalObject *buo = [[BranchUniversalObject alloc] initWithCanonicalIdentifier:@"item/12345"];
BranchLinkProperties *lp = [BranchLinkProperties new];
[buo getShortUrlWithLinkProperties:lp andCallback:^(NSString *url, NSError *error) {
if (!error) {
NSLog(@"got my Branch invite link to share: %@", url);
}
}];
getShortUrlWithLinkPropertiesAndIgnoreFirstClick
This method is part of the BranchUniversalObject : NSObject
interface.
Method | Description |
---|---|
Returns a Branch short URL for the specified Branch Universal Object instance and includes the passed Link Properties object. |
Argument | Type | Description |
---|---|---|
|
| The link properties to include with the Branch short URL. |
Example Usage
let buo = BranchUniversalObject(canonicalIdentifier: "item/12345")
let lp = BranchLinkProperties()
buo.getShortUrl(with: lp) { (url, error) in
if (error == nil) {
print("Got my Branch link to share: (url)")
} else {
print(String(format: "Branch error : %@", error! as CVarArg))
}
}
BranchUniversalObject *buo = [[BranchUniversalObject alloc] initWithCanonicalIdentifier:@"item/12345"];
BranchLinkProperties *lp = [BranchLinkProperties new];
[buo getShortUrlWithLinkPropertiesAndIgnoreFirstClick:lp andCallback:^(NSString *url, NSError *error) {
if (!error) {
NSLog(@"got my Branch invite link to share: %@", url);
}
}];
getLongUrlWithChannel
This method is part of the BranchUniversalObject : NSObject
interface.
Method | Description |
---|---|
Returns a Branch long URL for the specified Branch Universal Object instance and includes |
Argument | Type | Description |
---|---|---|
|
| The channel to include with the long URL. |
|
| The tags to include with the long URL. |
|
| The feature to include with the long URL. |
|
| The stage to include with the long URL. |
|
| The alias to include with the long URL. |
Example Usage
let longUrl = Branch.getInstance().getLongURL(withChannel: "channel", andTags: ["tag1"], andFeature: "feature", andStage: "stage", andAlias: "testingLinkAlias123")
NSString *longUrl = [[Branch getInstance] getLongURLWithChannel:@"channel" andTags:@[@"tag1"] andFeature:@"feature" andStage:@"stage" andAlias:@"testingLinkAlias123"];
showShareSheetWithShareText
This method is part of the BranchUniversalObject : NSObject
interface.
Method | Description |
---|---|
Show the user a Share Sheet and specify the text to display. |
Argument | Type | Description |
---|---|---|
|
| The message associated with the shareable Branch Deep Link. |
|
| The |
Example Usage
let buo = BranchUniversalObject(canonicalIdentifier: "item/12345")
buo.showShareSheet(withShareText: "Share Your Monster!") { (activityType, success) in
if (success) {
print("Log an event here")
}
}
BranchUniversalObject *buo = [[BranchUniversalObject alloc] initWithCanonicalIdentifier:@"item/12345"];
[self.buo
showShareSheetWithShareText:@"Super amazing thing I want to share"
completion:^(NSString *activityType, BOOL completed) {
if (completed) {
NSLog(@"%@", [NSString stringWithFormat:@"Completed sharing to %@", activityType]);
}
}
}];
showShareSheetWithLinkProperties
This method is part of the BranchUniversalObject : NSObject
interface.
Method | Description |
---|---|
Show the user a Share Sheet and specify the text to display as well as the link properties. | |
Show the user a Share Sheet and specify the text to display as well as the link properties. Include | |
On iPad, show the user a Share Sheet and specify the text to display as well as the link properties. | |
On iPad, show the user a Share Sheet and specify the text to display as well as the link properties. Include |
Argument | Type | Description |
---|---|---|
|
| The Branch Link Properties object to associate with the Branch Link. |
|
| The message associated with the shareable Branch Deep Link. |
|
| The |
|
| For iPads. |
|
| May contain |
Example Usage
let buo = BranchUniversalObject(canonicalIdentifier: "item/12345")
let lp = BranchLinkProperties()
let message = "Check out this link"
buo.showShareSheet(with: lp, andShareText: message, from: self) { (activityType, completed) in
print(activityType ?? "")
}
BranchUniversalObject *buo = [[BranchUniversalObject alloc] initWithCanonicalIdentifier:@"item/12345"];
BranchLinkProperties *lp = [[BranchLinkProperties alloc] init];
[buo showShareSheetWithLinkProperties:lp
andShareText:shareText
fromViewController:self.parentViewController
completion:^(NSString *activityType, BOOL completed) {
if (completed) {
NSLog(@"Completed sharing to %@", activityType);
} else {
NSLog(@"Sharing failed");
}
}
];
listOnSpotlight
This method is part of the BranchUniversalObject : NSObject
interface.
Method | Description |
---|---|
List content on iOS Spotlight. |
Example Usage
let buo = BranchUniversalObject(canonicalIdentifier: "item/12345")
buo.listOnSpotlight()
BranchUniversalObject *buo = [[BranchUniversalObject alloc] initWithCanonicalIdentifier:@"item/12345"];
[buo listOnSpotlight];
listOnSpotlightWithCallback
This method is part of the BranchUniversalObject : NSObject
interface.
Method | Description |
---|---|
List content on iOS Spotlight and include a callback. |
Argument | Type | Description |
---|---|---|
|
| A callback including either the URL for the content or an error. |
Example Usage
let buo = BranchUniversalObject(canonicalIdentifier: "item/12345")
buo.listOnSpotlight { (url, error) in
if let spotlightUrl = url {
print("BUO was listed on spotlight: \(spotlightUrl)")
}
}
BranchUniversalObject *buo = [[BranchUniversalObject alloc] initWithCanonicalIdentifier:@"item/12345"];
// Example 1
[buo listOnSpotlightWithCallback:^(NSString *url, NSError *error) {
if (!error) {
NSLog(@"shortURL: %@", url);
} else {
NSLog(@"error: %@", error);
}
}];
// Example 2
[buo listOnSpotlightWithCallback:^(NSString * _Nullable url, NSError * _Nullable error) {
NSLog(@"BUO was listed on spotlight: %@", url);
}];
listOnSpotlightWithLinkProperties
This method is part of the BranchUniversalObject : NSObject
interface.
Method | Description |
---|---|
List content on iOS Spotlight with link properties and include a callback. |
Argument | Type | Description |
---|---|---|
|
| The Branch Link Properties object to associate with the Branch Link. |
|
| A callback including either the URL for the content or an error. |
Example Usage
let buo = BranchUniversalObject(canonicalIdentifier: "item/12345")
let lp = BranchLinkProperties()
buo.listOnSpotlight(with: lp) { (url, error) in
if (error == nil) {
NSLog("Successfully indexed on spotlight \(url)")
}
}
BranchUniversalObject *buo = [[BranchUniversalObject alloc] initWithCanonicalIdentifier:@"item/12345"];
BranchLinkProperties *lp = [[BranchLinkProperties alloc] init];
// Example 1
[buo listOnSpotlightWithCallback:^(NSString *url, NSError *error) {
if (!error) {
NSLog(@"shortURL: %@", url);
} else {
NSLog(@"error: %@", error);
}
}];
// Example 2
[buo listOnSpotlightWithCallback:^(NSString * _Nullable url, NSError * _Nullable error) {
NSLog(@"BUO was listed on spotlight: %@", url);
}];
removeFromSpotlightWithCallback
This method is part of the BranchUniversalObject : NSObject
interface.
Method | Description |
---|---|
(void)removeFromSpotlightWithCallback:(void (^_Nullable)(NSError * _Nullable error))completion; | Remove content from iOS Spotlight and include a callback. |
Argument | Type | Description |
---|---|---|
|
| A callback containing an error (nullable). |
Example Usage
let buo = BranchUniversalObject(canonicalIdentifier: "item/12345")
buo.removeFromSpotlight { (error) in
if (error == nil) {
print("BUO successfully removed")
}
}
BranchUniversalObject *buo = [[BranchUniversalObject alloc] initWithCanonicalIdentifier:@"item/12345"];
[buo removeFromSpotlightWithCallback:^(NSError * _Nullable error) {
NSString *title = @"Remove private indexing";
NSString *message;
if (!error) {
message = @"Successfully removed indexing";
}
else {
message = [error description];
}
}];