public class Branch extends java.lang.Object implements BranchViewHandler.IBranchViewEvents
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:
Modifier and Type | Class and Description |
---|---|
static interface |
Branch.BranchLinkCreateListener
An Interface class that is implemented by all classes that make use of
Branch.BranchLinkCreateListener , defining a single method that takes a URL
String format, and an error message of BranchError format that will be
returned on failure of the request response. |
static interface |
Branch.BranchLinkShareListener
An Interface class that is implemented by all classes that make use of
Branch.BranchLinkShareListener , defining methods to listen for link sharing status. |
static interface |
Branch.BranchListResponseListener
An Interface class that is implemented by all classes that make use of
Branch.BranchListResponseListener , defining a single method that takes a list of
JSONArray format, and an error message of BranchError format that will be
returned on failure of the request response. |
static interface |
Branch.BranchReferralInitListener
An Interface class that is implemented by all classes that make use of
Branch.BranchReferralInitListener , defining a single method that takes a list of params in
JSONObject format, and an error message of BranchError format that will be
returned on failure of the request response. |
static interface |
Branch.BranchReferralStateChangedListener
An Interface class that is implemented by all classes that make use of
Branch.BranchReferralStateChangedListener , defining a single method that takes a value of
Boolean format, and an error message of BranchError format that will be
returned on failure of the request response. |
static interface |
Branch.BranchUniversalReferralInitListener
An Interface class that is implemented by all classes that make use of
Branch.BranchUniversalReferralInitListener , defining a single method that provides
BranchUniversalObject , LinkProperties and an error message of BranchError format that will be
returned on failure of the request response. |
static class |
Branch.CreditHistoryOrder
enum containing the sort options for return of credit history.
|
static interface |
Branch.ExtendedBranchLinkShareListener
An extended version of
Branch.BranchLinkShareListener with callback that supports updating link data or properties after user select a channel to share
This will provide the extended callback Branch.ExtendedBranchLinkShareListener.onChannelSelected(String, BranchUniversalObject, LinkProperties) only when sharing a link using Branch Universal Object. |
static interface |
Branch.IBranchViewControl
Interface for defining optional Branch view behaviour for Activities
|
static interface |
Branch.IChannelProperties
An interface class for customizing sharing properties with selected channel.
|
static interface |
Branch.LogoutStatusListener
Callback interface for listening logout status
|
static class |
Branch.ShareLinkBuilder
Class for building a share link dialog.This creates a chooser for selecting application for
sharing a link created with given parameters.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ALWAYS_DEEPLINK
String value indicating whether the link should always initiate a deep link action. |
static java.lang.String |
DEEPLINK_PATH
String value denoting the deep link path to override Branch's default one. |
static java.lang.String |
FEATURE_TAG_DEAL
Hard-coded
String that denotes a link that is part of a commercial 'deal' or offer. |
static java.lang.String |
FEATURE_TAG_GIFT
Hard-coded
String that denotes a link tagged as a gift action within a service or
product. |
static java.lang.String |
FEATURE_TAG_INVITE
Hard-coded
String that denotes a 'referral' tag; applies to links that are sent as
referral actions by users of an app using an 'invite contacts' feature for instance. |
static java.lang.String |
FEATURE_TAG_REFERRAL
Hard-coded
String that denotes a 'referral' tag; applies to links that are associated
with a referral program, incentivized or not. |
static java.lang.String |
FEATURE_TAG_SHARE
Hard-coded
String that denotes a BranchLinkData.tags ; applies to links that
are shared with others directly as a user action, via social media for instance. |
static int |
LINK_TYPE_ONE_TIME_USE
An
Integer value indicating the link type. |
static int |
LINK_TYPE_UNLIMITED_USE
An
Integer value indicating the link type. |
static long |
NO_PLAY_STORE_REFERRER_WAIT |
static java.lang.String |
OG_APP_ID
Unique identifier for the app in use.
|
static java.lang.String |
OG_DESC
The description of the object to appear in social media feeds that use
Facebook's Open Graph specification.
|
static java.lang.String |
OG_IMAGE_URL
An image URL which should represent your object to appear in social media feeds that use
Facebook's Open Graph specification.
|
static java.lang.String |
OG_TITLE
Open Graph: The title of your object as it should appear within the graph, e.g., "The Rock".
|
static java.lang.String |
OG_URL
The canonical URL of your object that will be used as its permanent ID in the graph.
|
static java.lang.String |
OG_VIDEO
A URL to a video file that complements this object.
|
static java.lang.String |
REDEEM_CODE
The code to be passed as part of a deal or gift; retrieved from the Branch object as a
tag upon initialisation.
|
static java.lang.String |
REDIRECT_ANDROID_URL
The redirect URL provided when the link is handled by an Android device.
|
static java.lang.String |
REDIRECT_BLACKBERRY_URL
The redirect URL provided when the link is handled by a Blackberry device.
|
static java.lang.String |
REDIRECT_DESKTOP_URL
The redirect URL provided when the link is handled by a desktop client.
|
static java.lang.String |
REDIRECT_FIRE_URL
The redirect URL provided when the link is handled by an Amazon Fire device.
|
static java.lang.String |
REDIRECT_IOS_URL
The redirect URL provided when the link is handled by an iOS device.
|
static java.lang.String |
REDIRECT_IPAD_URL
The redirect URL provided when the link is handled by a large form-factor iOS device such as
an iPad.
|
static java.lang.String |
REDIRECT_WINDOWS_PHONE_URL
The redirect URL provided when the link is handled by a Windows Phone device.
|
static java.lang.String |
REFERRAL_BUCKET_DEFAULT
Default value of referral bucket; referral buckets contain credits that are used when users
are referred to your apps.
|
static java.lang.String |
REFERRAL_CODE
Key value for referral code as a parameter.
|
static int |
REFERRAL_CODE_AWARD_UNIQUE
An
Integer value indicating the calculation type of the referral code. |
static int |
REFERRAL_CODE_AWARD_UNLIMITED
An
Integer value indicating the calculation type of the referral code. |
static int |
REFERRAL_CODE_LOCATION_BOTH
An
Integer value indicating the user to reward for applying a referral code. |
static int |
REFERRAL_CODE_LOCATION_REFERREE
An
Integer value indicating the user to reward for applying a referral code. |
static int |
REFERRAL_CODE_LOCATION_REFERRING_USER
An
Integer value indicating the user to reward for applying a referral code. |
static java.lang.String |
REFERRAL_CODE_TYPE
Hard-coded value for referral code type.
|
static int |
REFERRAL_CREATION_SOURCE_SDK
Branch SDK version for the current release of the Branch SDK.
|
Modifier and Type | Method and Description |
---|---|
void |
addExtraInstrumentationData(java.util.HashMap<java.lang.String,java.lang.String> instrumentationData)
Update the extra instrumentation data provided to Branch
|
void |
addExtraInstrumentationData(java.lang.String key,
java.lang.String value)
Update the extra instrumentation data provided to Branch
|
Branch |
addInstallMetadata(java.lang.String key,
java.lang.String value)
This API allows to tag the install with custom attribute.
|
Branch |
addUriHostsToSkip(java.lang.String urlSkipPattern)
Branch collect the URLs in the incoming intent for better attribution.
|
Branch |
addWhiteListedScheme(java.lang.String urlWhiteListPattern)
Branch collect the URLs in the incoming intent for better attribution.
|
void |
cancelShareLinkDialog(boolean animateClose)
Cancel current share link operation and Application selector dialog.
|
void |
closeSession()
Deprecated.
This method is deprecated from SDK v1.14.6. Session Start and close are automatically handled by Branch.
In case you need to handle sessions manually inorder to support minimum sdk version less than 14 please consider using
SDK version 1.14.5
|
void |
disableAppList()
Deprecated.
Branch is not listing external apps any more from v2.11.0
|
static void |
disableDeviceIDFetch(java.lang.Boolean deviceIdFetch)
Method to control reading Android ID from device.
|
static void |
disableForcedSession() |
static void |
disableInstantDeepLinking(boolean disableIDL)
Disables or enables the instant deep link functionality.
|
static void |
disableLogging() |
static void |
disableSimulateInstalls() |
static void |
disableTestMode() |
void |
disableTracking(boolean disableTracking)
Method to change the Tracking state.
|
static void |
enableBypassCurrentActivityIntentState() |
static void |
enableCookieBasedMatching(java.lang.String cookieMatchDomain)
Enabled Strong matching check using chrome cookies.
|
static void |
enableCookieBasedMatching(java.lang.String cookieMatchDomain,
int delay)
Enabled Strong matching check using chrome cookies.
|
void |
enableFacebookAppLinkCheck()
Enable Facebook app link check operation during Branch initialisation.
|
static void |
enableForcedSession() |
static void |
enableLogging() |
static void |
enablePlayStoreReferrer(long delay)
Deprecated.
This method is deprecated since play store referrer is enabled by default from v2.9.1.
Please use
setPlayStoreReferrerCheckTimeout(long) instead. |
static void |
enableSimulateInstalls() |
static void |
enableTestMode()
Enables/Disables the test mode for the SDK.
|
android.content.Context |
getApplicationContext() |
static Branch |
getAutoInstance(android.content.Context context)
Singleton method to return the pre-initialised, or newly initialise and return, a singleton
object of the type
Branch . |
static Branch |
getAutoInstance(android.content.Context context,
boolean isReferrable)
Singleton method to return the pre-initialised, or newly initialise and return, a singleton
object of the type
Branch . |
static Branch |
getAutoInstance(android.content.Context context,
java.lang.String branchKey)
Singleton method to return the pre-initialised, or newly initialise and return, a singleton
object of the type
Branch . |
static Branch |
getAutoTestInstance(android.content.Context context)
If you configured the your Strings file according to the guide, you'll be able to use
the test version of your app by just calling this static method before calling initSession.
|
static Branch |
getAutoTestInstance(android.content.Context context,
boolean isReferrable)
If you configured the your Strings file according to the guide, you'll be able to use
the test version of your app by just calling this static method before calling initSession.
|
void |
getCreditHistory(Branch.BranchListResponseListener callback)
Gets the credit history of the specified bucket and triggers a callback to handle the
response.
|
void |
getCreditHistory(java.lang.String bucket,
Branch.BranchListResponseListener callback)
Gets the credit history of the specified bucket and triggers a callback to handle the
response.
|
void |
getCreditHistory(java.lang.String afterId,
int length,
Branch.CreditHistoryOrder order,
Branch.BranchListResponseListener callback)
Gets the credit history of the specified bucket and triggers a callback to handle the
response.
|
void |
getCreditHistory(java.lang.String bucket,
java.lang.String afterId,
int length,
Branch.CreditHistoryOrder order,
Branch.BranchListResponseListener callback)
Gets the credit history of the specified bucket and triggers a callback to handle the
response.
|
int |
getCredits()
Retrieve the number of credits available for the "default" bucket.
|
int |
getCreditsForBucket(java.lang.String bucket)
Returns an
Integer of the number of credits available for use within the supplied
bucket name. |
org.json.JSONObject |
getDeeplinkDebugParams() |
org.json.JSONObject |
getFirstReferringParams()
Returns the parameters associated with the link that referred the user.
|
org.json.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.
|
static Branch |
getInstance()
Singleton method to return the pre-initialised object of the type
Branch . |
static Branch |
getInstance(android.content.Context context)
Singleton method to return the pre-initialised, or newly initialise and return, a singleton
object of the type
Branch . |
static Branch |
getInstance(android.content.Context context,
java.lang.String branchKey)
Singleton method to return the pre-initialised, or newly initialise and return, a singleton
object of the type
Branch . |
org.json.JSONObject |
getLatestReferringParams()
Returns the parameters associated with the link that referred the session.
|
org.json.JSONObject |
getLatestReferringParamsSync()
This function must be called from a non-UI thread! If Branch has not been initialized
and this func is called, it will return data upon initialization, or until LATCH_WAIT_UNTIL.
|
static Branch |
getTestInstance(android.content.Context context)
If you configured the your Strings file according to the guide, you'll be able to use
the test version of your app by just calling this static method before calling initSession.
|
void |
handleNewRequest(ServerRequest req)
Handles execution of a new request other than open or install.
|
boolean |
initSession()
Initialises a session with the Branch API, without a callback or
Activity . |
boolean |
initSession(android.app.Activity activity)
Initialises a session with the Branch API, without a callback or
Activity . |
boolean |
initSession(boolean isReferrable)
Initialises a session with the Branch API, specifying whether the initialisation can count
as a referrable action.
|
boolean |
initSession(boolean isReferrable,
android.app.Activity activity)
Initialises a session with the Branch API, specifying whether the initialisation can count
as a referrable action, and supplying the calling
Activity for context. |
boolean |
initSession(Branch.BranchReferralInitListener callback)
Initialises a session with the Branch API, assigning a
Branch.BranchReferralInitListener
to perform an action upon successful initialisation. |
boolean |
initSession(Branch.BranchReferralInitListener callback,
android.app.Activity activity)
Initialises a session with the Branch API, passing the
Activity and assigning a
Branch.BranchReferralInitListener to perform an action upon successful initialisation. |
boolean |
initSession(Branch.BranchReferralInitListener callback,
boolean isReferrable)
Initialises a session with the Branch API.
|
boolean |
initSession(Branch.BranchReferralInitListener callback,
boolean isReferrable,
android.app.Activity activity)
Initialises a session with the Branch API.
|
boolean |
initSession(Branch.BranchReferralInitListener callback,
boolean isReferrable,
android.net.Uri data)
Initialises a session with the Branch API.
|
boolean |
initSession(Branch.BranchReferralInitListener callback,
boolean isReferrable,
android.net.Uri data,
android.app.Activity activity)
Initialises a session with the Branch API.
|
boolean |
initSession(Branch.BranchReferralInitListener callback,
android.net.Uri data)
Initialises a session with the Branch API.
|
boolean |
initSession(Branch.BranchReferralInitListener callback,
android.net.Uri data,
android.app.Activity activity)
Initialises a session with the Branch API.
|
boolean |
initSession(Branch.BranchUniversalReferralInitListener callback)
Initialises a session with the Branch API, assigning a
Branch.BranchUniversalReferralInitListener
to perform an action upon successful initialisation. |
boolean |
initSession(Branch.BranchUniversalReferralInitListener callback,
android.app.Activity activity)
Initialises a session with the Branch API, passing the
Activity and assigning a
Branch.BranchUniversalReferralInitListener to perform an action upon successful initialisation. |
boolean |
initSession(Branch.BranchUniversalReferralInitListener callback,
boolean isReferrable)
Initialises a session with the Branch API.
|
boolean |
initSession(Branch.BranchUniversalReferralInitListener callback,
boolean isReferrable,
android.app.Activity activity)
Initialises a session with the Branch API.
|
boolean |
initSession(Branch.BranchUniversalReferralInitListener callback,
boolean isReferrable,
android.net.Uri data)
Initialises a session with the Branch API.
|
boolean |
initSession(Branch.BranchUniversalReferralInitListener callback,
boolean isReferrable,
android.net.Uri data,
android.app.Activity activity)
Initialises a session with the Branch API.
|
boolean |
initSession(Branch.BranchUniversalReferralInitListener callback,
android.net.Uri data)
Initialises a session with the Branch API.
|
boolean |
initSession(Branch.BranchUniversalReferralInitListener callback,
android.net.Uri data,
android.app.Activity activity)
Initialises a session with the Branch API.
|
boolean |
initSessionForced(Branch.BranchReferralInitListener callback)
Force initialises a session with the Branch API, assigning a
Branch.BranchReferralInitListener
to perform an action upon successful initialisation. |
boolean |
initSessionWithData(android.net.Uri data)
Initialises a session with the Branch API, with associated data from the supplied
Uri . |
boolean |
initSessionWithData(android.net.Uri data,
android.app.Activity activity)
Initialises a session with the Branch API, with associated data from the supplied
Uri . |
static boolean |
isAutoDeepLinkLaunch(android.app.Activity activity)
Checks if an activity is launched by Branch auto deep link feature.
|
static boolean |
isDeviceIDFetchDisabled()
Returns true if reading device id is disabled
|
static boolean |
isForceSessionEnabled()
Returns true if forced session is enabled
|
static boolean |
isInstantApp(android.content.Context context)
Checks if this is an Instant app instance
|
boolean |
isTrackingDisabled()
Checks if tracking is disabled.
|
boolean |
isUserIdentified()
Indicates whether or not this user has a custom identity specified for them.
|
void |
loadRewards()
Fire-and-forget retrieval of rewards for the current session.
|
void |
loadRewards(Branch.BranchReferralStateChangedListener callback)
Retrieves rewards for the current session, with a callback to perform a predefined
action following successful report of state change.
|
void |
logout()
This method should be called if you know that a different person is about to use the app.
|
void |
logout(Branch.LogoutStatusListener callback)
This method should be called if you know that a different person is about to use the app.
|
void |
notifyNetworkAvailable()
Notify Branch when network is available in order to process the next request in the queue.
|
void |
onBranchViewAccepted(java.lang.String action,
java.lang.String branchViewID)
Called when user click the positive button on Branch view
|
void |
onBranchViewCancelled(java.lang.String action,
java.lang.String branchViewID)
Called when user click the negative button app Branch view
|
void |
onBranchViewError(int errorCode,
java.lang.String errorMsg,
java.lang.String action)
Called when there is an error on creating or showing Branch view
|
void |
onBranchViewVisible(java.lang.String action,
java.lang.String branchViewID)
Called when a Branch view shown
|
void |
onGAdsFetchFinished() |
void |
onInstallReferrerEventsFinished() |
void |
redeemRewards(int count)
Redeems the specified number of credits from the "default" bucket, if there are sufficient
credits within it.
|
void |
redeemRewards(int count,
Branch.BranchReferralStateChangedListener callback)
Redeems the specified number of credits from the "default" bucket, if there are sufficient
credits within it.
|
void |
redeemRewards(java.lang.String bucket,
int count)
Redeems the specified number of credits from the named bucket, if there are sufficient
credits within it.
|
void |
redeemRewards(java.lang.String bucket,
int count,
Branch.BranchReferralStateChangedListener callback)
Redeems the specified number of credits from the named bucket, if there are sufficient
credits within it.
|
void |
registerView(BranchUniversalObject branchUniversalObject,
BranchUniversalObject.RegisterViewStatusListener callback) |
void |
resetUserSession()
Manually sets the
Boolean value, that indicates that the Branch API connection has
been initialised, to false - forcing re-initialisation. |
void |
sendCommerceEvent(CommerceEvent commerceEvent) |
void |
sendCommerceEvent(CommerceEvent commerceEvent,
org.json.JSONObject metadata,
BranchViewHandler.IBranchViewEvents callback) |
void |
setBranchRemoteInterface(BranchRemoteInterface remoteInterface)
Sets a custom Branch Remote interface for handling RESTful requests.
|
void |
setDebug() |
void |
setDeepLinkDebugMode(org.json.JSONObject debugParams)
Sets the key-value pairs for debugging the deep link.
|
void |
setIdentity(java.lang.String userId)
Identifies the current user to the Branch API by supplying a unique identifier as a
String value. |
void |
setIdentity(java.lang.String userId,
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 successful
response to request. |
void |
setLimitFacebookTracking(boolean isLimitFacebookTracking)
Enables or disables app tracking with Branch or any other third parties that Branch use internally
|
void |
setNetworkTimeout(int timeout)
Sets the duration in milliseconds that the system should wait for a response before considering
any Branch API call to have timed out.
|
static void |
setPlayStoreReferrerCheckTimeout(long delay)
Since play store referrer broadcast from google play is few millisecond delayed Branch will delay the collecting deep link data on app install by
playStoreReferrerFetchTime millisecond
This will allow branch to provide for more accurate tracking and attribution. |
void |
setRequestMetadata(java.lang.String key,
java.lang.String value)
Add key value pairs to all requests
|
void |
setRetryCount(int retryCount)
Sets the number of times to re-attempt a timed-out request to the Branch API, before
considering the request to have failed entirely.
|
void |
setRetryInterval(int retryInterval)
Sets the amount of time in milliseconds to wait before re-attempting a timed-out request
to the Branch API.
|
Branch |
setWhiteListedSchemes(java.util.List<java.lang.String> urlWhiteListPatternList)
Branch collect the URLs in the incoming intent for better attribution.
|
static boolean |
showInstallPrompt(android.app.Activity activity,
int requestCode)
Method shows play store install prompt for the full app.
|
static boolean |
showInstallPrompt(android.app.Activity activity,
int requestCode,
BranchUniversalObject buo)
Method shows play store install prompt for the full app.
|
static boolean |
showInstallPrompt(android.app.Activity activity,
int requestCode,
java.lang.String referrer)
Method shows play store install prompt for the full app.
|
void |
userCompletedAction(java.lang.String action)
A void call to indicate that the user has performed a specific action and for that to be
reported to the Branch API.
|
void |
userCompletedAction(java.lang.String action,
BranchViewHandler.IBranchViewEvents callback)
A void call to indicate that the user has performed a specific action and for that to be
reported to the Branch API.
|
void |
userCompletedAction(java.lang.String action,
org.json.JSONObject metadata)
A void call to indicate that the user has performed a specific action and for that to be
reported to the Branch API, with additional app-defined meta data to go along with that action.
|
void |
userCompletedAction(java.lang.String action,
org.json.JSONObject metadata,
BranchViewHandler.IBranchViewEvents callback)
A void call to indicate that the user has performed a specific action and for that to be
reported to the Branch API, with additional app-defined meta data to go along with that action.
|
public static final java.lang.String FEATURE_TAG_SHARE
String
that denotes a BranchLinkData.tags
; applies to links that
are shared with others directly as a user action, via social media for instance.public static final java.lang.String FEATURE_TAG_REFERRAL
String
that denotes a 'referral' tag; applies to links that are associated
with a referral program, incentivized or not.public static final java.lang.String FEATURE_TAG_INVITE
String
that denotes a 'referral' tag; applies to links that are sent as
referral actions by users of an app using an 'invite contacts' feature for instance.public static final java.lang.String FEATURE_TAG_DEAL
String
that denotes a link that is part of a commercial 'deal' or offer.public static final java.lang.String FEATURE_TAG_GIFT
String
that denotes a link tagged as a gift action within a service or
product.public static final java.lang.String REDEEM_CODE
String
format.public static final java.lang.String REFERRAL_BUCKET_DEFAULT
Default value of referral bucket; referral buckets contain credits that are used when users are referred to your apps. These can be viewed in the Branch dashboard under Referrals.
public static final java.lang.String REFERRAL_CODE_TYPE
Hard-coded value for referral code type. Referral codes will always result on "credit" actions. Even if they are of 0 value.
public static final int REFERRAL_CREATION_SOURCE_SDK
public static final java.lang.String REFERRAL_CODE
public static final java.lang.String REDIRECT_DESKTOP_URL
public static final java.lang.String REDIRECT_ANDROID_URL
public static final java.lang.String REDIRECT_IOS_URL
public static final java.lang.String REDIRECT_IPAD_URL
public static final java.lang.String REDIRECT_FIRE_URL
public static final java.lang.String REDIRECT_BLACKBERRY_URL
public static final java.lang.String REDIRECT_WINDOWS_PHONE_URL
public static final java.lang.String OG_TITLE
public static final java.lang.String OG_DESC
public static final java.lang.String OG_IMAGE_URL
public static final java.lang.String OG_VIDEO
public static final java.lang.String OG_URL
public static final java.lang.String OG_APP_ID
public static final java.lang.String DEEPLINK_PATH
String
value denoting the deep link path to override Branch's default one. By
default, Branch will use yourapp://open?link_click_id=12345. If you specify this key/value,
Branch will use yourapp://'$deeplink_path'?link_click_id=12345public static final java.lang.String ALWAYS_DEEPLINK
String
value indicating whether the link should always initiate a deep link action.
By default, unless overridden on the dashboard, Branch will only open the app if they are
100% sure the app is installed. This setting will cause the link to always open the app.
Possible values are "true" or "false"public static final int REFERRAL_CODE_LOCATION_REFERREE
Integer
value indicating the user to reward for applying a referral code. In this
case, the user applying the referral code receives credit.public static final int REFERRAL_CODE_LOCATION_REFERRING_USER
Integer
value indicating the user to reward for applying a referral code. In this
case, the user who created the referral code receives credit.public static final int REFERRAL_CODE_LOCATION_BOTH
Integer
value indicating the user to reward for applying a referral code. In this
case, both the creator and applicant receive creditpublic static final int REFERRAL_CODE_AWARD_UNLIMITED
Integer
value indicating the calculation type of the referral code. In this case,
the referral code can be applied continually.public static final int REFERRAL_CODE_AWARD_UNIQUE
Integer
value indicating the calculation type of the referral code. In this case,
a user can only apply a specific referral code once.public static final int LINK_TYPE_UNLIMITED_USE
Integer
value indicating the link type. In this case, the link can be used an
unlimited number of times.public static final int LINK_TYPE_ONE_TIME_USE
Integer
value indicating the link type. In this case, the link can be used only
once. After initial use, subsequent attempts will not validate.public static final long NO_PLAY_STORE_REFERRER_WAIT
public android.content.Context getApplicationContext()
public void setBranchRemoteInterface(BranchRemoteInterface remoteInterface)
remoteInterface
- A instance of class extending BranchRemoteInterface
with implementation for abstract RESTful GET or POST methodspublic static void enableTestMode()
Enables/Disables the test mode for the SDK. This will use the Branch Test Keys. This will also enable debug logs. Note: This is same as setting "io.branch.sdk.TestMode" to "True" in Manifest file
public static void disableTestMode()
public void setDebug()
public void disableTracking(boolean disableTracking)
public boolean isTrackingDisabled()
disableTracking(boolean)
true
if tracking is disabledpublic static void enablePlayStoreReferrer(long delay)
setPlayStoreReferrerCheckTimeout(long)
instead.public static void setPlayStoreReferrerCheckTimeout(long delay)
playStoreReferrerFetchTime
millisecond
This will allow branch to provide for more accurate tracking and attribution. This will delay branch init only the first time user open the app.
This method allows to override the maximum wait time for play store referrer to arrive. Set it to NO_PLAY_STORE_REFERRER_WAIT
if you don't want to wait for play store referrer
Note: as of our testing 4/2017 a 1500 milli sec wait time is enough to capture more than 90% of the install referrer case
delay
- Long
Maximum wait time for install referrer broadcast in milli seconds. Set to NO_PLAY_STORE_REFERRER_WAIT
if you don't want to wait for play store referrerpublic static void disableInstantDeepLinking(boolean disableIDL)
Disables or enables the instant deep link functionality.
disableIDL
- Value true
disables the instant deep linking. Value false
enables the instant deep linking.public static Branch getInstance()
Singleton method to return the pre-initialised object of the type Branch
.
Make sure your app is instantiating BranchApp
before calling this method
or you have created an instance of Branch already by calling getInstance(Context ctx).
Branch
objectpublic static Branch getInstance(android.content.Context context, java.lang.String branchKey)
Singleton method to return the pre-initialised, or newly initialise and return, a singleton
object of the type Branch
.
context
- A Context
from which this call was made.branchKey
- Your Branch key as a String
.Branch
object, either fetched from a pre-initialised
instance within the singleton class, or a newly instantiated object where
one was not already requested during the current app lifecycle.public static Branch getInstance(android.content.Context context)
Singleton method to return the pre-initialised, or newly initialise and return, a singleton
object of the type Branch
.
Use this whenever you need to call a method directly on the Branch
object.
context
- A Context
from which this call was made.Branch
object, either fetched from a pre-initialised
instance within the singleton class, or a newly instantiated object where
one was not already requested during the current app lifecycle.public static Branch getTestInstance(android.content.Context context)
If you configured the your Strings file according to the guide, you'll be able to use the test version of your app by just calling this static method before calling initSession.
context
- A Context
from which this call was made.Branch
object.public static Branch getAutoInstance(android.content.Context context)
Singleton method to return the pre-initialised, or newly initialise and return, a singleton
object of the type Branch
.
Use this whenever you need to call a method directly on the Branch
object.
context
- A Context
from which this call was made.Branch
object, either fetched from a pre-initialised
instance within the singleton class, or a newly instantiated object where
one was not already requested during the current app lifecycle.public static Branch getAutoInstance(android.content.Context context, boolean isReferrable)
Singleton method to return the pre-initialised, or newly initialise and return, a singleton
object of the type Branch
.
Use this whenever you need to call a method directly on the Branch
object.
context
- A Context
from which this call was made.isReferrable
- A Boolean
value indicating whether initialising a session on this Branch instance
should be considered as potentially referrable or not. By default, a user is only referrable
if initSession results in a fresh install. Overriding this gives you control of who is referrable.Branch
object, either fetched from a pre-initialised
instance within the singleton class, or a newly instantiated object where
one was not already requested during the current app lifecycle.public static Branch getAutoInstance(android.content.Context context, java.lang.String branchKey)
Singleton method to return the pre-initialised, or newly initialise and return, a singleton
object of the type Branch
.
Use this whenever you need to call a method directly on the Branch
object.
context
- A Context
from which this call was made.branchKey
- A String
value used to initialize Branch.Branch
object, either fetched from a pre-initialised
instance within the singleton class, or a newly instantiated object where
one was not already requested during the current app lifecycle.public static Branch getAutoTestInstance(android.content.Context context)
If you configured the your Strings file according to the guide, you'll be able to use the test version of your app by just calling this static method before calling initSession.
context
- A Context
from which this call was made.Branch
object.public static Branch getAutoTestInstance(android.content.Context context, boolean isReferrable)
If you configured the your Strings file according to the guide, you'll be able to use the test version of your app by just calling this static method before calling initSession.
context
- A Context
from which this call was made.isReferrable
- A Boolean
value indicating whether initialising a session on this Branch instance
should be considered as potentially referrable or not. By default, a user is only referrable
if initSession results in a fresh install. Overriding this gives you control of who is referrable.Branch
object.public void resetUserSession()
Manually sets the Boolean
value, that indicates that the Branch API connection has
been initialised, to false - forcing re-initialisation.
public void setRetryCount(int retryCount)
Sets the number of times to re-attempt a timed-out request to the Branch API, before considering the request to have failed entirely. Default 5.
retryCount
- An Integer
specifying the number of times to retry before giving
up and declaring defeat.public void setRetryInterval(int retryInterval)
Sets the amount of time in milliseconds to wait before re-attempting a timed-out request to the Branch API. Default 3000 ms.
retryInterval
- An Integer
value specifying the number of milliseconds to
wait before re-attempting a timed-out request.public void setNetworkTimeout(int timeout)
Sets the duration in milliseconds that the system should wait for a response before considering any Branch API call to have timed out. Default 3000 ms.
Increase this to perform better in low network speed situations, but at the expense of responsiveness to error situation.
timeout
- An Integer
value specifying the number of milliseconds to wait before
considering the request to have timed out.public static void disableDeviceIDFetch(java.lang.Boolean deviceIdFetch)
Application.onCreate()
method before creating Branch auto instance by calling getAutoInstance(Context)
deviceIdFetch
- with value true to disable reading the Android id from device
public static boolean isDeviceIDFetchDisabled()
Boolean
with value true to disable reading Andoid IDpublic void setDeepLinkDebugMode(org.json.JSONObject debugParams)
debugParams
- A JSONObject
containing key-value pairs for debugging branch deep linkingpublic void disableAppList()
public void enableFacebookAppLinkCheck()
Enable Facebook app link check operation during Branch initialisation.
public void setLimitFacebookTracking(boolean isLimitFacebookTracking)
isLimitFacebookTracking
- true
to limit app trackingpublic void setRequestMetadata(java.lang.String key, java.lang.String value)
Add key value pairs to all requests
public Branch addInstallMetadata(java.lang.String key, java.lang.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()
public boolean initSession(Branch.BranchUniversalReferralInitListener callback)
Initialises a session with the Branch API, assigning a Branch.BranchUniversalReferralInitListener
to perform an action upon successful initialisation.
callback
- A Branch.BranchUniversalReferralInitListener
instance that will be called following
successful (or unsuccessful) initialisation of the session with the Branch API.Boolean
value, indicating false if initialisation is
unsuccessful.public boolean initSession(Branch.BranchReferralInitListener callback)
Initialises a session with the Branch API, assigning a Branch.BranchReferralInitListener
to perform an action upon successful initialisation.
callback
- A Branch.BranchReferralInitListener
instance that will be called following
successful (or unsuccessful) initialisation of the session with the Branch API.Boolean
value, indicating false if initialisation is
unsuccessful.public boolean initSession(Branch.BranchUniversalReferralInitListener callback, android.app.Activity activity)
Initialises a session with the Branch API, passing the Activity
and assigning a
Branch.BranchUniversalReferralInitListener
to perform an action upon successful initialisation.
callback
- A Branch.BranchUniversalReferralInitListener
instance that will be called
following successful (or unsuccessful) initialisation of the session
with the Branch API.activity
- The calling Activity
for context.Boolean
value, indicating false if initialisation is
unsuccessful.public boolean initSession(Branch.BranchReferralInitListener callback, android.app.Activity activity)
Initialises a session with the Branch API, passing the Activity
and assigning a
Branch.BranchReferralInitListener
to perform an action upon successful initialisation.
callback
- A Branch.BranchReferralInitListener
instance that will be called
following successful (or unsuccessful) initialisation of the session
with the Branch API.activity
- The calling Activity
for context.Boolean
value, indicating false if initialisation is
unsuccessful.public boolean initSession(Branch.BranchUniversalReferralInitListener callback, android.net.Uri data)
Initialises a session with the Branch API.
callback
- A Branch.BranchUniversalReferralInitListener
instance that will be called
following successful (or unsuccessful) initialisation of the session
with the Branch API.data
- A Uri
variable containing the details of the source link that
led to this initialisation action.Boolean
value that will return false if the supplied
data parameter cannot be handled successfully - i.e. is not of a
valid URI format.public boolean initSession(Branch.BranchReferralInitListener callback, android.net.Uri data)
Initialises a session with the Branch API.
callback
- A Branch.BranchReferralInitListener
instance that will be called
following successful (or unsuccessful) initialisation of the session
with the Branch API.data
- A Uri
variable containing the details of the source link that
led to this initialisation action.Boolean
value that will return false if the supplied
data parameter cannot be handled successfully - i.e. is not of a
valid URI format.public boolean initSession(Branch.BranchUniversalReferralInitListener callback, android.net.Uri data, android.app.Activity activity)
Initialises a session with the Branch API.
callback
- A Branch.BranchUniversalReferralInitListener
instance that will be called
following successful (or unsuccessful) initialisation of the session
with the Branch API.data
- A Uri
variable containing the details of the source link that
led to this initialisation action.activity
- The calling Activity
for context.Boolean
value that will return false if the supplied
data parameter cannot be handled successfully - i.e. is not of a
valid URI format.public boolean initSession(Branch.BranchReferralInitListener callback, android.net.Uri data, android.app.Activity activity)
Initialises a session with the Branch API.
callback
- A Branch.BranchReferralInitListener
instance that will be called
following successful (or unsuccessful) initialisation of the session
with the Branch API.data
- A Uri
variable containing the details of the source link that
led to this initialisation action.activity
- The calling Activity
for context.Boolean
value that will return false if the supplied
data parameter cannot be handled successfully - i.e. is not of a
valid URI format.public boolean initSession()
Initialises a session with the Branch API, without a callback or Activity
.
Boolean
value that returns false if unsuccessful.public boolean initSession(android.app.Activity activity)
Initialises a session with the Branch API, without a callback or Activity
.
activity
- The calling Activity
for context.Boolean
value that returns false if unsuccessful.public boolean initSessionForced(Branch.BranchReferralInitListener callback)
Force initialises a session with the Branch API, assigning a Branch.BranchReferralInitListener
to perform an action upon successful initialisation. Will not wait for new intent onResume.
callback
- A Branch.BranchReferralInitListener
instance that will be called following
successful (or unsuccessful) initialisation of the session with the Branch API.Boolean
value, indicating false if initialisation is
unsuccessful.public boolean initSessionWithData(android.net.Uri data)
Initialises a session with the Branch API, with associated data from the supplied
Uri
.
data
- A Uri
variable containing the details of the source link that
led to this
initialisation action.Boolean
value that returns false if unsuccessful.public boolean initSessionWithData(android.net.Uri data, android.app.Activity activity)
Initialises a session with the Branch API, with associated data from the supplied
Uri
.
data
- A Uri
variable containing the details of the source link that led to this
initialisation action.activity
- The calling Activity
for context.Boolean
value that returns false if unsuccessful.public boolean initSession(boolean isReferrable)
Initialises a session with the Branch API, specifying whether the initialisation can count as a referrable action.
isReferrable
- A Boolean
value indicating whether this initialisation
session should be considered as potentially referrable or not.
By default, a user is only referrable if initSession results in a
fresh install. Overriding this gives you control of who is referrable.Boolean
value that returns false if unsuccessful.public boolean initSession(boolean isReferrable, android.app.Activity activity)
Initialises a session with the Branch API, specifying whether the initialisation can count
as a referrable action, and supplying the calling Activity
for context.
isReferrable
- A Boolean
value indicating whether this initialisation
session should be considered as potentially referrable or not.
By default, a user is only referrable if initSession results in a
fresh install. Overriding this gives you control of who is referrable.activity
- The calling Activity
for context.Boolean
value that returns false if unsuccessful.public boolean initSession(Branch.BranchUniversalReferralInitListener callback, boolean isReferrable, android.net.Uri data)
Initialises a session with the Branch API.
callback
- A Branch.BranchUniversalReferralInitListener
instance that will be called
following successful (or unsuccessful) initialisation of the session
with the Branch API.isReferrable
- A Boolean
value indicating whether this initialisation
session should be considered as potentially referrable or not.
By default, a user is only referrable if initSession results in a
fresh install. Overriding this gives you control of who is referrable.data
- A Uri
variable containing the details of the source link that
led to this initialisation action.Boolean
value that returns false if unsuccessful.public boolean initSession(Branch.BranchReferralInitListener callback, boolean isReferrable, android.net.Uri data)
Initialises a session with the Branch API.
callback
- A Branch.BranchReferralInitListener
instance that will be called
following successful (or unsuccessful) initialisation of the session
with the Branch API.isReferrable
- A Boolean
value indicating whether this initialisation
session should be considered as potentially referrable or not.
By default, a user is only referrable if initSession results in a
fresh install. Overriding this gives you control of who is referrable.data
- A Uri
variable containing the details of the source link that
led to this initialisation action.Boolean
value that returns false if unsuccessful.public boolean initSession(Branch.BranchUniversalReferralInitListener callback, boolean isReferrable, android.net.Uri data, android.app.Activity activity)
Initialises a session with the Branch API.
callback
- A Branch.BranchUniversalReferralInitListener
instance that will be called
following successful (or unsuccessful) initialisation of the session
with the Branch API.isReferrable
- A Boolean
value indicating whether this initialisation
session should be considered as potentially referrable or not.
By default, a user is only referrable if initSession results in a
fresh install. Overriding this gives you control of who is referrable.data
- A Uri
variable containing the details of the source link that
led to this initialisation action.activity
- The calling Activity
for context.Boolean
value that returns false if unsuccessful.public boolean initSession(Branch.BranchReferralInitListener callback, boolean isReferrable, android.net.Uri data, android.app.Activity activity)
Initialises a session with the Branch API.
callback
- A Branch.BranchReferralInitListener
instance that will be called
following successful (or unsuccessful) initialisation of the session
with the Branch API.isReferrable
- A Boolean
value indicating whether this initialisation
session should be considered as potentially referrable or not.
By default, a user is only referrable if initSession results in a
fresh install. Overriding this gives you control of who is referrable.data
- A Uri
variable containing the details of the source link that
led to this initialisation action.activity
- The calling Activity
for context.Boolean
value that returns false if unsuccessful.public boolean initSession(Branch.BranchUniversalReferralInitListener callback, boolean isReferrable)
Initialises a session with the Branch API.
callback
- A Branch.BranchUniversalReferralInitListener
instance that will be called
following successful (or unsuccessful) initialisation of the session
with the Branch API.isReferrable
- A Boolean
value indicating whether this initialisation
session should be considered as potentially referrable or not.
By default, a user is only referrable if initSession results in a
fresh install. Overriding this gives you control of who is referrable.Boolean
value that returns false if unsuccessful.public boolean initSession(Branch.BranchReferralInitListener callback, boolean isReferrable)
Initialises a session with the Branch API.
callback
- A Branch.BranchReferralInitListener
instance that will be called
following successful (or unsuccessful) initialisation of the session
with the Branch API.isReferrable
- A Boolean
value indicating whether this initialisation
session should be considered as potentially referrable or not.
By default, a user is only referrable if initSession results in a
fresh install. Overriding this gives you control of who is referrable.Boolean
value that returns false if unsuccessful.public boolean initSession(Branch.BranchUniversalReferralInitListener callback, boolean isReferrable, android.app.Activity activity)
Initialises a session with the Branch API.
callback
- A Branch.BranchUniversalReferralInitListener
instance that will be called
following successful (or unsuccessful) initialisation of the session
with the Branch API.isReferrable
- A Boolean
value indicating whether this initialisation
session should be considered as potentially referrable or not.
By default, a user is only referrable if initSession results in a
fresh install. Overriding this gives you control of who is referrable.activity
- The calling Activity
for context.Boolean
value that returns false if unsuccessful.public boolean initSession(Branch.BranchReferralInitListener callback, boolean isReferrable, android.app.Activity activity)
Initialises a session with the Branch API.
callback
- A Branch.BranchReferralInitListener
instance that will be called
following successful (or unsuccessful) initialisation of the session
with the Branch API.isReferrable
- A Boolean
value indicating whether this initialisation
session should be considered as potentially referrable or not.
By default, a user is only referrable if initSession results in a
fresh install. Overriding this gives you control of who is referrable.activity
- The calling Activity
for context.Boolean
value that returns false if unsuccessful.public void closeSession()
Closes the current session, dependent on the state of the
PrefHelper#getSmartSession() Boolean
value. If true, take no action.
If false, close the session via the executeClose()
)} method.
Note that if smartSession is enabled, closeSession cannot be called within a 2 second time span of another Branch action. This has to do with the method that Branch uses to keep a session alive during Activity transitions
public static void enableCookieBasedMatching(java.lang.String cookieMatchDomain)
Enabled Strong matching check using chrome cookies. This method should be called before Branch#getAutoInstance(Context).
cookieMatchDomain
- The domain for the url used to match the cookie (eg. example.app.link)public static void enableCookieBasedMatching(java.lang.String cookieMatchDomain, int delay)
Enabled Strong matching check using chrome cookies. This method should be called before Branch#getAutoInstance(Context).
cookieMatchDomain
- The domain for the url used to match the cookie (eg. example.app.link)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.public void onGAdsFetchFinished()
public void onInstallReferrerEventsFinished()
public Branch addWhiteListedScheme(java.lang.String urlWhiteListPattern)
This method should be called immediately after calling getAutoInstance(Context)
urlWhiteListPattern
- A regular expression with a URI white listing patternBranch
instance for successive method callspublic Branch setWhiteListedSchemes(java.util.List<java.lang.String> urlWhiteListPatternList)
This method should be called immediately after calling getAutoInstance(Context)
urlWhiteListPatternList
- List
of regular expressions with URI white listing patternBranch
instance for successive method callspublic Branch addUriHostsToSkip(java.lang.String urlSkipPattern)
This method should be called immediately after calling getAutoInstance(Context)
urlSkipPattern
- String
A URL pattern that Branch SDK should skip from collecting dataBranch
instance for successive method callspublic void setIdentity(java.lang.String userId)
Identifies the current user to the Branch API by supplying a unique identifier as a
String
value. No callback.
userId
- A String
value containing the unique identifier of the user.public void setIdentity(java.lang.String userId, 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 successful
response to request.
userId
- A String
value containing the unique identifier of the user.callback
- A Branch.BranchReferralInitListener
callback instance that will return
the data associated with the user id being assigned, if available.public boolean isUserIdentified()
Boolean
value that will return true only if user already has an identity.public 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 Branch to create a new user for this device. This will clear the first and latest params, as a new session is created.
public 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 Branch to create a new user for this device. This will clear the first and latest params, as a new session is created.
callback
- An instance of Branch.LogoutStatusListener
to callback with the logout operation status.public void loadRewards()
Fire-and-forget retrieval of rewards for the current session. Without a callback.
public void loadRewards(Branch.BranchReferralStateChangedListener callback)
Retrieves rewards for the current session, with a callback to perform a predefined action following successful report of state change. You'll then need to call getCredits in the callback to update the credit totals in your UX.
callback
- A Branch.BranchReferralStateChangedListener
callback instance that will
trigger actions defined therein upon a referral state change.public int getCredits()
Retrieve the number of credits available for the "default" bucket.
Integer
value of the number credits available in the "default" bucket.public int getCreditsForBucket(java.lang.String bucket)
Integer
of the number of credits available for use within the supplied
bucket name.bucket
- A String
value indicating the name of the bucket to get credits for.Integer
value of the number credits available in the specified
bucket.public void redeemRewards(int count)
Redeems the specified number of credits from the "default" bucket, if there are sufficient credits within it. If the number to redeem exceeds the number available in the bucket, all of the available credits will be redeemed instead.
count
- A Integer
specifying the number of credits to attempt to redeem from
the bucket.public void redeemRewards(int count, Branch.BranchReferralStateChangedListener callback)
Redeems the specified number of credits from the "default" bucket, if there are sufficient credits within it. If the number to redeem exceeds the number available in the bucket, all of the available credits will be redeemed instead.
count
- A Integer
specifying the number of credits to attempt to redeem from
the bucket.callback
- A Branch.BranchReferralStateChangedListener
callback instance that will
trigger actions defined therein upon a executing redeem rewards.public void redeemRewards(java.lang.String bucket, int count)
Redeems the specified number of credits from the named bucket, if there are sufficient credits within it. If the number to redeem exceeds the number available in the bucket, all of the available credits will be redeemed instead.
bucket
- A String
value containing the name of the referral bucket to attempt
to redeem credits from.count
- A Integer
specifying the number of credits to attempt to redeem from
the specified bucket.public void redeemRewards(java.lang.String bucket, int count, Branch.BranchReferralStateChangedListener callback)
Redeems the specified number of credits from the named bucket, if there are sufficient credits within it. If the number to redeem exceeds the number available in the bucket, all of the available credits will be redeemed instead.
bucket
- A String
value containing the name of the referral bucket to attempt
to redeem credits from.count
- A Integer
specifying the number of credits to attempt to redeem from
the specified bucket.callback
- A Branch.BranchReferralStateChangedListener
callback instance that will
trigger actions defined therein upon a executing redeem rewards.public void getCreditHistory(Branch.BranchListResponseListener callback)
Gets the credit history of the specified bucket and triggers a callback to handle the response.
callback
- A Branch.BranchListResponseListener
callback instance that will trigger
actions defined therein upon receipt of a response to a create link request.public void getCreditHistory(java.lang.String bucket, Branch.BranchListResponseListener callback)
Gets the credit history of the specified bucket and triggers a callback to handle the response.
bucket
- A String
value containing the name of the referral bucket that the
code will belong to.callback
- A Branch.BranchListResponseListener
callback instance that will trigger
actions defined therein upon receipt of a response to a create link request.public void getCreditHistory(java.lang.String afterId, int length, Branch.CreditHistoryOrder order, Branch.BranchListResponseListener callback)
Gets the credit history of the specified bucket and triggers a callback to handle the response.
afterId
- A String
value containing the ID of the history record to begin after.
This allows for a partial history to be retrieved, rather than the entire
credit history of the bucket.length
- A Integer
value containing the number of credit history records to
return.order
- A Branch.CreditHistoryOrder
object indicating which order the results should
be returned in.
Valid choices:
callback
- A Branch.BranchListResponseListener
callback instance that will trigger
actions defined therein upon receipt of a response to a create link request.public void getCreditHistory(java.lang.String bucket, java.lang.String afterId, int length, Branch.CreditHistoryOrder order, Branch.BranchListResponseListener callback)
Gets the credit history of the specified bucket and triggers a callback to handle the response.
bucket
- A String
value containing the name of the referral bucket that the
code will belong to.afterId
- A String
value containing the ID of the history record to begin after.
This allows for a partial history to be retrieved, rather than the entire
credit history of the bucket.length
- A Integer
value containing the number of credit history records to
return.order
- A Branch.CreditHistoryOrder
object indicating which order the results should
be returned in.
Valid choices:
callback
- A Branch.BranchListResponseListener
callback instance that will trigger
actions defined therein upon receipt of a response to a create link request.public void userCompletedAction(java.lang.String action, org.json.JSONObject metadata)
A void call to indicate that the user has performed a specific action and for that to be reported to the Branch API, with additional app-defined meta data to go along with that action.
action
- A String
value to be passed as an action that the user has carried
out. For example "registered" or "logged in".metadata
- A JSONObject
containing app-defined meta-data to be attached to a
user action that has just been completed.public void userCompletedAction(java.lang.String action)
A void call to indicate that the user has performed a specific action and for that to be reported to the Branch API.
action
- A String
value to be passed as an action that the user has carried
out. For example "registered" or "logged in".public void userCompletedAction(java.lang.String action, BranchViewHandler.IBranchViewEvents callback)
A void call to indicate that the user has performed a specific action and for that to be reported to the Branch API.
action
- A String
value to be passed as an action that the user has carried
out. For example "registered" or "logged in".callback
- instance of BranchViewHandler.IBranchViewEvents
to listen Branch view eventspublic void userCompletedAction(java.lang.String action, org.json.JSONObject metadata, BranchViewHandler.IBranchViewEvents callback)
A void call to indicate that the user has performed a specific action and for that to be reported to the Branch API, with additional app-defined meta data to go along with that action.
action
- A String
value to be passed as an action that the user has carried
out. For example "registered" or "logged in".metadata
- A JSONObject
containing app-defined meta-data to be attached to a
user action that has just been completed.callback
- instance of BranchViewHandler.IBranchViewEvents
to listen Branch view eventspublic void sendCommerceEvent(CommerceEvent commerceEvent, org.json.JSONObject metadata, BranchViewHandler.IBranchViewEvents callback)
public void sendCommerceEvent(CommerceEvent commerceEvent)
public org.json.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 true on a fresh install (not upgrade or reinstall). This will change on setIdentity (if the user already exists from a previous device) and logout.
JSONObject
containing the install-time parameters as configured
locally.public org.json.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 true on a fresh install (not upgrade or reinstall). This will change on setIdentity (if the user already exists from a previous device) and logout.
JSONObject
containing the install-time parameters as configured
locally.public org.json.JSONObject getLatestReferringParams()
Returns the parameters associated with the link that referred the session. If a user clicks a link, and then opens the app, initSession will return the parameters of the link and 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 you minimize the app, these parameters will be cleared when closeSession is called.
JSONObject
containing the latest referring parameters as
configured locally.public org.json.JSONObject getLatestReferringParamsSync()
This function must be called from a non-UI thread! If Branch has not been initialized and 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 user clicks a link, and then opens the app, initSession will return the parameters of the link and 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 you minimize the app, these parameters will be cleared when closeSession is called.
JSONObject
containing the latest referring parameters as
configured locally.public org.json.JSONObject getDeeplinkDebugParams()
public 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 are calling this method before your activity finishes inorder to prevent any window leak.
animateClose
- A Boolean
to specify whether to close the dialog with an animation.
A value of true will close the dialog with an animation. Setting this value
to false will close the Dialog immediately.public void handleNewRequest(ServerRequest req)
req
- The ServerRequest
to executepublic void notifyNetworkAvailable()
public static boolean isAutoDeepLinkLaunch(android.app.Activity activity)
Checks if an activity is launched by Branch auto deep link feature. Branch launches activitie 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 followsactivity
- Instance of activity to check if launched on auto deep link.public static void enableSimulateInstalls()
public static void disableSimulateInstalls()
public static void enableLogging()
public static void disableLogging()
public static void enableForcedSession()
public static void disableForcedSession()
public static boolean isForceSessionEnabled()
Boolean
with value true to enable forced sessionpublic static void enableBypassCurrentActivityIntentState()
public void registerView(BranchUniversalObject branchUniversalObject, BranchUniversalObject.RegisterViewStatusListener callback)
public void addExtraInstrumentationData(java.util.HashMap<java.lang.String,java.lang.String> instrumentationData)
instrumentationData
- A HashMap
with key value pairs for instrumentation data.public void addExtraInstrumentationData(java.lang.String key, java.lang.String value)
key
- A String
Value for instrumentation data keyvalue
- A String
Value for instrumentation data valuepublic void onBranchViewVisible(java.lang.String action, java.lang.String branchViewID)
BranchViewHandler.IBranchViewEvents
onBranchViewVisible
in interface BranchViewHandler.IBranchViewEvents
action
- action name associated with the Branch view itembranchViewID
- ID for the Branch view displayedpublic void onBranchViewAccepted(java.lang.String action, java.lang.String branchViewID)
BranchViewHandler.IBranchViewEvents
onBranchViewAccepted
in interface BranchViewHandler.IBranchViewEvents
action
- action name associated with the App Branch itembranchViewID
- ID for the Branch view acceptedpublic void onBranchViewCancelled(java.lang.String action, java.lang.String branchViewID)
BranchViewHandler.IBranchViewEvents
onBranchViewCancelled
in interface BranchViewHandler.IBranchViewEvents
action
- action name associated with the Branch viewbranchViewID
- ID for the Branch view cancelledpublic void onBranchViewError(int errorCode, java.lang.String errorMsg, java.lang.String action)
BranchViewHandler.IBranchViewEvents
onBranchViewError
in interface BranchViewHandler.IBranchViewEvents
errorCode
- Integer
with error code for the issueerrorMsg
- String
with value error messageaction
- action name for the Branch view failed to displaypublic static boolean isInstantApp(android.content.Context context)
context
- Current Context
true
if current application is an instance of instant apppublic static boolean showInstallPrompt(android.app.Activity activity, int requestCode)
activity
- Current activityrequestCode
- Request code for the activity to receive the resulttrue
if install prompt is shown to userpublic static boolean showInstallPrompt(android.app.Activity activity, int requestCode, java.lang.String referrer)
showInstallPrompt(Activity, int)
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")true
if install prompt is shown to userpublic static boolean showInstallPrompt(android.app.Activity activity, int requestCode, BranchUniversalObject buo)
BranchUniversalObject
to do deferred deep link.
Please see showInstallPrompt(Activity, int)
NOTE :
This method will do a synchronous generation of Branch short link for the BUO. So please consider calling this method on non UI thread
Please make sure your instant app and full ap are using same Branch key in order for the deferred deep link workingactivity
- Current activityrequestCode
- Request code for the activity to receive the resultbuo
- BranchUniversalObject
to pass to the full app up on installtrue
if install prompt is shown to user