-
- All Implemented Interfaces:
-
io.branch.referral.BranchViewHandler.IBranchViewEvents,io.branch.referral.StoreReferrerGooglePlayStore.IGoogleInstallReferrerEvents,io.branch.referral.StoreReferrerHuaweiAppGallery.IHuaweiInstallReferrerEvents,io.branch.referral.StoreReferrerSamsungGalaxyStore.ISamsungInstallReferrerEvents,io.branch.referral.StoreReferrerXiaomiGetApps.IXiaomiInstallReferrerEvents,io.branch.referral.SystemObserver.AdsParamsFetchEvents
public class Branch implements BranchViewHandler.IBranchViewEvents, SystemObserver.AdsParamsFetchEvents, StoreReferrerGooglePlayStore.IGoogleInstallReferrerEvents, StoreReferrerHuaweiAppGallery.IHuaweiInstallReferrerEvents, StoreReferrerSamsungGalaxyStore.ISamsungInstallReferrerEvents, StoreReferrerXiaomiGetApps.IXiaomiInstallReferrerEvents
The core object required when using Branch SDK. You should declare an object of this type at the class-level of each Activity or Fragment that you wish to use Branch functionality within.
Normal instantiation of this object would look like this:
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceBranch.BranchReferralInitListenerAn Interface class that is implemented by all classes that make use of BranchReferralInitListener, defining a single method that takes a list of params in JSONObject format, and an error message of BranchError format that will bereturned on failure of the request response.
public interfaceBranch.BranchUniversalReferralInitListenerAn Interface class that is implemented by all classes that make use of BranchUniversalReferralInitListener, defining a single method that provides BranchUniversalObject, LinkProperties and an error message of BranchError format that will bereturned on failure of the request response.In case of an error the value for BranchUniversalObject and LinkProperties are set to null.
public interfaceBranch.BranchReferralStateChangedListenerAn Interface class that is implemented by all classes that make use of BranchReferralStateChangedListener, defining a single method that takes a value of Boolean format, and an error message of BranchError format that will bereturned on failure of the request response.
public interfaceBranch.BranchLinkCreateListenerAn Interface class that is implemented by all classes that make use of BranchLinkCreateListener, defining a single method that takes a URL String format, and an error message of BranchError format that will bereturned on failure of the request response.
public interfaceBranch.BranchLinkShareListenerAn Interface class that is implemented by all classes that make use of BranchLinkShareListener, defining methods to listen for link sharing status.
public interfaceBranch.ExtendedBranchLinkShareListenerAn extended version of BranchLinkShareListener with callback that supports updating link data or properties after user select a channel to shareThis will provide the extended callback onChannelSelected only when sharing a link using Branch Universal Object.
public interfaceBranch.IChannelPropertiesAn interface class for customizing sharing properties with selected channel.
public interfaceBranch.BranchListResponseListenerAn Interface class that is implemented by all classes that make use of BranchListResponseListener, defining a single method that takes a list of JSONArray format, and an error message of BranchError format that will bereturned on failure of the request response.
public interfaceBranch.LogoutStatusListenerCallback interface for listening logout status
public enumBranch.CreditHistoryOrderenum containing the sort options for return of credit history.
public interfaceBranch.IBranchViewControlInterface for defining optional Branch view behaviour for Activities
public classBranch.InitSessionBuilderpublic classBranch.ShareLinkBuilderLegacy class for building a share link dialog. Use BranchShareSheetBuilder instead.
-
Field Summary
Fields Modifier and Type Field Description public final static StringFEATURE_TAG_SHAREpublic final static StringFEATURE_TAG_REFERRALpublic final static StringFEATURE_TAG_INVITEpublic final static StringFEATURE_TAG_DEALpublic final static StringFEATURE_TAG_GIFTpublic final static StringREDEEM_CODEpublic final static StringREFERRAL_BUCKET_DEFAULTpublic final static StringREFERRAL_CODE_TYPEpublic final static intREFERRAL_CREATION_SOURCE_SDKpublic final static StringREFERRAL_CODEpublic final static StringREDIRECT_DESKTOP_URLpublic final static StringREDIRECT_ANDROID_URLpublic final static StringREDIRECT_IOS_URLpublic final static StringREDIRECT_IPAD_URLpublic final static StringREDIRECT_FIRE_URLpublic final static StringREDIRECT_BLACKBERRY_URLpublic final static StringREDIRECT_WINDOWS_PHONE_URLpublic final static StringOG_TITLEpublic final static StringOG_DESCpublic final static StringOG_IMAGE_URLpublic final static StringOG_VIDEOpublic final static StringOG_URLpublic final static StringOG_APP_IDpublic final static StringDEEPLINK_PATHpublic final static StringALWAYS_DEEPLINKpublic final static intREFERRAL_CODE_LOCATION_REFERREEpublic final static intREFERRAL_CODE_LOCATION_REFERRING_USERpublic final static intREFERRAL_CODE_LOCATION_BOTHpublic final static intREFERRAL_CODE_AWARD_UNLIMITEDpublic final static intREFERRAL_CODE_AWARD_UNIQUEpublic final static intLINK_TYPE_UNLIMITED_USEpublic final static intLINK_TYPE_ONE_TIME_USEpublic final static longNO_PLAY_STORE_REFERRER_WAITpublic booleancloseRequestNeededprivate booleanisInstantDeepLinkPossibleprivate final TrackingControllertrackingControllerprivate static StringpluginVersion
-
Method Summary
Modifier and Type Method Description booleanisInstantDeepLinkPossible()TrackingControllergetTrackingController()static StringgetPluginVersion()static synchronized BranchgetInstance()Singleton method to return the pre-initialised object of the type Branch. static synchronized BranchgetAutoInstance(@NonNull() Context context)Singleton method to return the pre-initialised, or newly initialise and return, a singletonobject of the type Branch. static BranchgetAutoInstance(@NonNull() Context context, @NonNull() String branchKey)Singleton method to return the pre-initialised, or newly initialise and return, a singletonobject of the type Branch. ContextgetApplicationContext()voidsetBranchRemoteInterface(BranchRemoteInterface remoteInterface)Sets a custom Branch Remote interface for handling RESTful requests. BranchRemoteInterfacegetBranchRemoteInterface()static voidenableTestMode()Enables the test mode for the SDK. static voiddisableTestMode()Disables the test mode for the SDK. voiddisableAdNetworkCallouts(boolean disabled)Disable (or re-enable) ad network callouts. static voidexpectDelayedSessionInitialization(boolean expectDelayedInit)Temporarily disables auto session initialization until user initializes themselves.Context: Branch expects session initialization to be started in LauncherActivity.onStart(),if session initialization has not been started/completed by the time ANY Activity resumes,Branch will auto-initialize. static voidsetAPIUrl(String url)Sets a custom base URL for all calls to the Branch API. static voidsetCDNBaseUrl(String url)Sets a custom CDN base URL. voiddisableTracking(boolean disableTracking)Method to change the Tracking state. booleanisTrackingDisabled()Checks if tracking is disabled. static voidenablePlayStoreReferrer(long delay)static voidsetPlayStoreReferrerCheckTimeout(long delay)Set timeout for Play Store Referrer library. static voiddisableInstantDeepLinking(boolean disableIDL)Disables or enables the instant deep link functionality. voidresetUserSession()Manually sets the Boolean value, that indicates that the Branch API connection hasbeen initialised, to false - forcing re-initialisation. voidsetRetryCount(int retryCount)Sets the max number of times to re-attempt a timed-out request to the Branch API, beforeconsidering the request to have failed entirely. voidsetRetryInterval(int retryInterval)Sets the amount of time in milliseconds to wait before re-attempting a timed-out requestto the Branch API. voidsetNetworkTimeout(int timeout)Sets the duration in milliseconds that the system should wait for a response before timingout any Branch API. voidsetNetworkConnectTimeout(int connectTimeout)Sets the duration in milliseconds that the system should wait for initializing a network* request. voidsetNoConnectionRetryMax(int retryMax)In cases of persistent no internet connection or offline modes,set a maximum number of attempts for the Branch Request to be tried. voidsetReferrerGclidValidForWindow(long window)Sets the window for the referrer GCLID field. static voiddisableDeviceIDFetch(Boolean deviceIdFetch)Method to control reading Android ID from device. static booleanisDeviceIDFetchDisabled()Returns true if reading device id is disabled voidsetDeepLinkDebugMode(JSONObject debugParams)Sets the key-value pairs for debugging the deep link. voiddisableAppList()voidenableFacebookAppLinkCheck()Enable Facebook app link check operation during Branch initialisation. voidsetLimitFacebookTracking(boolean isLimitFacebookTracking)Enables or disables app tracking with Branch or any other third parties that Branch use internally voidsetRequestMetadata(@NonNull() String key, @NonNull() String value)Add key value pairs to all requests BranchaddInstallMetadata(@NonNull() String key, @NonNull() String value)This API allows to tag the install with custom attribute. BranchsetPreinstallCampaign(@NonNull() String preInstallCampaign)wrapper method to add the pre-install campaign analytics BranchsetPreinstallPartner(@NonNull() String preInstallPartner)wrapper method to add the pre-install campaign analytics static voidsetIsUserAgentSync(boolean sync)static voidenableCookieBasedMatching(String cookieMatchDomain)Enabled Strong matching check using chrome cookies. static voidenableCookieBasedMatching(String cookieMatchDomain, int delay)Enabled Strong matching check using chrome cookies. static voidregisterPlugin(String name, String version)voidonAdsParamsFetchFinished()voidonGoogleInstallReferrerEventsFinished()voidonHuaweiInstallReferrerEventsFinished()voidonSamsungInstallReferrerEventsFinished()voidonXiaomiInstallReferrerEventsFinished()BranchaddWhiteListedScheme(String urlWhiteListPattern)Branch collect the URLs in the incoming intent for better attribution. BranchsetWhiteListedSchemes(List<String> urlWhiteListPatternList)Branch collect the URLs in the incoming intent for better attribution. BranchaddUriHostsToSkip(String urlSkipPattern)Branch collect the URLs in the incoming intent for better attribution. voidsetIdentity(@NonNull() String userId)Identifies the current user to the Branch API by supplying a unique identifier as a String value. voidsetIdentity(@NonNull() String userId, @Nullable() Branch.BranchReferralInitListener callback)Identifies the current user to the Branch API by supplying a unique identifier as a String value, with a callback specified to perform a defined action upon successfulresponse to request. voidgetCrossPlatformIds(@NonNull() ServerRequestGetCPID.BranchCrossPlatformIdListener callback)Gets all available cross platform ids. voidgetLastAttributedTouchData(@NonNull() ServerRequestGetLATD.BranchLastAttributedTouchDataListener callback)Gets the available last attributed touch data. voidgetLastAttributedTouchData(ServerRequestGetLATD.BranchLastAttributedTouchDataListener callback, int attributionWindow)Gets the available last attributed touch data with a custom set attribution window. booleanisUserIdentified()Indicates whether or not this user has a custom identity specified for them. voidlogout()This method should be called if you know that a different person is about to use the app. voidlogout(Branch.LogoutStatusListener callback)This method should be called if you know that a different person is about to use the app. voidloadRewards()voidloadRewards(Branch.BranchReferralStateChangedListener callback)intgetCredits()intgetCreditsForBucket(String bucket)voidredeemRewards(int count)voidredeemRewards(int count, Branch.BranchReferralStateChangedListener callback)voidredeemRewards(@NonNull() String bucket, int count)voidredeemRewards(@NonNull() String bucket, int count, Branch.BranchReferralStateChangedListener callback)voidgetCreditHistory(Branch.BranchListResponseListener callback)voidgetCreditHistory(@NonNull() String bucket, Branch.BranchListResponseListener callback)voidgetCreditHistory(@NonNull() String afterId, int length, @NonNull() Branch.CreditHistoryOrder order, Branch.BranchListResponseListener callback)voidgetCreditHistory(String bucket, String afterId, int length, @NonNull() Branch.CreditHistoryOrder order, Branch.BranchListResponseListener callback)voiduserCompletedAction(@NonNull() String action, JSONObject metadata)A void call to indicate that the user has performed a specific action and for that to bereported to the Branch API, with additional app-defined meta data to go along with that action. voiduserCompletedAction(String action)A void call to indicate that the user has performed a specific action and for that to bereported to the Branch API. voiduserCompletedAction(String action, BranchViewHandler.IBranchViewEvents callback)A void call to indicate that the user has performed a specific action and for that to bereported to the Branch API. voiduserCompletedAction(@NonNull() String action, JSONObject metadata, BranchViewHandler.IBranchViewEvents callback)A void call to indicate that the user has performed a specific action and for that to bereported to the Branch API, with additional app-defined meta data to go along with that action. voidsendCommerceEvent(@NonNull() CommerceEvent commerceEvent, JSONObject metadata, BranchViewHandler.IBranchViewEvents callback)voidsendCommerceEvent(@NonNull() CommerceEvent commerceEvent)JSONObjectgetFirstReferringParams()Returns the parameters associated with the link that referred the user. voidremoveSessionInitializationDelay()JSONObjectgetFirstReferringParamsSync()This function must be called from a non-UI thread! JSONObjectgetLatestReferringParams()Returns the parameters associated with the link that referred the session. JSONObjectgetLatestReferringParamsSync()This function must be called from a non-UI thread! voidaddFacebookPartnerParameterWithName(@NonNull() String key, @NonNull() String value)Add a Partner Parameter for Facebook.Once set, this parameter is attached to installs, opens and events until cleared or the app restarts. voidclearPartnerParameters()Clears all Partner Parameters JSONObjectgetDeeplinkDebugParams()voidcancelShareLinkDialog(boolean animateClose)Cancel current share link operation and Application selector dialog. DeviceInfogetDeviceInfo()BranchPluginSupportgetBranchPluginSupport()BranchQRCodeCachegetBranchQRCodeCache()voidsetInstantDeepLinkPossible(boolean instantDeepLinkPossible)voidhandleNewRequest(ServerRequest req)Handles execution of a new request other than open or install.Checks for the session initialisation and adds a install/Open request in front of this requestif the request need session to execute. voidnotifyNetworkAvailable()Notify Branch when network is available in order to process the next request in the queue. static booleanisAutoDeepLinkLaunch(Activity activity)Checks if an activity is launched by Branch auto deep link feature. static voidenableLogging()Enable Logging, independent of Debug Mode. static voiddisableLogging()Disable Logging, independent of Debug Mode. static voidenableForcedSession()static voidbypassWaitingForIntent(boolean bypassIntent)Use this method cautiously, it is meant to enable the ability to start a session beforethe user opens the app.The use case explained:Users are expected to initialize session from Activity.onStart. static voiddisableForcedSession()static booleanisForceSessionEnabled()Returns true if session initialization should bypass waiting for intent (retrieved after onResume). static booleanisWaitingForIntent()static voidenableBypassCurrentActivityIntentState()static booleanbypassCurrentActivityIntentState()voidregisterView(BranchUniversalObject branchUniversalObject, BranchUniversalObject.RegisterViewStatusListener callback)voidaddExtraInstrumentationData(HashMap<String, String> instrumentationData)Update the extra instrumentation data provided to Branch voidaddExtraInstrumentationData(String key, String value)Update the extra instrumentation data provided to Branch voidonBranchViewVisible(String action, String branchViewID)Called when a Branch view shown voidonBranchViewAccepted(String action, String branchViewID)Called when user click the positive button on Branch view voidonBranchViewCancelled(String action, String branchViewID)Called when user click the negative button app Branch view voidonBranchViewError(int errorCode, String errorMsg, String action)Called when there is an error on creating or showing Branch view static booleanisInstantApp(@NonNull() Context context)Checks if this is an Instant app instance static booleanshowInstallPrompt(@NonNull() Activity activity, int requestCode)Method shows play store install prompt for the full app. static booleanshowInstallPrompt(@NonNull() Activity activity, int requestCode, @Nullable() String referrer)Method shows play store install prompt for the full app. static booleanshowInstallPrompt(@NonNull() Activity activity, int requestCode, @NonNull() BranchUniversalObject buo)Method shows play store install prompt for the full app. static Branch.InitSessionBuildersessionBuilder(Activity activity)Create Branch session builder. static StringgetSdkVersionNumber()Method will return the current Branch SDK version number booleaninitSession(Branch.BranchUniversalReferralInitListener callback)booleaninitSession(Branch.BranchReferralInitListener callback)booleaninitSession(Branch.BranchUniversalReferralInitListener callback, Activity activity)booleaninitSession(Branch.BranchReferralInitListener callback, Activity activity)booleaninitSession(Branch.BranchUniversalReferralInitListener callback, Uri data)booleaninitSession(Branch.BranchReferralInitListener callback, Uri data)booleaninitSession(Branch.BranchUniversalReferralInitListener callback, Uri data, Activity activity)booleaninitSession(Branch.BranchReferralInitListener callback, Uri data, Activity activity)booleaninitSession()booleaninitSession(Activity activity)booleaninitSessionForced(Branch.BranchReferralInitListener callback)booleaninitSessionWithData(Uri data)booleaninitSessionWithData(Uri data, Activity activity)booleaninitSession(boolean isReferrable)booleaninitSession(boolean isReferrable, @NonNull() Activity activity)booleaninitSession(Branch.BranchUniversalReferralInitListener callback, boolean isReferrable, Uri data)booleaninitSession(Branch.BranchReferralInitListener callback, boolean isReferrable, Uri data)booleaninitSession(Branch.BranchUniversalReferralInitListener callback, boolean isReferrable, Uri data, Activity activity)booleaninitSession(Branch.BranchReferralInitListener callback, boolean isReferrable, Uri data, Activity activity)booleaninitSession(Branch.BranchUniversalReferralInitListener callback, boolean isReferrable)booleaninitSession(Branch.BranchReferralInitListener callback, boolean isReferrable)booleaninitSession(Branch.BranchUniversalReferralInitListener callback, boolean isReferrable, Activity activity)booleaninitSession(Branch.BranchReferralInitListener callback, boolean isReferrable, Activity activity)booleanreInitSession(Activity activity, Branch.BranchUniversalReferralInitListener callback)booleanreInitSession(Activity activity, Branch.BranchReferralInitListener callback)voidsetDebug()static voidenableDebugMode()static voiddisableDebugMode()static voidenableSimulateInstalls()static voiddisableSimulateInstalls()static BranchgetInstance(@NonNull() Context context)static BranchgetTestInstance(@NonNull() Context context)static BranchgetAutoInstance(@NonNull() Context context, boolean isReferrable)static BranchgetAutoTestInstance(@NonNull() Context context)static BranchgetInstance(@NonNull() Context context, @NonNull() String branchKey)static BranchgetAutoTestInstance(@NonNull() Context context, boolean isReferrable)-
-
Method Detail
-
isInstantDeepLinkPossible
boolean isInstantDeepLinkPossible()
-
getTrackingController
TrackingController getTrackingController()
-
getPluginVersion
static String getPluginVersion()
-
getInstance
static synchronized Branch getInstance()
-
getAutoInstance
static synchronized Branch getAutoInstance(@NonNull() Context context)
Singleton method to return the pre-initialised, or newly initialise and return, a singletonobject of the type Branch.
Use this whenever you need to call a method directly on the Branch object.
- Parameters:
context- A Context from which this call was made.
-
getAutoInstance
static Branch getAutoInstance(@NonNull() Context context, @NonNull() String branchKey)
-
getApplicationContext
Context getApplicationContext()
-
setBranchRemoteInterface
void setBranchRemoteInterface(BranchRemoteInterface remoteInterface)
Sets a custom Branch Remote interface for handling RESTful requests. Call this for implementing a custom network layer for handling communication betweenBranch SDK and remote Branch server
- Parameters:
remoteInterface- A instance of class extending BranchRemoteInterface withimplementation for abstract RESTful GET or POST methods, if nullis passed, the SDK will use its default.
-
getBranchRemoteInterface
BranchRemoteInterface getBranchRemoteInterface()
-
enableTestMode
static void enableTestMode()
Enables the test mode for the SDK. This will use the Branch Test Keys. This is same as setting"io.branch.sdk.TestMode" to "True" in Manifest file.Note: As of v5.0.1, enableTestMode has been changed. It now uses the test key but will not log or randomizethe device IDs. If you wish to enable logging, please invoke enableLogging. If you wish to simulateinstalls, please see add a Test Device (https://help.branch.io/using-branch/docs/adding-test-devices)then reset your test device's data (https://help.branch.io/using-branch/docs/adding-test-devices#section-resetting-your-test-device-data).
-
disableTestMode
static void disableTestMode()
Disables the test mode for the SDK.
-
disableAdNetworkCallouts
void disableAdNetworkCallouts(boolean disabled)
Disable (or re-enable) ad network callouts. This setting is persistent.
- Parameters:
disabled- (@link Boolean) whether ad network callouts should be disabled.
-
expectDelayedSessionInitialization
static void expectDelayedSessionInitialization(boolean expectDelayedInit)
Temporarily disables auto session initialization until user initializes themselves.Context: Branch expects session initialization to be started in LauncherActivity.onStart(),if session initialization has not been started/completed by the time ANY Activity resumes,Branch will auto-initialize. This allows Branch to keep an accurate count of all app sessions,including instances when app is launched from a recent apps list and the first visible Activityis not LauncherActivity.However, in certain scenarios users may need to delay session initialization (e.g. to asynchronouslyretrieve some data that needs to be passed to Branch prior to session initialization). In thosecases, use expectDelayedSessionInitialization() to temporarily disable auto self initialization.Once the user initializes the session themselves, the flag will be reset and auto session initializationwill be re-enabled.
- Parameters:
expectDelayedInit- A Boolean to set the expectation flag.
-
setAPIUrl
static void setAPIUrl(String url)
Sets a custom base URL for all calls to the Branch API. Requires https.
- Parameters:
url- The String URL base URL that the Branch API uses.
-
setCDNBaseUrl
static void setCDNBaseUrl(String url)
Sets a custom CDN base URL.
- Parameters:
url- The String base URL for CDN endpoints.
-
disableTracking
void disableTracking(boolean disableTracking)
Method to change the Tracking state. If disabled SDK will not track any user data or state. SDK will not send any network calls except for deep linking when tracking is disabled
-
isTrackingDisabled
boolean isTrackingDisabled()
Checks if tracking is disabled. See disableTracking
-
enablePlayStoreReferrer
static void enablePlayStoreReferrer(long delay)
-
setPlayStoreReferrerCheckTimeout
static void setPlayStoreReferrerCheckTimeout(long delay)
Set timeout for Play Store Referrer library. Play Store Referrer library allows Branch to providemore accurate tracking and attribution. This delays Branch initialization only the first time user opens the app.This method allows to override the maximum wait time for play store referrer to arrive.
- Parameters:
delay- Long Maximum wait time for install referrer broadcast in milli seconds.
-
disableInstantDeepLinking
static void disableInstantDeepLinking(boolean disableIDL)
Disables or enables the instant deep link functionality.
- Parameters:
disableIDL- Value{@code true}disables the instant deep linking.
-
resetUserSession
void resetUserSession()
Manually sets the Boolean value, that indicates that the Branch API connection hasbeen initialised, to false - forcing re-initialisation.
-
setRetryCount
void setRetryCount(int retryCount)
Sets the max number of times to re-attempt a timed-out request to the Branch API, beforeconsidering the request to have failed entirely. Default to 3. Note that the the networktimeout, as set in setNetworkTimeout, together with the retry interval value from setRetryInterval will determine if the max retry count will be attempted.
- Parameters:
retryCount- An Integer specifying the number of times to retry before givingup and declaring defeat.
-
setRetryInterval
void setRetryInterval(int retryInterval)
Sets the amount of time in milliseconds to wait before re-attempting a timed-out requestto the Branch API. Default 1000 ms.
- Parameters:
retryInterval- An Integer value specifying the number of milliseconds towait before re-attempting a timed-out request.
-
setNetworkTimeout
void setNetworkTimeout(int timeout)
Sets the duration in milliseconds that the system should wait for a response before timingout any Branch API. Default 5500 ms. Note that this is the total time allocated for all requestretries as set in setRetryCount.
- Parameters:
timeout- An Integer value specifying the number of milliseconds to wait beforeconsidering the request to have timed out.
-
setNetworkConnectTimeout
void setNetworkConnectTimeout(int connectTimeout)
Sets the duration in milliseconds that the system should wait for initializing a network* request.
- Parameters:
connectTimeout- An Integer value specifying the number of milliseconds to wait beforeconsidering the initialization to have timed out.
-
setNoConnectionRetryMax
void setNoConnectionRetryMax(int retryMax)
In cases of persistent no internet connection or offline modes,set a maximum number of attempts for the Branch Request to be tried.Must be greater than 0Defaults to 3
-
setReferrerGclidValidForWindow
void setReferrerGclidValidForWindow(long window)
Sets the window for the referrer GCLID field. The GCLID will be persisted locally from thetime it is set + window in milliseconds. Thereafter, it will be deleted.By default, the window is set to 30 days, or 2592000000L in millsecondsMinimum of 0 millisecondsMaximum of 3 years
- Parameters:
window- A Long value specifying the number of milliseconds to wait beforedeleting the locally persisted GCLID value.
-
disableDeviceIDFetch
static void disableDeviceIDFetch(Boolean deviceIdFetch)
Method to control reading Android ID from device. Set this to true to disable reading the device id.This method should be called from your onCreate method before creating Branch auto instance by calling getAutoInstance
- Parameters:
deviceIdFetch- with value true to disable reading the Android id from device
-
isDeviceIDFetchDisabled
static boolean isDeviceIDFetchDisabled()
Returns true if reading device id is disabled
-
setDeepLinkDebugMode
void setDeepLinkDebugMode(JSONObject debugParams)
Sets the key-value pairs for debugging the deep link. The key-value set in debug mode is given back with other deep link data on branch init session.This method should be called from onCreate() of activity which listens to Branch Init Session callbacks
- Parameters:
debugParams- A JSONObject containing key-value pairs for debugging branch deep linking
-
disableAppList
void disableAppList()
-
enableFacebookAppLinkCheck
void enableFacebookAppLinkCheck()
Enable Facebook app link check operation during Branch initialisation.
-
setLimitFacebookTracking
void setLimitFacebookTracking(boolean isLimitFacebookTracking)
Enables or disables app tracking with Branch or any other third parties that Branch use internally
- Parameters:
isLimitFacebookTracking-{@code true}to limit app tracking
-
setRequestMetadata
void setRequestMetadata(@NonNull() String key, @NonNull() String value)
Add key value pairs to all requests
-
addInstallMetadata
Branch addInstallMetadata(@NonNull() String key, @NonNull() String value)
This API allows to tag the install with custom attribute. Add any key-values that qualify or distinguish an install here.Please make sure this method is called before the Branch init, which is on the onStartMethod of first activity.A better place to call this method is right after Branch#getAutoInstance()
-
setPreinstallCampaign
Branch setPreinstallCampaign(@NonNull() String preInstallCampaign)
wrapper method to add the pre-install campaign analytics
-
setPreinstallPartner
Branch setPreinstallPartner(@NonNull() String preInstallPartner)
wrapper method to add the pre-install campaign analytics
-
setIsUserAgentSync
static void setIsUserAgentSync(boolean sync)
-
enableCookieBasedMatching
static void enableCookieBasedMatching(String cookieMatchDomain)
Enabled Strong matching check using chrome cookies. This method should be called beforeBranch#getAutoInstance(Context).
- Parameters:
cookieMatchDomain- The domain for the url used to match the cookie (eg.
-
enableCookieBasedMatching
static void enableCookieBasedMatching(String cookieMatchDomain, int delay)
Enabled Strong matching check using chrome cookies. This method should be called beforeBranch#getAutoInstance(Context).
- Parameters:
cookieMatchDomain- The domain for the url used to match the cookie (eg.delay- Time in millisecond to wait for the strong match to check to finish before Branch init session is called.Default time is 750 msec.
-
registerPlugin
static void registerPlugin(String name, String version)
-
onAdsParamsFetchFinished
void onAdsParamsFetchFinished()
-
onGoogleInstallReferrerEventsFinished
void onGoogleInstallReferrerEventsFinished()
-
onHuaweiInstallReferrerEventsFinished
void onHuaweiInstallReferrerEventsFinished()
-
onSamsungInstallReferrerEventsFinished
void onSamsungInstallReferrerEventsFinished()
-
onXiaomiInstallReferrerEventsFinished
void onXiaomiInstallReferrerEventsFinished()
-
addWhiteListedScheme
Branch addWhiteListedScheme(String urlWhiteListPattern)
Branch collect the URLs in the incoming intent for better attribution. Branch SDK extensively check for any sensitive data in the URL and skip if exist.However the following method provisions application to set SDK to collect only URLs in particular form. This method allow application to specify a set of regular expressions to white list the URL collection.If whitelist is not empty SDK will collect only the URLs that matches the white list.
This method should be called immediately after calling getAutoInstance
- Parameters:
urlWhiteListPattern- A regular expression with a URI white listing pattern
-
setWhiteListedSchemes
Branch setWhiteListedSchemes(List<String> urlWhiteListPatternList)
Branch collect the URLs in the incoming intent for better attribution. Branch SDK extensively check for any sensitive data in the URL and skip if exist.However the following method provisions application to set SDK to collect only URLs in particular form. This method allow application to specify a set of regular expressions to white list the URL collection.If whitelist is not empty SDK will collect only the URLs that matches the white list.
This method should be called immediately after calling getAutoInstance
- Parameters:
urlWhiteListPatternList- List of regular expressions with URI white listing pattern
-
addUriHostsToSkip
Branch addUriHostsToSkip(String urlSkipPattern)
Branch collect the URLs in the incoming intent for better attribution. Branch SDK extensively check for any sensitive data in the URL and skip if exist.This method allows applications specify SDK to skip any additional URL patterns to be skipped
This method should be called immediately after calling getAutoInstance
- Parameters:
urlSkipPattern- String A URL pattern that Branch SDK should skip from collecting data
-
setIdentity
void setIdentity(@NonNull() String userId)
Identifies the current user to the Branch API by supplying a unique identifier as a String value. No callback.
- Parameters:
userId- A String value containing the unique identifier of the user.
-
setIdentity
void setIdentity(@NonNull() String userId, @Nullable() Branch.BranchReferralInitListener callback)
Identifies the current user to the Branch API by supplying a unique identifier as a String value, with a callback specified to perform a defined action upon successfulresponse to request.
- Parameters:
userId- A String value containing the unique identifier of the user.callback- A BranchReferralInitListener callback instance that will returnthe data associated with the user id being assigned, if available.
-
getCrossPlatformIds
void getCrossPlatformIds(@NonNull() ServerRequestGetCPID.BranchCrossPlatformIdListener callback)
Gets all available cross platform ids.
- Parameters:
callback- An instance of io.branch.referral.ServerRequestGetCPID.BranchCrossPlatformIdListener to callback with cross platform ids
-
getLastAttributedTouchData
void getLastAttributedTouchData(@NonNull() ServerRequestGetLATD.BranchLastAttributedTouchDataListener callback)
Gets the available last attributed touch data. The attribution window is set to the value lastsaved via PreferenceHelper.setLATDAttributionWindow(). If no value has been saved, Branchdefaults to a 30 day attribution window (SDK sends -1 to request the default from the server).
- Parameters:
callback- An instance of io.branch.referral.ServerRequestGetLATD.BranchLastAttributedTouchDataListener to callback with last attributed touch data
-
getLastAttributedTouchData
void getLastAttributedTouchData(ServerRequestGetLATD.BranchLastAttributedTouchDataListener callback, int attributionWindow)
Gets the available last attributed touch data with a custom set attribution window.
- Parameters:
callback- An instance of io.branch.referral.ServerRequestGetLATD.BranchLastAttributedTouchDataListener to callback with last attributed touch dataattributionWindow- An to bound the the window of time in days during whichthe attribution data is considered valid.
-
isUserIdentified
boolean isUserIdentified()
Indicates whether or not this user has a custom identity specified for them. Note that this is independent of installs.If you call setIdentity, this device will have that identity associated with this user until logout is called.This includes persisting through uninstalls, as we track device id.
-
logout
void logout()
This method should be called if you know that a different person is about to use the app. For example,if you allow users to log out and let their friend use the app, you should call this to notify Branchto create a new user for this device. This will clear the first and latest params, as a new session is created.
-
logout
void logout(Branch.LogoutStatusListener callback)
This method should be called if you know that a different person is about to use the app. For example,if you allow users to log out and let their friend use the app, you should call this to notify Branchto create a new user for this device. This will clear the first and latest params, as a new session is created.
- Parameters:
callback- An instance of io.branch.referral.Branch.LogoutStatusListener to callback with the logout operation status.
-
loadRewards
@Deprecated() void loadRewards()
-
loadRewards
@Deprecated() void loadRewards(Branch.BranchReferralStateChangedListener callback)
-
getCredits
@Deprecated() int getCredits()
-
getCreditsForBucket
@Deprecated() int getCreditsForBucket(String bucket)
-
redeemRewards
@Deprecated() void redeemRewards(int count)
-
redeemRewards
@Deprecated() void redeemRewards(int count, Branch.BranchReferralStateChangedListener callback)
-
redeemRewards
@Deprecated() void redeemRewards(@NonNull() String bucket, int count)
-
redeemRewards
@Deprecated() void redeemRewards(@NonNull() String bucket, int count, Branch.BranchReferralStateChangedListener callback)
-
getCreditHistory
@Deprecated() void getCreditHistory(Branch.BranchListResponseListener callback)
-
getCreditHistory
@Deprecated() void getCreditHistory(@NonNull() String bucket, Branch.BranchListResponseListener callback)
-
getCreditHistory
@Deprecated() void getCreditHistory(@NonNull() String afterId, int length, @NonNull() Branch.CreditHistoryOrder order, Branch.BranchListResponseListener callback)
-
getCreditHistory
@Deprecated() void getCreditHistory(String bucket, String afterId, int length, @NonNull() Branch.CreditHistoryOrder order, Branch.BranchListResponseListener callback)
-
userCompletedAction
void userCompletedAction(@NonNull() String action, JSONObject metadata)
A void call to indicate that the user has performed a specific action and for that to bereported to the Branch API, with additional app-defined meta data to go along with that action.
- Parameters:
action- A String value to be passed as an action that the user has carriedout.metadata- A JSONObject containing app-defined meta-data to be attached to auser action that has just been completed.
-
userCompletedAction
void userCompletedAction(String action)
A void call to indicate that the user has performed a specific action and for that to bereported to the Branch API.
- Parameters:
action- A String value to be passed as an action that the user has carriedout.
-
userCompletedAction
void userCompletedAction(String action, BranchViewHandler.IBranchViewEvents callback)
A void call to indicate that the user has performed a specific action and for that to bereported to the Branch API.
- Parameters:
action- A String value to be passed as an action that the user has carriedout.callback- instance of BranchViewHandler.IBranchViewEvents to listen Branch view events
-
userCompletedAction
void userCompletedAction(@NonNull() String action, JSONObject metadata, BranchViewHandler.IBranchViewEvents callback)
A void call to indicate that the user has performed a specific action and for that to bereported to the Branch API, with additional app-defined meta data to go along with that action.
- Parameters:
action- A String value to be passed as an action that the user has carriedout.metadata- A JSONObject containing app-defined meta-data to be attached to auser action that has just been completed.callback- instance of BranchViewHandler.IBranchViewEvents to listen Branch view events
-
sendCommerceEvent
void sendCommerceEvent(@NonNull() CommerceEvent commerceEvent, JSONObject metadata, BranchViewHandler.IBranchViewEvents callback)
-
sendCommerceEvent
void sendCommerceEvent(@NonNull() CommerceEvent commerceEvent)
-
getFirstReferringParams
JSONObject getFirstReferringParams()
Returns the parameters associated with the link that referred the user. This is only set once,the first time the user is referred by a link. Think of this as the user referral parameters.It is also only set if isReferrable is equal to true, which by default is only trueon a fresh install (not upgrade or reinstall). This will change on setIdentity (if theuser already exists from a previous device) and logout.
-
removeSessionInitializationDelay
void removeSessionInitializationDelay()
-
getFirstReferringParamsSync
JSONObject getFirstReferringParamsSync()
This function must be called from a non-UI thread! If Branch has no install link data,and this func is called, it will return data upon initializing, or until LATCH_WAIT_UNTIL.Returns the parameters associated with the link that referred the user. This is only set once,the first time the user is referred by a link. Think of this as the user referral parameters.It is also only set if isReferrable is equal to true, which by default is only trueon a fresh install (not upgrade or reinstall). This will change on setIdentity (if theuser already exists from a previous device) and logout.
-
getLatestReferringParams
JSONObject getLatestReferringParams()
Returns the parameters associated with the link that referred the session. If a userclicks a link, and then opens the app, initSession will return the parameters of the linkand then set them in as the latest parameters to be retrieved by this method. By default,sessions persist for the duration of time that the app is in focus. For example, if youminimize the app, these parameters will be cleared when closeSession is called.
-
getLatestReferringParamsSync
JSONObject getLatestReferringParamsSync()
This function must be called from a non-UI thread! If Branch has not been initializedand this func is called, it will return data upon initialization, or until LATCH_WAIT_UNTIL.Returns the parameters associated with the link that referred the session. If a userclicks a link, and then opens the app, initSession will return the parameters of the linkand then set them in as the latest parameters to be retrieved by this method. By default,sessions persist for the duration of time that the app is in focus. For example, if youminimize the app, these parameters will be cleared when closeSession is called.
-
addFacebookPartnerParameterWithName
void addFacebookPartnerParameterWithName(@NonNull() String key, @NonNull() String value)
Add a Partner Parameter for Facebook.Once set, this parameter is attached to installs, opens and events until cleared or the app restarts.See Facebook's documentation for details on valid parameters
-
clearPartnerParameters
void clearPartnerParameters()
Clears all Partner Parameters
-
getDeeplinkDebugParams
JSONObject getDeeplinkDebugParams()
-
cancelShareLinkDialog
void cancelShareLinkDialog(boolean animateClose)
Cancel current share link operation and Application selector dialog. If your app is not using auto session management, make sure you arecalling this method before your activity finishes inorder to prevent any window leak.
- Parameters:
animateClose- A Boolean to specify whether to close the dialog with an animation.A value of true will close the dialog with an animation.
-
getDeviceInfo
DeviceInfo getDeviceInfo()
-
getBranchPluginSupport
BranchPluginSupport getBranchPluginSupport()
-
getBranchQRCodeCache
BranchQRCodeCache getBranchQRCodeCache()
-
setInstantDeepLinkPossible
void setInstantDeepLinkPossible(boolean instantDeepLinkPossible)
-
handleNewRequest
void handleNewRequest(ServerRequest req)
Handles execution of a new request other than open or install.Checks for the session initialisation and adds a install/Open request in front of this requestif the request need session to execute.
- Parameters:
req- The ServerRequest to execute
-
notifyNetworkAvailable
void notifyNetworkAvailable()
Notify Branch when network is available in order to process the next request in the queue.
-
isAutoDeepLinkLaunch
static boolean isAutoDeepLinkLaunch(Activity activity)
Checks if an activity is launched by Branch auto deep link feature. Branch launches activity configured for auto deep link on seeing matching keys.Keys for auto deep linking should be specified to each activity as a meta data in manifest.
Configure your activity in your manifest to enable auto deep linking as follows- Parameters:
activity- Instance of activity to check if launched on auto deep link.
-
enableLogging
static void enableLogging()
Enable Logging, independent of Debug Mode.
-
disableLogging
static void disableLogging()
Disable Logging, independent of Debug Mode.
-
enableForcedSession
@Deprecated() static void enableForcedSession()
-
bypassWaitingForIntent
static void bypassWaitingForIntent(boolean bypassIntent)
Use this method cautiously, it is meant to enable the ability to start a session beforethe user opens the app.The use case explained:Users are expected to initialize session from Activity.onStart. However, by default, Branch actuallywaits until Activity.onResume to start session initialization, so as to ensure that the latest intentdata is available (e.g. when activity is launched from stack via onNewIntent). Setting this flag to truewill bypass waiting for intent, so session could technically be initialized from a background serviceor otherwise before the application is even opened.Note however that if the flag is not reset during normal app boot up, the SDK behavior is undefinedin certain cases.
- Parameters:
bypassIntent- a Boolean indicating if SDK should wait for onResume in order to fire thesession initialization request.
-
disableForcedSession
@Deprecated() static void disableForcedSession()
-
isForceSessionEnabled
@Deprecated() static boolean isForceSessionEnabled()
Returns true if session initialization should bypass waiting for intent (retrieved after onResume).
-
isWaitingForIntent
static boolean isWaitingForIntent()
-
enableBypassCurrentActivityIntentState
static void enableBypassCurrentActivityIntentState()
-
bypassCurrentActivityIntentState
static boolean bypassCurrentActivityIntentState()
-
registerView
void registerView(BranchUniversalObject branchUniversalObject, BranchUniversalObject.RegisterViewStatusListener callback)
-
addExtraInstrumentationData
void addExtraInstrumentationData(HashMap<String, String> instrumentationData)
Update the extra instrumentation data provided to Branch
- Parameters:
instrumentationData- A HashMap with key value pairs for instrumentation data.
-
addExtraInstrumentationData
void addExtraInstrumentationData(String key, String value)
Update the extra instrumentation data provided to Branch
-
onBranchViewVisible
void onBranchViewVisible(String action, String branchViewID)
Called when a Branch view shown
- Parameters:
action- action name associated with the Branch view itembranchViewID- ID for the Branch view displayed
-
onBranchViewAccepted
void onBranchViewAccepted(String action, String branchViewID)
Called when user click the positive button on Branch view
- Parameters:
action- action name associated with the App Branch itembranchViewID- ID for the Branch view accepted
-
onBranchViewCancelled
void onBranchViewCancelled(String action, String branchViewID)
Called when user click the negative button app Branch view
- Parameters:
action- action name associated with the Branch viewbranchViewID- ID for the Branch view cancelled
-
onBranchViewError
void onBranchViewError(int errorCode, String errorMsg, String action)
Called when there is an error on creating or showing Branch view
-
isInstantApp
static boolean isInstantApp(@NonNull() Context context)
Checks if this is an Instant app instance
- Parameters:
context- Current Context
-
showInstallPrompt
static boolean showInstallPrompt(@NonNull() Activity activity, int requestCode)
Method shows play store install prompt for the full app. Thi passes the referrer to the installed application. The same deep link params as the instant app are provided to thefull app up on Branch#initSession()
- Parameters:
activity- Current activityrequestCode- Request code for the activity to receive the result
-
showInstallPrompt
static boolean showInstallPrompt(@NonNull() Activity activity, int requestCode, @Nullable() String referrer)
Method shows play store install prompt for the full app. Use this method only if you have custom parameters to pass to the full app using referrer else use showInstallPrompt
- Parameters:
activity- Current activityrequestCode- Request code for the activity to receive the resultreferrer- Any custom referrer string to pass to full app (must be of format "referrer_key1=referrer_value1%26referrer_key2=referrer_value2")
-
showInstallPrompt
static boolean showInstallPrompt(@NonNull() Activity activity, int requestCode, @NonNull() BranchUniversalObject buo)
Method shows play store install prompt for the full app. Use this method only if you want the full app to receive a custom BranchUniversalObject to do deferred deep link.Please see showInstallPrompt NOTE :This method will do a synchronous generation of Branch short link for the BUO. So please consider calling this method on non UI threadPlease make sure your instant app and full ap are using same Branch key in order for the deferred deep link working
- Parameters:
activity- Current activityrequestCode- Request code for the activity to receive the resultbuo- BranchUniversalObject to pass to the full app up on install
-
sessionBuilder
static Branch.InitSessionBuilder sessionBuilder(Activity activity)
Create Branch session builder. Add configuration variables with the available methodsin the returned InitSessionBuilder class. Must be finished with init() or reInit(),otherwise takes no effect.
- Parameters:
activity- The calling Activity for context.
-
getSdkVersionNumber
static String getSdkVersionNumber()
Method will return the current Branch SDK version number
-
initSession
boolean initSession(Branch.BranchUniversalReferralInitListener callback)
-
initSession
boolean initSession(Branch.BranchReferralInitListener callback)
-
initSession
boolean initSession(Branch.BranchUniversalReferralInitListener callback, Activity activity)
-
initSession
boolean initSession(Branch.BranchReferralInitListener callback, Activity activity)
-
initSession
boolean initSession(Branch.BranchUniversalReferralInitListener callback, Uri data)
-
initSession
boolean initSession(Branch.BranchReferralInitListener callback, Uri data)
-
initSession
boolean initSession(Branch.BranchUniversalReferralInitListener callback, Uri data, Activity activity)
-
initSession
boolean initSession(Branch.BranchReferralInitListener callback, Uri data, Activity activity)
-
initSession
boolean initSession()
-
initSession
boolean initSession(Activity activity)
-
initSessionForced
boolean initSessionForced(Branch.BranchReferralInitListener callback)
-
initSessionWithData
boolean initSessionWithData(Uri data)
-
initSessionWithData
boolean initSessionWithData(Uri data, Activity activity)
-
initSession
boolean initSession(boolean isReferrable)
-
initSession
boolean initSession(boolean isReferrable, @NonNull() Activity activity)
-
initSession
boolean initSession(Branch.BranchUniversalReferralInitListener callback, boolean isReferrable, Uri data)
-
initSession
boolean initSession(Branch.BranchReferralInitListener callback, boolean isReferrable, Uri data)
-
initSession
boolean initSession(Branch.BranchUniversalReferralInitListener callback, boolean isReferrable, Uri data, Activity activity)
-
initSession
boolean initSession(Branch.BranchReferralInitListener callback, boolean isReferrable, Uri data, Activity activity)
-
initSession
boolean initSession(Branch.BranchUniversalReferralInitListener callback, boolean isReferrable)
-
initSession
boolean initSession(Branch.BranchReferralInitListener callback, boolean isReferrable)
-
initSession
boolean initSession(Branch.BranchUniversalReferralInitListener callback, boolean isReferrable, Activity activity)
-
initSession
boolean initSession(Branch.BranchReferralInitListener callback, boolean isReferrable, Activity activity)
-
reInitSession
boolean reInitSession(Activity activity, Branch.BranchUniversalReferralInitListener callback)
-
reInitSession
boolean reInitSession(Activity activity, Branch.BranchReferralInitListener callback)
-
setDebug
void setDebug()
-
enableDebugMode
static void enableDebugMode()
-
disableDebugMode
static void disableDebugMode()
-
enableSimulateInstalls
static void enableSimulateInstalls()
-
disableSimulateInstalls
static void disableSimulateInstalls()
-
getInstance
static Branch getInstance(@NonNull() Context context)
-
getTestInstance
static Branch getTestInstance(@NonNull() Context context)
-
getAutoInstance
static Branch getAutoInstance(@NonNull() Context context, boolean isReferrable)
-
getAutoTestInstance
static Branch getAutoTestInstance(@NonNull() Context context)
-
getAutoTestInstance
static Branch getAutoTestInstance(@NonNull() Context context, boolean isReferrable)
-
-
-
-