-
- All Implemented Interfaces:
-
android.os.Parcelable
public class BranchUniversalObject implements Parcelable
Class represents a single piece of content within your app, as well as any associated metadata. It provides convenient methods for sharing, deep linking, and tracking how often that content is viewed. This information is then used to provide you with powerful content analytics and deep linking.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public enumBranchUniversalObject.CONTENT_INDEX_MODEDefines the Content indexing modesPUBLIC | PRIVATE
public interfaceBranchUniversalObject.RegisterViewStatusListenerCallback interface for listening register content view status
-
Field Summary
Fields Modifier and Type Field Description public final static Parcelable.CreatorCREATOR
-
Constructor Summary
Constructors Constructor Description BranchUniversalObject()Create a BranchUniversalObject with the given content.
-
Method Summary
Modifier and Type Method Description BranchUniversalObjectsetCanonicalIdentifier(@NonNull() String canonicalIdentifier)Set the canonical identifier for this BranchUniversalObject. BranchUniversalObjectsetCanonicalUrl(@NonNull() String canonicalUrl)Canonical url for the content referred. BranchUniversalObjectsetTitle(@NonNull() String title)Set a title for the content referred by this object BranchUniversalObjectsetContentDescription(String description)Set description for the content for the content referred by this object BranchUniversalObjectsetContentImageUrl(@NonNull() String imageUrl)Set the url to any image associated with this content. BranchUniversalObjectaddContentMetadata(HashMap<String, String> metadata)BranchUniversalObjectaddContentMetadata(String key, String value)BranchUniversalObjectsetContentMetadata(ContentMetadata metadata)Set the metadata associated with the content. BranchUniversalObjectsetContentType(String type)BranchUniversalObjectsetContentIndexingMode(BranchUniversalObject.CONTENT_INDEX_MODE indexMode)Set the indexing mode for the content referred in this object BranchUniversalObjectsetLocalIndexMode(BranchUniversalObject.CONTENT_INDEX_MODE localIndexMode)Set the Local indexing mode for the content referred in this object.NOTE: The locally indexable contents are added to the local indexing services , if supported, when listing the contents on Google or other content indexing services. BranchUniversalObjectaddKeyWords(ArrayList<String> keywords)Adds any keywords associated with the content referred BranchUniversalObjectaddKeyWord(String keyword)Add a keyword associated with the content referred BranchUniversalObjectsetContentExpiration(Date expirationDate)Set the content expiration time. BranchUniversalObjectsetPrice(double price, CurrencyType currency)Set the price associated with content of this BUO if any voidlistOnGoogleSearch(Context context)Publish this BUO with Google app indexing so that the contents will be available with google searchwith branch link pointing to the app. voidlistOnGoogleSearch(Context context, LinkProperties linkProperties)Publish this BUO with Google app indexing so that the contents will be available with google searchwith branch link pointing to the app. voidremoveFromLocalIndexing(Context context)Remove the BUO from the local indexing if it is added to the local indexing alreadyThis will remove the content from Google(Firebase) and other supported Indexing services voidremoveFromLocalIndexing(Context context, LinkProperties linkProperties)Remove the BUO from the local indexing if it is added to the local indexing alreadyThis will remove the content from Google(Firebase) and other supported Indexing servicesThis method takes additional LinkProperties parameter. voiduserCompletedAction(String action)Method to report user actions happened on this BUO. voiduserCompletedAction(BRANCH_STANDARD_EVENT action)Method to report user actions happened on this BUO. voiduserCompletedAction(String action, HashMap<String, String> metadata)Method to report user actions happened on this BUO. voiduserCompletedAction(BRANCH_STANDARD_EVENT action, HashMap<String, String> metadata)Method to report user actions happened on this BUO. booleanisPublicallyIndexable()Specifies whether the contents referred by this object is publically indexable booleanisLocallyIndexable()Specifies whether the contents referred by this object is locally indexable HashMap<String, String>getMetadata()ContentMetadatagetContentMetadata()Get the ContentMetadata associated with this BUO which holds the metadata for content represented longgetExpirationTime()Get expiry date for the content and any associated links. StringgetCanonicalIdentifier()Get the canonical identifier for this BranchUniversalObject StringgetCanonicalUrl()Get the canonical url for this BranchUniversalObject StringgetDescription()Get description for the content for the content referred by this object StringgetImageUrl()Get the url to any image associated with this content. StringgetTitle()Get a title for the content referred by this object StringgetType()doublegetPrice()Gets the price associated with this BUO content StringgetCurrencyType()Get the currency type of the price for this BUO JSONArraygetKeywordsJsonArray()Get the keywords associated with this BranchUniversalObject ArrayList<String>getKeywords()Get the keywords associated with this BranchUniversalObject voidregisterView()Mark the content referred by this object as viewed. voidregisterView(@Nullable() BranchUniversalObject.RegisterViewStatusListener callback)Mark the content referred by this object as viewed. StringgetShortUrl(@NonNull() Context context, @NonNull() LinkProperties linkProperties)Creates a short url for the BUO synchronously. StringgetShortUrl(@NonNull() Context context, @NonNull() LinkProperties linkProperties, boolean defaultToLongUrl)Creates a short url for the BUO synchronously. voidgenerateShortUrl(@NonNull() Context context, @NonNull() LinkProperties linkProperties, @Nullable() Branch.BranchLinkCreateListener callback)Creates a short url for the BUO asynchronously voidgenerateShortUrl(@NonNull() Context context, @NonNull() LinkProperties linkProperties, @Nullable() Branch.BranchLinkCreateListener callback, boolean defaultToLongUrl)Creates a short url for the BUO asynchronously. voidshowShareSheet(@NonNull() Activity activity, @NonNull() LinkProperties linkProperties, @NonNull() ShareSheetStyle style, @Nullable() Branch.BranchLinkShareListener callback)voidshowShareSheet(@NonNull() Activity activity, @NonNull() LinkProperties linkProperties, @NonNull() ShareSheetStyle style, @Nullable() Branch.BranchLinkShareListener callback, Branch.IChannelProperties channelProperties)static BranchUniversalObjectgetReferredBranchUniversalObject()Get the BranchUniversalObject associated with the latest deep linking. static BranchUniversalObjectcreateInstance(JSONObject jsonObject)Creates a new BranchUniversalObject with the data provided by JSONObject. JSONObjectconvertToJson()Convert the BUO to corresponding Json representation intdescribeContents()voidwriteToParcel(Parcel dest, int flags)-
-
Method Detail
-
setCanonicalIdentifier
BranchUniversalObject setCanonicalIdentifier(@NonNull() String canonicalIdentifier)
Set the canonical identifier for this BranchUniversalObject. Canonical identifier is normally the canonical path for your content in the application or web
- Parameters:
canonicalIdentifier- A String with value for the canonical identifier
-
setCanonicalUrl
BranchUniversalObject setCanonicalUrl(@NonNull() String canonicalUrl)
Canonical url for the content referred. This would be the corresponding website URL.
- Parameters:
canonicalUrl- A String with value for the canonical url
-
setTitle
BranchUniversalObject setTitle(@NonNull() String title)
Set a title for the content referred by this object
- Parameters:
title- A String with value of for the content title
-
setContentDescription
BranchUniversalObject setContentDescription(String description)
Set description for the content for the content referred by this object
- Parameters:
description- A String with value for the description of the content referred by this object
-
setContentImageUrl
BranchUniversalObject setContentImageUrl(@NonNull() String imageUrl)
Set the url to any image associated with this content.
- Parameters:
imageUrl- A String specifying a url to an image associated with content referred by this object
-
addContentMetadata
BranchUniversalObject addContentMetadata(HashMap<String, String> metadata)
-
addContentMetadata
BranchUniversalObject addContentMetadata(String key, String value)
-
setContentMetadata
BranchUniversalObject setContentMetadata(ContentMetadata metadata)
Set the metadata associated with the content. Please see ContentMetadata
- Parameters:
metadata- Instance of ContentMetadata.
-
setContentType
BranchUniversalObject setContentType(String type)
-
setContentIndexingMode
BranchUniversalObject setContentIndexingMode(BranchUniversalObject.CONTENT_INDEX_MODE indexMode)
Set the indexing mode for the content referred in this object
- Parameters:
indexMode- BranchUniversalObject.CONTENT_INDEX_MODE value for the content referred
-
setLocalIndexMode
BranchUniversalObject setLocalIndexMode(BranchUniversalObject.CONTENT_INDEX_MODE localIndexMode)
Set the Local indexing mode for the content referred in this object.NOTE: The locally indexable contents are added to the local indexing services , if supported, when listing the contents on Google or other content indexing services.So please make sure you are marking local index mode to PRIVATE if you don't want to list the contents locally on device
- Parameters:
localIndexMode- BranchUniversalObject.CONTENT_INDEX_MODE value for the content referred
-
addKeyWords
BranchUniversalObject addKeyWords(ArrayList<String> keywords)
Adds any keywords associated with the content referred
-
addKeyWord
BranchUniversalObject addKeyWord(String keyword)
Add a keyword associated with the content referred
- Parameters:
keyword- AString with value for keyword
-
setContentExpiration
BranchUniversalObject setContentExpiration(Date expirationDate)
Set the content expiration time.
- Parameters:
expirationDate- A Date value representing the expiration date.
-
setPrice
BranchUniversalObject setPrice(double price, CurrencyType currency)
Set the price associated with content of this BUO if any
- Parameters:
price- A Double value specifying the price info associated with BUOcurrency- ISO 4217 currency code defined in CurrencyType for the price
-
listOnGoogleSearch
void listOnGoogleSearch(Context context)
Publish this BUO with Google app indexing so that the contents will be available with google searchwith branch link pointing to the app.
- Parameters:
context- Application context
-
listOnGoogleSearch
void listOnGoogleSearch(Context context, LinkProperties linkProperties)
Publish this BUO with Google app indexing so that the contents will be available with google searchwith branch link pointing to the app. This method takes additional LinkProperties parameter to configure the link settings for your link that is indexed
- Parameters:
context- Application context
-
removeFromLocalIndexing
void removeFromLocalIndexing(Context context)
Remove the BUO from the local indexing if it is added to the local indexing alreadyThis will remove the content from Google(Firebase) and other supported Indexing services
- Parameters:
context- Application context
-
removeFromLocalIndexing
void removeFromLocalIndexing(Context context, LinkProperties linkProperties)
Remove the BUO from the local indexing if it is added to the local indexing alreadyThis will remove the content from Google(Firebase) and other supported Indexing servicesThis method takes additional LinkProperties parameter. Use this method if you indexed the content using listOnGoogleSearch methodotherwise use removeFromLocalIndexing
- Parameters:
context- Application context
-
userCompletedAction
void userCompletedAction(String action)
Method to report user actions happened on this BUO. Use this method to report the user actions for analytics purpose.
- Parameters:
action- A Stringwith value of user action name.
-
userCompletedAction
void userCompletedAction(BRANCH_STANDARD_EVENT action)
Method to report user actions happened on this BUO. Use this method to report the user actions for analytics purpose.
- Parameters:
action- A BRANCH_STANDARD_EVENTwith value of user action name.
-
userCompletedAction
void userCompletedAction(String action, HashMap<String, String> metadata)
Method to report user actions happened on this BUO. Use this method to report the user actions for analytics purpose.
- Parameters:
action- A Stringwith value of user action name.metadata- A HashMap containing any additional metadata need to add to this user eventNOTE : please consider using userCompletedAction instead
-
userCompletedAction
void userCompletedAction(BRANCH_STANDARD_EVENT action, HashMap<String, String> metadata)
Method to report user actions happened on this BUO. Use this method to report the user actions for analytics purpose.
- Parameters:
action- A BRANCH_STANDARD_EVENTwith value of user action name.metadata- A HashMap containing any additional metadata need to add to this user event
-
isPublicallyIndexable
boolean isPublicallyIndexable()
Specifies whether the contents referred by this object is publically indexable
-
isLocallyIndexable
boolean isLocallyIndexable()
Specifies whether the contents referred by this object is locally indexable
-
getMetadata
HashMap<String, String> getMetadata()
-
getContentMetadata
ContentMetadata getContentMetadata()
Get the ContentMetadata associated with this BUO which holds the metadata for content represented
-
getExpirationTime
long getExpirationTime()
Get expiry date for the content and any associated links. Represented as epoch milli second
-
getCanonicalIdentifier
String getCanonicalIdentifier()
Get the canonical identifier for this BranchUniversalObject
-
getCanonicalUrl
String getCanonicalUrl()
Get the canonical url for this BranchUniversalObject
-
getDescription
String getDescription()
Get description for the content for the content referred by this object
-
getImageUrl
String getImageUrl()
Get the url to any image associated with this content.
-
getPrice
double getPrice()
Gets the price associated with this BUO content
-
getCurrencyType
String getCurrencyType()
Get the currency type of the price for this BUO
-
getKeywordsJsonArray
JSONArray getKeywordsJsonArray()
Get the keywords associated with this BranchUniversalObject
-
getKeywords
ArrayList<String> getKeywords()
Get the keywords associated with this BranchUniversalObject
-
registerView
void registerView()
Mark the content referred by this object as viewed. This increment the view count of the contents referred by this object.
-
registerView
void registerView(@Nullable() BranchUniversalObject.RegisterViewStatusListener callback)
Mark the content referred by this object as viewed. This increment the view count of the contents referred by this object.
- Parameters:
callback- An instance of RegisterViewStatusListener to listen to results of the operation
-
getShortUrl
String getShortUrl(@NonNull() Context context, @NonNull() LinkProperties linkProperties)
Creates a short url for the BUO synchronously.
- Parameters:
context- Context instancelinkProperties- An object of LinkProperties specifying the properties of this link
-
getShortUrl
String getShortUrl(@NonNull() Context context, @NonNull() LinkProperties linkProperties, boolean defaultToLongUrl)
Creates a short url for the BUO synchronously.
- Parameters:
context- Context instancelinkProperties- An object of LinkProperties specifying the properties of this linkdefaultToLongUrl- A specifies if a long url should be returned in case of link creation errorIf set to false, NULL is returned in case of link creation error
-
generateShortUrl
void generateShortUrl(@NonNull() Context context, @NonNull() LinkProperties linkProperties, @Nullable() Branch.BranchLinkCreateListener callback)
Creates a short url for the BUO asynchronously
- Parameters:
context- Context instancelinkProperties- An object of LinkProperties specifying the properties of this linkcallback- An instance of io.branch.referral.Branch.BranchLinkCreateListener to receive the results
-
generateShortUrl
void generateShortUrl(@NonNull() Context context, @NonNull() LinkProperties linkProperties, @Nullable() Branch.BranchLinkCreateListener callback, boolean defaultToLongUrl)
Creates a short url for the BUO asynchronously.
- Parameters:
context- Context instancelinkProperties- An object of LinkProperties specifying the properties of this linkcallback- An instance of io.branch.referral.Branch.BranchLinkCreateListener to receive the resultsdefaultToLongUrl- A specifies if a long url should be returned in case of link creation errorIf set to false, NULL is returned in case of link creation error
-
showShareSheet
void showShareSheet(@NonNull() Activity activity, @NonNull() LinkProperties linkProperties, @NonNull() ShareSheetStyle style, @Nullable() Branch.BranchLinkShareListener callback)
-
showShareSheet
void showShareSheet(@NonNull() Activity activity, @NonNull() LinkProperties linkProperties, @NonNull() ShareSheetStyle style, @Nullable() Branch.BranchLinkShareListener callback, Branch.IChannelProperties channelProperties)
-
getReferredBranchUniversalObject
static BranchUniversalObject getReferredBranchUniversalObject()
Get the BranchUniversalObject associated with the latest deep linking. This should retrieve theexact object used for creating the deep link. This should be called only after initialising Branch Session.
-
createInstance
static BranchUniversalObject createInstance(JSONObject jsonObject)
Creates a new BranchUniversalObject with the data provided by JSONObject.
- Parameters:
jsonObject- JSONObject to create the BranchUniversalObject
-
convertToJson
JSONObject convertToJson()
Convert the BUO to corresponding Json representation
-
describeContents
int describeContents()
-
writeToParcel
void writeToParcel(Parcel dest, int flags)
-
-
-
-