public class BranchUniversalObject
extends java.lang.Object
implements android.os.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.
Modifier and Type | Class and Description |
---|---|
static class |
BranchUniversalObject.CONTENT_INDEX_MODE
Defines the Content indexing modes
PUBLIC | PRIVATE
|
static interface |
BranchUniversalObject.RegisterViewStatusListener
Callback interface for listening register content view status
|
Modifier and Type | Field and Description |
---|---|
static android.os.Parcelable.Creator |
CREATOR |
Constructor and Description |
---|
BranchUniversalObject()
Create a BranchUniversalObject with the given content.
|
Modifier and Type | Method and Description |
---|---|
BranchUniversalObject |
addContentMetadata(java.util.HashMap<java.lang.String,java.lang.String> metadata)
Deprecated.
please use #setContentMetadata instead
|
BranchUniversalObject |
addContentMetadata(java.lang.String key,
java.lang.String value)
Deprecated.
please use #setContentMetadata instead
|
BranchUniversalObject |
addKeyWord(java.lang.String keyword)
Add a keyword associated with the content referred
|
BranchUniversalObject |
addKeyWords(java.util.ArrayList<java.lang.String> keywords)
Adds any keywords associated with the content referred
|
org.json.JSONObject |
convertToJson()
Convert the BUO to corresponding Json representation
|
static BranchUniversalObject |
createInstance(org.json.JSONObject jsonObject)
Creates a new BranchUniversalObject with the data provided by
JSONObject . |
int |
describeContents() |
void |
generateShortUrl(android.content.Context context,
LinkProperties linkProperties,
Branch.BranchLinkCreateListener callback)
Creates a short url for the BUO asynchronously
|
void |
generateShortUrl(android.content.Context context,
LinkProperties linkProperties,
Branch.BranchLinkCreateListener callback,
boolean defaultToLongUrl)
Creates a short url for the BUO asynchronously.
|
java.lang.String |
getCanonicalIdentifier()
Get the canonical identifier for this BranchUniversalObject
|
java.lang.String |
getCanonicalUrl()
Get the canonical url for this BranchUniversalObject
|
ContentMetadata |
getContentMetadata()
Get the
ContentMetadata associated with this BUO which holds the metadata for content represented |
java.lang.String |
getCurrencyType()
Deprecated.
Please check
BranchEvent for more info on commerce event tracking with Branch |
java.lang.String |
getDescription()
Get description for the content for the content referred by this object
|
long |
getExpirationTime()
Get expiry date for the content and any associated links.
|
java.lang.String |
getImageUrl()
Get the url to any image associated with this content.
|
java.util.ArrayList<java.lang.String> |
getKeywords()
Get the keywords associated with this
BranchUniversalObject |
org.json.JSONArray |
getKeywordsJsonArray()
Get the keywords associated with this
BranchUniversalObject |
java.util.HashMap<java.lang.String,java.lang.String> |
getMetadata()
Deprecated.
Please use #getContentMetadata() instead.
|
double |
getPrice()
Deprecated.
please use
ContentMetadata.price instead |
static BranchUniversalObject |
getReferredBranchUniversalObject()
Get the
BranchUniversalObject associated with the latest deep linking. |
java.lang.String |
getShortUrl(android.content.Context context,
LinkProperties linkProperties)
Creates a short url for the BUO synchronously.
|
java.lang.String |
getShortUrl(android.content.Context context,
LinkProperties linkProperties,
boolean defaultToLongUrl)
Creates a short url for the BUO synchronously.
|
java.lang.String |
getTitle()
Get a title for the content referred by this object
|
java.lang.String |
getType()
Deprecated.
please use
ContentMetadata.contentSchema |
boolean |
isLocallyIndexable()
Specifies whether the contents referred by this object is locally indexable
|
boolean |
isPublicallyIndexable()
Specifies whether the contents referred by this object is publically indexable
|
void |
listOnGoogleSearch(android.content.Context context)
Publish this BUO with Google app indexing so that the contents will be available with google search
with branch link pointing to the app.
|
void |
listOnGoogleSearch(android.content.Context context,
LinkProperties linkProperties)
Publish this BUO with Google app indexing so that the contents will be available with google search
with branch link pointing to the app.
|
void |
registerView()
Mark the content referred by this object as viewed.
|
void |
registerView(BranchUniversalObject.RegisterViewStatusListener callback)
Mark the content referred by this object as viewed.
|
void |
removeFromLocalIndexing(android.content.Context context)
Remove the BUO from the local indexing if it is added to the local indexing already
This will remove the content from Google(Firebase) and other supported Indexing services
|
void |
removeFromLocalIndexing(android.content.Context context,
LinkProperties linkProperties)
Remove the BUO from the local indexing if it is added to the local indexing already
This will remove the content from Google(Firebase) and other supported Indexing services
This method takes additional
LinkProperties parameter. |
BranchUniversalObject |
setCanonicalIdentifier(java.lang.String canonicalIdentifier)
Set the canonical identifier for this BranchUniversalObject.
|
BranchUniversalObject |
setCanonicalUrl(java.lang.String canonicalUrl)
Canonical url for the content referred.
|
BranchUniversalObject |
setContentDescription(java.lang.String description)
Set description for the content for the content referred by this object
|
BranchUniversalObject |
setContentExpiration(java.util.Date expirationDate)
Set the content expiration time.
|
BranchUniversalObject |
setContentImageUrl(java.lang.String imageUrl)
Set the url to any image associated with this content.
|
BranchUniversalObject |
setContentIndexingMode(BranchUniversalObject.CONTENT_INDEX_MODE indexMode)
Set the indexing mode for the content referred in this object
|
BranchUniversalObject |
setContentMetadata(ContentMetadata metadata)
Set the metadata associated with the content.
|
BranchUniversalObject |
setContentType(java.lang.String type)
Deprecated.
Please use
ContentMetadata.contentSchema .
Please see setContentMetadata(ContentMetadata) |
BranchUniversalObject |
setLocalIndexMode(BranchUniversalObject.CONTENT_INDEX_MODE localIndexMode)
Set the Local indexing mode for the content referred in this object.
|
BranchUniversalObject |
setPrice(double price,
CurrencyType currency)
Deprecated.
use
ContentMetadata.price instead. Please check BranchEvent for more info on commerce event tracking with Branch |
BranchUniversalObject |
setTitle(java.lang.String title)
Set a title for the content referred by this object
|
void |
showShareSheet(android.app.Activity activity,
LinkProperties linkProperties,
ShareSheetStyle style,
Branch.BranchLinkShareListener callback) |
void |
showShareSheet(android.app.Activity activity,
LinkProperties linkProperties,
ShareSheetStyle style,
Branch.BranchLinkShareListener callback,
Branch.IChannelProperties channelProperties) |
void |
userCompletedAction(BRANCH_STANDARD_EVENT action)
Method to report user actions happened on this BUO.
|
void |
userCompletedAction(BRANCH_STANDARD_EVENT action,
java.util.HashMap<java.lang.String,java.lang.String> metadata)
Method to report user actions happened on this BUO.
|
void |
userCompletedAction(java.lang.String action)
Method to report user actions happened on this BUO.
|
void |
userCompletedAction(java.lang.String action,
java.util.HashMap<java.lang.String,java.lang.String> metadata)
Method to report user actions happened on this BUO.
|
void |
writeToParcel(android.os.Parcel dest,
int flags) |
public BranchUniversalObject()
Create a BranchUniversalObject with the given content.
public BranchUniversalObject setCanonicalIdentifier(java.lang.String canonicalIdentifier)
Set the canonical identifier for this BranchUniversalObject. Canonical identifier is normally the canonical path for your content in the application or web
canonicalIdentifier
- A String
with value for the canonical identifierpublic BranchUniversalObject setCanonicalUrl(java.lang.String canonicalUrl)
Canonical url for the content referred. This would be the corresponding website URL.
canonicalUrl
- A String
with value for the canonical urlpublic BranchUniversalObject setTitle(java.lang.String title)
Set a title for the content referred by this object
title
- A String
with value of for the content titlepublic BranchUniversalObject setContentDescription(java.lang.String description)
Set description for the content for the content referred by this object
description
- A String
with value for the description of the content referred by this objectpublic BranchUniversalObject setContentImageUrl(java.lang.String imageUrl)
Set the url to any image associated with this content.
imageUrl
- A String
specifying a url to an image associated with content referred by this objectpublic BranchUniversalObject addContentMetadata(java.util.HashMap<java.lang.String,java.lang.String> metadata)
public BranchUniversalObject addContentMetadata(java.lang.String key, java.lang.String value)
public BranchUniversalObject setContentMetadata(ContentMetadata metadata)
ContentMetadata
metadata
- Instance of ContentMetadata
. Holds the metadata for the contents of this BUOpublic BranchUniversalObject setContentType(java.lang.String type)
ContentMetadata.contentSchema
.
Please see setContentMetadata(ContentMetadata)
public BranchUniversalObject setContentIndexingMode(BranchUniversalObject.CONTENT_INDEX_MODE indexMode)
Set the indexing mode for the content referred in this object
indexMode
- BranchUniversalObject.CONTENT_INDEX_MODE
value for the content referredpublic 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 BranchUniversalObject.CONTENT_INDEX_MODE.PRIVATE
if you don't want to list the contents locally on device
localIndexMode
- BranchUniversalObject.CONTENT_INDEX_MODE
value for the content referredpublic BranchUniversalObject addKeyWords(java.util.ArrayList<java.lang.String> keywords)
Adds any keywords associated with the content referred
keywords
- An ArrayList
of String
valuespublic BranchUniversalObject addKeyWord(java.lang.String keyword)
Add a keyword associated with the content referred
keyword
- AString
with value for keywordpublic BranchUniversalObject setContentExpiration(java.util.Date expirationDate)
Set the content expiration time.
expirationDate
- A Date
value representing the expiration date.public BranchUniversalObject setPrice(double price, CurrencyType currency)
ContentMetadata.price
instead. Please check BranchEvent
for more info on commerce event tracking with BranchSet the price associated with content of this BUO if any
price
- A Double
value specifying the price info associated with BUOcurrency
- ISO 4217 currency code defined in CurrencyType
for the pricepublic void listOnGoogleSearch(android.content.Context context)
Publish this BUO with Google app indexing so that the contents will be available with google search with branch link pointing to the app.
context
- Application contextpublic void listOnGoogleSearch(android.content.Context context, LinkProperties linkProperties)
Publish this BUO with Google app indexing so that the contents will be available with google search
with branch link pointing to the app. This method takes additional LinkProperties
parameter to configure the link settings for your link that is indexed
context
- Application contextpublic void removeFromLocalIndexing(android.content.Context context)
context
- Application contextpublic void removeFromLocalIndexing(android.content.Context context, LinkProperties linkProperties)
LinkProperties
parameter. Use this method if you indexed the content using listOnGoogleSearch(Context, LinkProperties)
method
otherwise use removeFromLocalIndexing(Context)
context
- Application contextpublic void userCompletedAction(java.lang.String action)
Method to report user actions happened on this BUO. Use this method to report the user actions for analytics purpose.
action
- A String
with value of user action name. See BranchEvent
for Branch defined user events.
NOTE : please consider using userCompletedAction(BRANCH_STANDARD_EVENT)
insteadpublic 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.
action
- A BRANCH_STANDARD_EVENT
with value of user action name. See BRANCH_STANDARD_EVENT
for Branch defined user events.public void userCompletedAction(java.lang.String action, java.util.HashMap<java.lang.String,java.lang.String> metadata)
Method to report user actions happened on this BUO. Use this method to report the user actions for analytics purpose.
action
- A String
with value of user action name. See BranchEvent
for Branch defined user events.metadata
- A HashMap containing any additional metadata need to add to this user event
NOTE : please consider using userCompletedAction(BRANCH_STANDARD_EVENT, HashMap)
insteadpublic void userCompletedAction(BRANCH_STANDARD_EVENT action, java.util.HashMap<java.lang.String,java.lang.String> metadata)
Method to report user actions happened on this BUO. Use this method to report the user actions for analytics purpose.
action
- A BRANCH_STANDARD_EVENT
with value of user action name. See BRANCH_STANDARD_EVENT
for Branch defined user events.metadata
- A HashMap containing any additional metadata need to add to this user eventpublic boolean isPublicallyIndexable()
Specifies whether the contents referred by this object is publically indexable
boolean
whose value is set to true if index mode is publicpublic boolean isLocallyIndexable()
Specifies whether the contents referred by this object is locally indexable
boolean
whose value is set to true if index mode is publicpublic java.util.HashMap<java.lang.String,java.lang.String> getMetadata()
public ContentMetadata getContentMetadata()
ContentMetadata
associated with this BUO which holds the metadata for content representedContentMetadata
object representing the content metadatapublic long getExpirationTime()
Get expiry date for the content and any associated links. Represented as epoch milli second
Long
with content expiration time in epoch millisecondspublic java.lang.String getCanonicalIdentifier()
Get the canonical identifier for this BranchUniversalObject
String
with value for the canonical identifierpublic java.lang.String getCanonicalUrl()
Get the canonical url for this BranchUniversalObject
String
with value for the canonical urlpublic java.lang.String getDescription()
Get description for the content for the content referred by this object
String
with value for the description of the content referred by this objectpublic java.lang.String getImageUrl()
Get the url to any image associated with this content.
String
specifying a url to an image associated with content referred by this objectpublic java.lang.String getTitle()
Get a title for the content referred by this object
String
with value of for the content titlepublic java.lang.String getType()
ContentMetadata.contentSchema
public double getPrice()
ContentMetadata.price
insteadGets the price associated with this BUO content
Double
with value for price of the content of BUOpublic java.lang.String getCurrencyType()
BranchEvent
for more info on commerce event tracking with BranchGet the currency type of the price for this BUO
String
with ISO 4217 for this currency. Empty string if there is no currency type setpublic org.json.JSONArray getKeywordsJsonArray()
BranchUniversalObject
JSONArray
with keywords associated with this BranchUniversalObject
public java.util.ArrayList<java.lang.String> getKeywords()
BranchUniversalObject
ArrayList
with keywords associated with this BranchUniversalObject
public void registerView()
public void registerView(BranchUniversalObject.RegisterViewStatusListener callback)
callback
- An instance of BranchUniversalObject.RegisterViewStatusListener
to listen to results of the operationpublic java.lang.String getShortUrl(android.content.Context context, LinkProperties linkProperties)
context
- Context
instancelinkProperties
- An object of LinkProperties
specifying the properties of this linkString
with value of the short url created for this BUO. A long url for the BUO is returned in case link creation failspublic java.lang.String getShortUrl(android.content.Context context, LinkProperties linkProperties, boolean defaultToLongUrl)
context
- Context
instancelinkProperties
- An object of LinkProperties
specifying the properties of this linkdefaultToLongUrl
- A boolean
specifies if a long url should be returned in case of link creation error
If set to false, NULL is returned in case of link creation errorString
with value of the short url created for this BUO. NULL is returned in case link creation failspublic void generateShortUrl(android.content.Context context, LinkProperties linkProperties, Branch.BranchLinkCreateListener callback)
context
- Context
instancelinkProperties
- An object of LinkProperties
specifying the properties of this linkcallback
- An instance of Branch.BranchLinkCreateListener
to receive the resultspublic void generateShortUrl(android.content.Context context, LinkProperties linkProperties, Branch.BranchLinkCreateListener callback, boolean defaultToLongUrl)
context
- Context
instancelinkProperties
- An object of LinkProperties
specifying the properties of this linkcallback
- An instance of Branch.BranchLinkCreateListener
to receive the resultsdefaultToLongUrl
- A boolean
specifies if a long url should be returned in case of link creation error
If set to false, NULL is returned in case of link creation errorpublic void showShareSheet(android.app.Activity activity, LinkProperties linkProperties, ShareSheetStyle style, Branch.BranchLinkShareListener callback)
public void showShareSheet(android.app.Activity activity, LinkProperties linkProperties, ShareSheetStyle style, Branch.BranchLinkShareListener callback, Branch.IChannelProperties channelProperties)
public static BranchUniversalObject getReferredBranchUniversalObject()
BranchUniversalObject
associated with the latest deep linking. This should retrieve the
exact object used for creating the deep link. This should be called only after initialising Branch Session.BranchUniversalObject
used to create the deep link that started the this app session.
Null is returned if this session is not started by Branch link clickpublic static BranchUniversalObject createInstance(org.json.JSONObject jsonObject)
JSONObject
.jsonObject
- JSONObject
to create the BranchUniversalObjectBranchUniversalObject
corresponding to the Json data passed inpublic org.json.JSONObject convertToJson()
JSONObject
which represent this BUOpublic int describeContents()
describeContents
in interface android.os.Parcelable
public void writeToParcel(android.os.Parcel dest, int flags)
writeToParcel
in interface android.os.Parcelable