-
public class PrefHelperA class that uses the helper pattern to provide regularly referenced static values and logging capabilities used in various other parts of the SDK, and that are related to globally set preference values.
-
-
Field Summary
Fields Modifier and Type Field Description public final static StringNO_STRING_VALUEprivate final JSONObjectrequestMetadataprivate final JSONObjectinstallMetadata
-
Method Summary
Modifier and Type Method Description JSONObjectgetRequestMetadata()voidsetRequestMetadata(@NonNull() String key, @NonNull() String value)JSONObjectgetInstallMetadata()static PrefHelpergetInstance(Context context)Singleton method to return the pre-initialised, or newly initialise and return, a singletonobject of the type PrefHelper. StringgetAPIBaseUrl()Returns the base URL to use for all calls to the Branch API as a String. voidsetTimeout(int timeout)Sets the duration in milliseconds to override the timeout value for calls to the Branch API. intgetTimeout()Returns the currently set timeout value for calls to the Branch API. intgetTaskTimeout()Returns the computed value of the connect and read timeout for web requests voidsetConnectTimeout(int connectTimeout)Sets the duration in milliseconds to override the timeout value for initiating requests. intgetConnectTimeout()Returns the currently set timeout value for opening a communication channel with a remoteresource. voidsetRetryCount(int retry)Sets the value specifying the number of times that a Branch API call has been re-attempted. intgetRetryCount()Gets the current count of the number of times that a Branch API call has been re-attempted. voidsetRetryInterval(int retryInt)Sets the amount of time in milliseconds to wait before re-attempting a timed-out requestto the Branch API. intgetRetryInterval()Gets the amount of time in milliseconds to wait before re-attempting a timed-out requestto the Branch API. voidsetNoConnectionRetryMax(int retryInt)In cases of persistent no internet connection or offline modes,set a maximum number of attempts for the Branch Request to be tried. intgetNoConnectionRetryMax()Returns the set retry count for Branch Requests voidsetAppVersion(String version)Sets the value of KEY_APP_VERSION in preferences. StringgetAppVersion()Returns the current value of KEY_APP_VERSION as stored in preferences. booleansetBranchKey(String key)Set the given Branch Key to preference. StringgetBranchKey()voidsetRandomizedDeviceToken(String randomized_device_token)Sets the randomized device token value of the current OS build, on the current device,as a String in preferences. StringgetRandomizedDeviceToken()Gets the randomized device token value of the current OS build, on the current device,as a String from preferences. voidsetSessionID(String session_id)Sets the ID of the KEY_SESSION_IDString value in preferences. StringgetSessionID()Gets the ID of the KEY_SESSION_IDString value from preferences. voidsetRandomizedBundleToken(String randomized_bundle_token)Sets the KEY_RANDOMIZED_BUNDLE_TOKENString value that has been set via the Branch API. StringgetRandomizedBundleToken()Gets the KEY_RANDOMIZED_BUNDLE_TOKENString value that has been set via the Branch API. voidsetIdentity(String identity)Sets the KEY_IDENTITYString value that has been set via the Branch API. StringgetIdentity()Gets the KEY_IDENTITYString value that has been set via the Branch API. voidsetLinkClickID(String link_click_id)Sets the KEY_LINK_CLICK_IDString value that has been set via the Branch API. voidsetRandomlyGeneratedUuid(String uuid)Sets a new randomly generated UUID to be associated with the device. StringgetRandomlyGeneratedUuid()Returns our own randomly generated UUID associated with the device StringgetLinkClickID()Gets the KEY_LINK_CLICK_IDString value that has been set via the Branch API. voidsetIsAppLinkTriggeredInit(Boolean isAppLinkTriggered)Set the value to specify if the current init is triggered by an FB app link booleangetIsAppLinkTriggeredInit()Specifies the value to specify if the current init is triggered by an FB app link voidsetAdNetworkCalloutsDisabled(boolean disabled)Specify whether ad network callouts should be disabled. booleangetAdNetworkCalloutsDisabled()Determine whether ad network callouts have been disabled. voidsetExternalIntentUri(String uri)Sets the KEY_EXTERNAL_INTENT_URI with value with given intent URI String. StringgetExternalIntentUri()Gets the KEY_EXTERNAL_INTENT_URIString value that has been set via the Branch API. voidsetExternalIntentExtra(String extras)Sets the KEY_EXTERNAL_INTENT_EXTRA with value with given intent extras in string format. StringgetExternalIntentExtra()Gets the KEY_EXTERNAL_INTENT_EXTRAString value that has been set via the Branch API. voidsetLinkClickIdentifier(String identifier)Sets the KEY_LINK_CLICK_IDENTIFIER String value that has been set via the Branch API. StringgetLinkClickIdentifier()Gets the KEY_LINK_CLICK_IDENTIFIER String value that has been set via the Branch API. voidsetGoogleSearchInstallIdentifier(String identifier)Sets the Google install referrer identifier to the pref StringgetGoogleSearchInstallIdentifier()Gets the google install referrer identifier voidsetAppStoreReferrer(String referrer)Sets the app store install referrer string StringgetAppStoreReferrer()Gets the app store install referrer string voidsetAppStoreSource(String store)StringgetAppStoreSource()voidsetReferrerGclid(String referrerGclid)Sets the referrer Google Click ID with an expiration date computed by time set + expiration window StringgetReferrerGclid()Returns the persisted referrer Google Click IDIf the expiry date has passed, the entry is deleted and will return null voidsetReferrerGclidValidForWindow(long window)Sets the GCLID expiration window in milliseconds longgetReferrerGclidValidForWindow()Gets the GCLID expiration window in milliseconds voidsetAppLink(String appLinkUrl)Set the KEY_APP_LINK String values that has been started the application. StringgetAppLink()Get the App link which statrted the application. voidsetIsFullAppConversion(boolean isFullAppConversion)Set the value for the full app conversion state. booleanisFullAppConversion()Get the value for the full app conversion state. voidsetPushIdentifier(String pushIdentifier)Set the KEY_PUSH_IDENTIFIER String values that has been started the application. StringgetPushIdentifier()Get the branch url in push payload which started the application. StringgetSessionParams()Gets the session parameters as currently set in preferences. voidsetSessionParams(String params)Sets the session parameters as currently set in preferences. StringgetInstallParams()Gets the session parameters as originally set at time of app installation, in preferences. voidsetInstallParams(String params)Sets the session parameters as originally set at time of app installation, in preferences. voidsetInstallReferrerParams(String params)StringgetInstallReferrerParams()voidsetUserURL(String user_url)Sets the user URL from preferences. StringgetUserURL()Sets the user URL from preferences. voidclearSystemReadStatus()Resets the time that the system was last read. voidclearUserValues()Resets the user-related values that have been stored in preferences. voidsetCreditCount(int count)voidsetCreditCount(String bucket, int count)intgetCreditCount()intgetCreditCount(String bucket)voidsetActionTotalCount(String action, int count)Sets the count of total number of times that the specified action has been carried outduring the current session, as defined in preferences. voidsetActionUniqueCount(String action, int count)Sets the count of the unique number of times that the specified action has been carriedout during the current session, as defined in preferences. intgetActionTotalCount(String action)Gets the count of total number of times that the specified action has been carriedout during the current session, as defined in preferences. intgetActionUniqueCount(String action)Gets the count of the unique number of times that the specified action has been carriedout during the current session, as defined in preferences. voidsetLATDAttributionWindow(int attributionWindow)Sets the latd attribution window, if attributionWindow is null, the saved latd attributionwindow value will be deleted. intgetLATDAttributionWindow()Gets the latd attribution window voidsetInitialReferrer(String initialReferrer)Persist the android.intent.extra. StringgetInitialReferrer()Get the persisted android.intent.extra. booleanhasPrefValue(String key)A basic method that returns a Boolean indicating whether some preference exists. voidremovePrefValue(String key)A basic method to remove some preference value. intgetInteger(String key)A basic method that returns an integer value from a specified preferences Key. intgetInteger(String key, int defaultValue)A basic method that returns an Integer value from a specified preferences Key, with adefault value supplied in case the value is null. longgetLong(String key)A basic method that returns a Long value from a specified preferences Key. longgetLong(String key, long defaultValue)floatgetFloat(String key)A basic method that returns a Float value from a specified preferences Key. StringgetString(String key)A basic method that returns a String value from a specified preferences Key. booleangetBool(String key)A basic method that returns a Boolean value from a specified preferences Key. voidsetInteger(String key, int value)Sets the value of the String key value supplied in preferences. voidsetLong(String key, long value)Sets the value of the String key value supplied in preferences. voidsetFloat(String key, float value)Sets the value of the String key value supplied in preferences. voidsetString(String key, String value)Sets the value of the String key value supplied in preferences. voidsetBool(String key, Boolean value)Sets the value of the String key value supplied in preferences. voidupdateBranchViewUsageCount(String branchViewId)intgetBranchViewUsageCount(String branchViewId)voidsaveLastStrongMatchTime(long strongMatchCheckTime)Saves the last strong match epoch time stamp longgetLastStrongMatchTime()Get the last strong match check epoch time static voidDebug(String message)Creates a Debug message in the debugger. static voidLogException(String message, Exception t)static voidLogAlways(String message)voidloadPartnerParams(JSONObject body)-
-
Method Detail
-
getRequestMetadata
JSONObject getRequestMetadata()
-
setRequestMetadata
void setRequestMetadata(@NonNull() String key, @NonNull() String value)
-
getInstallMetadata
JSONObject getInstallMetadata()
-
getInstance
static PrefHelper getInstance(Context context)
Singleton method to return the pre-initialised, or newly initialise and return, a singletonobject of the type PrefHelper.
- Parameters:
context- The Context within which the object should be instantiated; thisparameter is passed to the private PrefHelper constructor method.
-
getAPIBaseUrl
String getAPIBaseUrl()
Returns the base URL to use for all calls to the Branch API as a String.
NOTE: Below API v20, TLS 1.2 does not work reliably, so we will fall back in that case.
-
setTimeout
void setTimeout(int timeout)
Sets the duration in milliseconds to override the timeout value for calls to the Branch API.
- Parameters:
timeout- The Integer value of the timeout setting in milliseconds.
-
getTimeout
int getTimeout()
Returns the currently set timeout value for calls to the Branch API. This will be the defaultSDK setting unless it has been overridden manually between Branch object instantiation andthis call.
-
getTaskTimeout
int getTaskTimeout()
Returns the computed value of the connect and read timeout for web requests
-
setConnectTimeout
void setConnectTimeout(int connectTimeout)
Sets the duration in milliseconds to override the timeout value for initiating requests.
- Parameters:
connectTimeout- The Integer value of the connect timeout setting in milliseconds.
-
getConnectTimeout
int getConnectTimeout()
Returns the currently set timeout value for opening a communication channel with a remoteresource.
-
setRetryCount
void setRetryCount(int retry)
Sets the value specifying the number of times that a Branch API call has been re-attempted.
This overrides the default retry value.
- Parameters:
retry- An Integer value specifying the value to be specified in preferencesthat determines the number of times that a Branch API call has been re-attempted.
-
getRetryCount
int getRetryCount()
Gets the current count of the number of times that a Branch API call has been re-attempted.
-
setRetryInterval
void setRetryInterval(int retryInt)
Sets the amount of time in milliseconds to wait before re-attempting a timed-out requestto the Branch API.
- Parameters:
retryInt- An Integer value specifying the number of milliseconds to waitbefore re-attempting a timed-out request.
-
getRetryInterval
int getRetryInterval()
Gets the amount of time in milliseconds to wait before re-attempting a timed-out requestto the Branch API.
-
setNoConnectionRetryMax
void setNoConnectionRetryMax(int retryInt)
In cases of persistent no internet connection or offline modes,set a maximum number of attempts for the Branch Request to be tried.
-
getNoConnectionRetryMax
int getNoConnectionRetryMax()
Returns the set retry count for Branch Requests
-
setAppVersion
void setAppVersion(String version)
Sets the value of KEY_APP_VERSION in preferences.
- Parameters:
version- A String value containing the current app version.
-
getAppVersion
String getAppVersion()
Returns the current value of KEY_APP_VERSION as stored in preferences.
-
setBranchKey
boolean setBranchKey(String key)
Set the given Branch Key to preference. Clears the preference data if the key is a new key.
- Parameters:
key- A String representing Branch Key.
-
getBranchKey
String getBranchKey()
-
setRandomizedDeviceToken
void setRandomizedDeviceToken(String randomized_device_token)
Sets the randomized device token value of the current OS build, on the current device,as a String in preferences.
- Parameters:
randomized_device_token- A String that uniquely identifies this build.
-
getRandomizedDeviceToken
String getRandomizedDeviceToken()
Gets the randomized device token value of the current OS build, on the current device,as a String from preferences.
-
setSessionID
void setSessionID(String session_id)
Sets the ID of the KEY_SESSION_IDString value in preferences.
- Parameters:
session_id- A String value containing the session ID as returned by theBranch API upon successful initialisation.
-
getSessionID
String getSessionID()
Gets the ID of the KEY_SESSION_IDString value from preferences.
-
setRandomizedBundleToken
void setRandomizedBundleToken(String randomized_bundle_token)
Sets the KEY_RANDOMIZED_BUNDLE_TOKENString value that has been set via the Branch API.
This is used to identify a specific user ID and link that to a current session. Useful bothfor analytics and debugging purposes.
Note: Not to be confused with setIdentity - the name of the user
- Parameters:
randomized_bundle_token- A String value containing the currently configured identitywithin preferences.
-
getRandomizedBundleToken
String getRandomizedBundleToken()
Gets the KEY_RANDOMIZED_BUNDLE_TOKENString value that has been set via the Branch API.
-
setIdentity
void setIdentity(String identity)
Sets the KEY_IDENTITYString value that has been set via the Branch API.
This is used to identify a specific user identity and link that to a current session. Useful bothfor analytics and debugging purposes.
Note: Not to be confused with setRandomizedBundleToken - the UID reference of the user
- Parameters:
identity- A String value containing the currently configured identitywithin preferences.
-
getIdentity
String getIdentity()
Gets the KEY_IDENTITYString value that has been set via the Branch API.
This is used to identify a specific user identity and link that to a current session. Useful bothfor analytics and debugging purposes.
-
setLinkClickID
void setLinkClickID(String link_click_id)
Sets the KEY_LINK_CLICK_IDString value that has been set via the Branch API.
- Parameters:
link_click_id- A String value containing the identifier of theassociated link.
-
setRandomlyGeneratedUuid
void setRandomlyGeneratedUuid(String uuid)
Sets a new randomly generated UUID to be associated with the device.
-
getRandomlyGeneratedUuid
String getRandomlyGeneratedUuid()
Returns our own randomly generated UUID associated with the device
-
getLinkClickID
String getLinkClickID()
Gets the KEY_LINK_CLICK_IDString value that has been set via the Branch API.
-
setIsAppLinkTriggeredInit
void setIsAppLinkTriggeredInit(Boolean isAppLinkTriggered)
Set the value to specify if the current init is triggered by an FB app link
- Parameters:
isAppLinkTriggered- Boolean with value for triggered by an FB app link state
-
getIsAppLinkTriggeredInit
boolean getIsAppLinkTriggeredInit()
Specifies the value to specify if the current init is triggered by an FB app link
-
setAdNetworkCalloutsDisabled
void setAdNetworkCalloutsDisabled(boolean disabled)
Specify whether ad network callouts should be disabled. By default, they are enabled.
- Parameters:
disabled- (@link Boolean) whether ad network callouts should be disabled
-
getAdNetworkCalloutsDisabled
boolean getAdNetworkCalloutsDisabled()
Determine whether ad network callouts have been disabled.
-
setExternalIntentUri
void setExternalIntentUri(String uri)
Sets the KEY_EXTERNAL_INTENT_URI with value with given intent URI String.
- Parameters:
uri- A String value containing intent URI to set
-
getExternalIntentUri
String getExternalIntentUri()
Gets the KEY_EXTERNAL_INTENT_URIString value that has been set via the Branch API.
-
setExternalIntentExtra
void setExternalIntentExtra(String extras)
Sets the KEY_EXTERNAL_INTENT_EXTRA with value with given intent extras in string format.
- Parameters:
extras- A String value containing intent URI extra to set
-
getExternalIntentExtra
String getExternalIntentExtra()
Gets the KEY_EXTERNAL_INTENT_EXTRAString value that has been set via the Branch API.
-
setLinkClickIdentifier
void setLinkClickIdentifier(String identifier)
Sets the KEY_LINK_CLICK_IDENTIFIER String value that has been set via the Branch API.
- Parameters:
identifier- A String value containing the identifier of the associatedlink.
-
getLinkClickIdentifier
String getLinkClickIdentifier()
Gets the KEY_LINK_CLICK_IDENTIFIER String value that has been set via the Branch API.
-
setGoogleSearchInstallIdentifier
void setGoogleSearchInstallIdentifier(String identifier)
Sets the Google install referrer identifier to the pref
- Parameters:
identifier- Google install referrer identifier
-
getGoogleSearchInstallIdentifier
String getGoogleSearchInstallIdentifier()
Gets the google install referrer identifier
-
setAppStoreReferrer
void setAppStoreReferrer(String referrer)
Sets the app store install referrer string
- Parameters:
referrer- App store install referrer string
-
getAppStoreReferrer
String getAppStoreReferrer()
Gets the app store install referrer string
-
setAppStoreSource
void setAppStoreSource(String store)
-
getAppStoreSource
String getAppStoreSource()
-
setReferrerGclid
void setReferrerGclid(String referrerGclid)
Sets the referrer Google Click ID with an expiration date computed by time set + expiration window
-
getReferrerGclid
String getReferrerGclid()
Returns the persisted referrer Google Click IDIf the expiry date has passed, the entry is deleted and will return null
-
setReferrerGclidValidForWindow
void setReferrerGclidValidForWindow(long window)
Sets the GCLID expiration window in milliseconds
-
getReferrerGclidValidForWindow
long getReferrerGclidValidForWindow()
Gets the GCLID expiration window in milliseconds
-
setAppLink
void setAppLink(String appLinkUrl)
Set the KEY_APP_LINK String values that has been started the application.
- Parameters:
appLinkUrl- The App link which started this application
-
getAppLink
String getAppLink()
Get the App link which statrted the application.
-
setIsFullAppConversion
void setIsFullAppConversion(boolean isFullAppConversion)
Set the value for the full app conversion state. If set true indicate that this session isinitiated by a full app conversion flow
- Parameters:
isFullAppConversion- Boolean with value for full app conversion state
-
isFullAppConversion
boolean isFullAppConversion()
Get the value for the full app conversion state.
-
setPushIdentifier
void setPushIdentifier(String pushIdentifier)
Set the KEY_PUSH_IDENTIFIER String values that has been started the application.
- Parameters:
pushIdentifier- The Branch url with the push notification which started the app.
-
getPushIdentifier
String getPushIdentifier()
Get the branch url in push payload which started the application.
-
getSessionParams
String getSessionParams()
Gets the session parameters as currently set in preferences.
Parameters are stored in JSON format, and must be parsed prior to access.
-
setSessionParams
void setSessionParams(String params)
Sets the session parameters as currently set in preferences.
- Parameters:
params- A String value containing the JSON-encoded structure ofparameters for the current session.
-
getInstallParams
String getInstallParams()
Gets the session parameters as originally set at time of app installation, in preferences.
-
setInstallParams
void setInstallParams(String params)
Sets the session parameters as originally set at time of app installation, in preferences.
- Parameters:
params- A String value containing the JSON-encoded structure ofparameters as they should be at the time of installation.
-
setInstallReferrerParams
void setInstallReferrerParams(String params)
-
getInstallReferrerParams
String getInstallReferrerParams()
-
setUserURL
void setUserURL(String user_url)
Sets the user URL from preferences.
- Parameters:
user_url- A String value containing the current user URL.
-
getUserURL
String getUserURL()
Sets the user URL from preferences.
-
clearSystemReadStatus
void clearSystemReadStatus()
Resets the time that the system was last read. This is used to calculate how "stale" thevalues are that are in use in preferences.
-
clearUserValues
void clearUserValues()
Resets the user-related values that have been stored in preferences. This will cause async to occur whenever a method reads any of the values and finds the value to be 0 or unset.
-
setCreditCount
@Deprecated() void setCreditCount(int count)
-
setCreditCount
@Deprecated() void setCreditCount(String bucket, int count)
-
getCreditCount
@Deprecated() int getCreditCount()
-
getCreditCount
@Deprecated() int getCreditCount(String bucket)
-
setActionTotalCount
void setActionTotalCount(String action, int count)
Sets the count of total number of times that the specified action has been carried outduring the current session, as defined in preferences.
-
setActionUniqueCount
void setActionUniqueCount(String action, int count)
Sets the count of the unique number of times that the specified action has been carriedout during the current session, as defined in preferences.
-
getActionTotalCount
int getActionTotalCount(String action)
Gets the count of total number of times that the specified action has been carriedout during the current session, as defined in preferences.
- Parameters:
action- A String value containing the name of the action to return thecount for.
-
getActionUniqueCount
int getActionUniqueCount(String action)
Gets the count of the unique number of times that the specified action has been carriedout during the current session, as defined in preferences.
- Parameters:
action- A String value containing the name of the action to return thecount for.
-
setLATDAttributionWindow
void setLATDAttributionWindow(int attributionWindow)
Sets the latd attribution window, if attributionWindow is null, the saved latd attributionwindow value will be deleted.
- Parameters:
attributionWindow- An Integer value containing the current attribution window passed
-
getLATDAttributionWindow
int getLATDAttributionWindow()
Gets the latd attribution window
-
setInitialReferrer
void setInitialReferrer(String initialReferrer)
Persist the android.intent.extra.REFERRER value
- Parameters:
initialReferrer- android.intent.extra.
-
getInitialReferrer
String getInitialReferrer()
Get the persisted android.intent.extra.REFERRER value
-
hasPrefValue
boolean hasPrefValue(String key)
A basic method that returns a Boolean indicating whether some preference exists.
- Parameters:
key- A String value containing the key to reference.
-
removePrefValue
void removePrefValue(String key)
A basic method to remove some preference value.
- Parameters:
key- A String value containing the key to the value that's to be deleted.
-
getInteger
int getInteger(String key)
A basic method that returns an integer value from a specified preferences Key.
- Parameters:
key- A String value containing the key to reference.
-
getInteger
int getInteger(String key, int defaultValue)
A basic method that returns an Integer value from a specified preferences Key, with adefault value supplied in case the value is null.
-
getLong
long getLong(String key)
A basic method that returns a Long value from a specified preferences Key.
- Parameters:
key- A String value containing the key to reference.
-
getFloat
float getFloat(String key)
A basic method that returns a Float value from a specified preferences Key.
- Parameters:
key- A String value containing the key to reference.
-
getString
String getString(String key)
A basic method that returns a String value from a specified preferences Key.
- Parameters:
key- A String value containing the key to reference.
-
getBool
boolean getBool(String key)
A basic method that returns a Boolean value from a specified preferences Key.
- Parameters:
key- A String value containing the key to reference.
-
setInteger
void setInteger(String key, int value)
Sets the value of the String key value supplied in preferences.
-
setLong
void setLong(String key, long value)
Sets the value of the String key value supplied in preferences.
-
setFloat
void setFloat(String key, float value)
Sets the value of the String key value supplied in preferences.
-
setString
void setString(String key, String value)
Sets the value of the String key value supplied in preferences.
-
setBool
void setBool(String key, Boolean value)
Sets the value of the String key value supplied in preferences.
-
updateBranchViewUsageCount
void updateBranchViewUsageCount(String branchViewId)
-
getBranchViewUsageCount
int getBranchViewUsageCount(String branchViewId)
-
saveLastStrongMatchTime
void saveLastStrongMatchTime(long strongMatchCheckTime)
Saves the last strong match epoch time stamp
- Parameters:
strongMatchCheckTime- epoch time stamp for last strong match
-
getLastStrongMatchTime
long getLastStrongMatchTime()
Get the last strong match check epoch time
-
Debug
static void Debug(String message)
Creates a Debug message in the debugger. If debugging is disabled, this will fail silently.
- Parameters:
message- A String value containing the debug message to record.
-
LogException
static void LogException(String message, Exception t)
-
loadPartnerParams
void loadPartnerParams(JSONObject body)
-
-
-
-