Package 

Class PrefHelper


  • 
    public class PrefHelper
    
                        

    A 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.

    • Method Detail

      • 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.

      • 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.
      • 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.
      • 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.
      • 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.
      • 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.
      • 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
      • 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
      • 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
      • 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.
      • setGoogleSearchInstallIdentifier

         void setGoogleSearchInstallIdentifier(String identifier)

        Sets the Google install referrer identifier to the pref

        Parameters:
        identifier - Google install referrer identifier
      • setAppStoreReferrer

         void setAppStoreReferrer(String referrer)

        Sets the app store install referrer string

        Parameters:
        referrer - App store install referrer string
      • 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

      • 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.
      • 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.
      • setUserURL

         void setUserURL(String user_url)

        Sets the user URL from preferences.

        Parameters:
        user_url - A String value containing the current user URL.
      • 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.

      • 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.

        Parameters:
        action - - A String value containing the name of the action to return thecount for.
        count - - An Integer value containing the total number of times that thespecified action has been carried out during the current session.
      • 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.

        Parameters:
        action - A String value containing the name of the action to return thecount for.
        count - An Integer value containing the total number of times that thespecified action has been carried out during the current session.
      • 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
      • setInitialReferrer

         void setInitialReferrer(String initialReferrer)

        Persist the android.intent.extra.REFERRER value

        Parameters:
        initialReferrer - android.intent.extra.
      • 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.

        Parameters:
        key - A String value containing the key to reference.
        defaultValue - An Integer specifying the value to use if the preferences valueis 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.

        Parameters:
        key - A String value containing the key to reference.
        value - An Integer value to set the preference record to.
      • setLong

         void setLong(String key, long value)

        Sets the value of the String key value supplied in preferences.

        Parameters:
        key - A String value containing the key to reference.
        value - A Long value to set the preference record to.
      • setFloat

         void setFloat(String key, float value)

        Sets the value of the String key value supplied in preferences.

        Parameters:
        key - A String value containing the key to reference.
        value - A Float value to set the preference record to.
      • setString

         void setString(String key, String value)

        Sets the value of the String key value supplied in preferences.

        Parameters:
        key - A String value containing the key to reference.
        value - A String value to set the preference record to.
      • setBool

         void setBool(String key, Boolean value)

        Sets the value of the String key value supplied in preferences.

        Parameters:
        key - A String value containing the key to reference.
        value - A Boolean value to set the preference record to.
      • saveLastStrongMatchTime

         void saveLastStrongMatchTime(long strongMatchCheckTime)

        Saves the last strong match epoch time stamp

        Parameters:
        strongMatchCheckTime - epoch time stamp for last strong match
      • 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.