Modifier and Type | Method and Description |
---|---|
<T> void |
addSingleSynchronousSubscription(IEventSubscriber<T> subscriber,
java.lang.Class<T> eventClass)
Adds a new subscription for an external Braze SDK event.
|
void |
changeUser(java.lang.String userId)
When you first start using Braze on a device, the user is considered "anonymous".
|
void |
changeUser(java.lang.String userId,
java.lang.String sdkAuthSignature)
Identical to
changeUser(String) but provides an sdk
auth signature for the new user before any networking begins. |
void |
closeSession(android.app.Activity activity)
Closes the current session.
|
Card |
deserializeContentCard(org.json.JSONObject contentCardJson)
Constructs a Content Card from its
Card.forJsonPut() output. |
Card |
deserializeContentCard(java.lang.String contentCardString)
Helper method for
deserializeContentCard(JSONObject) . |
IInAppMessage |
deserializeInAppMessageString(java.lang.String inAppMessageString)
This function returns a deserialized in-app message from the message JSON string.
|
IAppboyImageLoader |
getAppboyImageLoader()
Deprecated.
Use
getImageLoader() |
java.lang.String |
getAppboyPushMessageRegistrationId()
Returns the FCM/ADM registration Id used to send the device push messages.
|
java.util.List<Card> |
getCachedContentCards()
Retrieves the offline/cached list of Content Cards from offline storage.
|
int |
getContentCardCount()
Retrieves information about Content Cards based on the currently cached data.
|
long |
getContentCardsLastUpdatedInSecondsFromEpoch()
Retrieves information about Content Cards based on the currently cached data.
|
int |
getContentCardUnviewedCount()
Retrieves information about Content Cards based on the currently cached data.
|
BrazeUser |
getCurrentUser()
Returns the user currently being tracked by Braze.
|
void |
getCurrentUser(IValueCallback<BrazeUser> completionCallback)
Returns the user currently being tracked by Braze.
|
java.lang.String |
getDeviceId()
Get the device ID - a randomly generated, app specific ID that is stored on the device.
|
IBrazeImageLoader |
getImageLoader()
Returns the
IBrazeImageLoader for the Braze instance. |
java.lang.String |
getInstallTrackingId()
Deprecated.
Use
getDeviceId() for equivalent functionality. Deprecated since May 2021 |
java.lang.String |
getRegisteredPushToken() |
void |
logContentCardsDisplayed()
Reports that Content Cards were displayed.
|
void |
logCustomEvent(java.lang.String eventName)
Reports a custom named event.
|
void |
logCustomEvent(java.lang.String eventName,
AppboyProperties properties) |
void |
logCustomEvent(java.lang.String eventName,
BrazeProperties properties)
Reports a custom named event.
|
void |
logFeedCardClick(java.lang.String cardId)
Deprecated.
Please call
Card.logClick() instead to log a click.
Reports a feed card was clicked. |
void |
logFeedCardImpression(java.lang.String cardId)
Deprecated.
Please call
Card.logImpression() instead to log an impression.
Reports a feed card was displayed to the user. Card impressions tracks how many times a card has been seen. Impressions should only be reported once the card becomes viewable to the user. Cards that are part of the stream but not visible should not log a card impression. If a card is viewed more than once in a particular view, it generates only one impression. If closed and reopened, a card will again generate an impression. |
void |
logFeedDisplayed()
Reports that the feed was displayed.
|
void |
logPurchase(java.lang.String productId,
java.lang.String currencyCode,
java.math.BigDecimal price)
In order to log a purchase, switch to
logPurchase(String, String, BigDecimal, int) . |
void |
logPurchase(java.lang.String productId,
java.lang.String currencyCode,
java.math.BigDecimal price,
AppboyProperties properties) |
void |
logPurchase(java.lang.String productId,
java.lang.String currencyCode,
java.math.BigDecimal price,
BrazeProperties properties)
In order to log a purchase, switch to
logPurchase(String, String, BigDecimal, int, BrazeProperties) . |
void |
logPurchase(java.lang.String productId,
java.lang.String currencyCode,
java.math.BigDecimal price,
int quantity)
In order to log a purchase, switch to
logPurchase(String, String, BigDecimal, int, BrazeProperties) . |
void |
logPurchase(java.lang.String productId,
java.lang.String currencyCode,
java.math.BigDecimal price,
int quantity,
AppboyProperties properties) |
void |
logPurchase(java.lang.String productId,
java.lang.String currencyCode,
java.math.BigDecimal price,
int quantity,
BrazeProperties properties)
Reports that the current user made an in app purchase.
|
void |
logPushNotificationActionClicked(java.lang.String campaignId,
java.lang.String actionId,
java.lang.String actionType)
Reports that the user clicked on a push notification action button.
|
void |
logPushNotificationOpened(android.content.Intent intent)
Reports that the user clicked on the push notification.
|
void |
logPushNotificationOpened(java.lang.String campaignId)
When possible,
logPushNotificationOpened(Intent) should be used instead. |
void |
logPushStoryPageClicked(java.lang.String campaignId,
java.lang.String pageId)
Reports that the user clicked on a push story page.
|
void |
openSession(android.app.Activity activity)
Opens a new session or resumes the previous session.
|
void |
registerAppboyPushMessages(java.lang.String registrationId)
Registers the device as eligible to receive push notifications from Braze.
|
void |
registerPushToken(java.lang.String pushToken)
Registers this device as eligible for receive push notifications
from Braze.
|
<T> void |
removeSingleSubscription(IEventSubscriber<T> subscriber,
java.lang.Class<T> eventClass)
Removes a single subscription associated with the given activity and event class.
|
void |
requestContentCardsRefresh(boolean fromCache)
Requests an immediate refresh of Content Cards.
|
void |
requestFeedRefresh()
Requests an immediate refresh of the news feed from the Braze server.
|
void |
requestFeedRefreshFromCache()
Requests a refresh of the news feed from offline storage.
|
void |
requestGeofences(double latitude,
double longitude)
Requests a refresh of Braze Geofences for the specified GPS coordinate.
|
void |
requestImmediateDataFlush()
Requests an immediate flush of any analytics data waiting to be sent to Appboy's servers.
|
void |
requestLocationInitialization()
Clients apps may call this method when location permissions are granted to request immediate
initialization of geofences as appropriate.
|
void |
setAppboyImageLoader(IAppboyImageLoader appboyImageLoader)
Deprecated.
|
void |
setGoogleAdvertisingId(java.lang.String googleAdvertisingId,
boolean isLimitAdTrackingEnabled)
Sets the Google Advertising ID and associated ad-tracking enabled field for this device.
|
void |
setImageLoader(IBrazeImageLoader brazeImageLoader)
Sets the
IBrazeImageLoader for the Braze instance. |
void |
setSdkAuthenticationSignature(java.lang.String signature)
Sets the signature used for SDK authentication
for the currently identified user.
|
void |
subscribeToContentCardsUpdates(IEventSubscriber<ContentCardsUpdatedEvent> subscriber)
Subscribes to Content Cards events.
|
void |
subscribeToFeedUpdates(IEventSubscriber<FeedUpdatedEvent> subscriber)
Subscribes to news feed events.
|
void |
subscribeToNetworkFailures(IEventSubscriber<BrazeNetworkFailureEvent> subscriber)
Subscribes to network failures that have occurred within the SDK.
|
void |
subscribeToNewInAppMessages(IEventSubscriber<InAppMessageEvent> subscriber)
Subscribes to in-app message events.
|
void |
subscribeToSdkAuthenticationFailures(IEventSubscriber<BrazeSdkAuthenticationErrorEvent> subscriber)
Subscribes to SDK Authentication failures.
|
void |
subscribeToSessionUpdates(IEventSubscriber<SessionStateChangedEvent> subscriber)
Subscribes to Session start and close events.
|
void openSession(android.app.Activity activity)
openSession(Activity)
within the session timeout of a call
to closeSession(Activity)
will cause the previous session to be
resumed. This is done so that transitions from one Activity to another do not
create a new session each time.activity
- The current Activity.void closeSession(android.app.Activity activity)
openSession(Activity)
within the session timeout.activity
- The current Activity.void logCustomEvent(java.lang.String eventName)
eventName
- The String identifier for the event to track. Best practice is to track generic
events useful for segmenting, instead of specific user actions (i.e. track
watched_sports_video instead of watched_video_adrian_peterson_td_mnf).void logCustomEvent(java.lang.String eventName, AppboyProperties properties)
for the preferred method to use.
void logCustomEvent(java.lang.String eventName, BrazeProperties properties)
eventName
- The String identifier for the event to track. Best practice is to track generic
events useful for segmenting, instead of specific user actions (i.e. track
watched_sports_video instead of watched_video_adrian_peterson_td_mnf).properties
- An object containing key-value properties describing this event. Property names
are non-empty strings <= 255 characters, with no leading dollar signs.void logPurchase(java.lang.String productId, java.lang.String currencyCode, java.math.BigDecimal price)
logPurchase(String, String, BigDecimal, int)
. Using this
method will by default log a purchase with a quantity of one.void logPurchase(java.lang.String productId, java.lang.String currencyCode, java.math.BigDecimal price, BrazeProperties properties)
logPurchase(String, String, BigDecimal, int, BrazeProperties)
.
Using this method will by default log a purchase with a quantity of one.void logPurchase(java.lang.String productId, java.lang.String currencyCode, java.math.BigDecimal price, AppboyProperties properties)
for the preferred method to use.
void logPurchase(java.lang.String productId, java.lang.String currencyCode, java.math.BigDecimal price, int quantity)
logPurchase(String, String, BigDecimal, int, BrazeProperties)
.void logPurchase(java.lang.String productId, java.lang.String currencyCode, java.math.BigDecimal price, int quantity, BrazeProperties properties)
productId
- The String identifier for the product purchased. Usually the Google Play SKU.currencyCode
- Currencies should be represented as an ISO 4217 currency code. Supported
currency symbols include: AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN,
BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTC, BTN, BWP, BYR,
BZD, CAD, CDF, CHF, CLF, CLP, CNY, COP, CRC, CUC, CUP, CVE, CZK, DJF, DKK,
DOP, DZD, EEK, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GGP, GHS, GIP, GMD,
GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, IMP, INR, IQD, IRR, ISK,
JEP, JMD, JOD, JPY, KES, KGS, KHR, KMF, KPW, KRW, KWD, KYD, KZT, LAK, LBP,
LKR, LRD, LSL, LTL, LVL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRO, MTL,
MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN,
PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK,
SGD, SHP, SLL, SOS, SRD, STD, SVC, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY,
TTD, TWD, TZS, UAH, UGX, USD, UYU, UZS, VEF, VND, VUV, WST, XAF, XAG, XAU,
XCD, XDR, XOF, XPD, XPF, XPT, YER, ZAR, ZMK, ZMW and ZWL.
Any other provided currency symbol will result in a logged warning and no other action taken by the SDK.
price
- The price paid. Base units depend on the currency. As an example, USD should be
reported as Dollars.Cents, whereas JPY should be reported as a whole number of Yen.
All provided BigDecimal values will have RoundingMode.HALF_UP rounding applied
such that a maximum of two digits exist after the decimal point. May be negative.quantity
- The quantity of items purchased expressed as a whole number. Must be greater
than zero.properties
- A map of key-value properties describing this purchase. Property names
are non-empty strings <= 255 characters, with no leading dollar signs.
Property values can be integers, floats, booleans, datetimes
(of the formats "%FT%T%z", "%Y-%m-%d %H:%M:%S", "%Y-%m-%d", "%m/%d/%Y"),
or strings <= 255 characters.
Note: The productId and currencyCode are trimmed of any whitespace characters before being
sent to Braze.
Note: Querying the Google Play store for SKU details may return the price of a in-app purchases
in micros. Therefore, a purchase of price 0.99USD will be returned as 9900000. To pass
this value to Braze, be sure to convert it to a BigDecimal before attempting to convert
it from micros to a decimal value in order to avoid integer division rounding errors.
BigDecimal priceInMicro = new BigDecimal(9900000L);
BigDecimal priceInDecimal = priceInMicro.divide(new BigDecimal(10e6));
void logPurchase(java.lang.String productId, java.lang.String currencyCode, java.math.BigDecimal price, int quantity, AppboyProperties properties)
for the preferred method to use.
void logPushNotificationOpened(java.lang.String campaignId)
logPushNotificationOpened(Intent)
should be used instead. Note that
integrations shouldn't be calling this method directly.
Reports that the user clicked on the push notification.
campaignId
- The ID of the campaign that triggered the push notification. This can be found as
an extra in the push notification intent.void logPushNotificationOpened(android.content.Intent intent)
intent
- The push notification intent.void logPushNotificationActionClicked(java.lang.String campaignId, java.lang.String actionId, java.lang.String actionType)
campaignId
- The ID of the campaign that triggered the push notification. This can be found as
an extra in the push notification intent.actionId
- The ID of the action button that was clicked.actionType
- The action type from the intent's string extra under Constants.APPBOY_ACTION_TYPE_KEY
.void logPushStoryPageClicked(java.lang.String campaignId, java.lang.String pageId)
campaignId
- The ID of the campaign that triggered the push notification. This can be found as
an extra in the push notification intent.pageId
- The ID of the push story page that was clicked.void logContentCardsDisplayed()
void logFeedDisplayed()
void requestContentCardsRefresh(boolean fromCache)
subscribeToContentCardsUpdates(IEventSubscriber)
fromCache
- whether to request data from offline storage.void requestFeedRefresh()
void requestFeedRefreshFromCache()
requestFeedRefresh()
.void requestImmediateDataFlush()
void subscribeToContentCardsUpdates(IEventSubscriber<ContentCardsUpdatedEvent> subscriber)
ContentCardsUpdatedEvent
.
removeSingleSubscription(com.appboy.events.IEventSubscriber, Class)
.
subscriber
- A callback that will be executed when Content Cards are updated.void subscribeToFeedUpdates(IEventSubscriber<FeedUpdatedEvent> subscriber)
FeedUpdatedEvent
.
removeSingleSubscription(com.appboy.events.IEventSubscriber, Class)
.
subscriber
- A callback that should be executed when the news feed is updated.void subscribeToNewInAppMessages(IEventSubscriber<InAppMessageEvent> subscriber)
InAppMessageEvent
.
removeSingleSubscription(com.appboy.events.IEventSubscriber, Class)
.
subscriber
- A callback that should be executed when the news feed is updated.void subscribeToSessionUpdates(IEventSubscriber<SessionStateChangedEvent> subscriber)
SessionStateChangedEvent
.
removeSingleSubscription(com.appboy.events.IEventSubscriber, Class)
.
subscriber
- A callback that will be executed when a session is created or sealed.void subscribeToNetworkFailures(IEventSubscriber<BrazeNetworkFailureEvent> subscriber)
subscriber
- A callback that will be executed when a network failure event has occurred.void subscribeToSdkAuthenticationFailures(IEventSubscriber<BrazeSdkAuthenticationErrorEvent> subscriber)
subscriber
- A callback that will be executed when an SDK authentication failure has occurred.<T> void addSingleSynchronousSubscription(IEventSubscriber<T> subscriber, java.lang.Class<T> eventClass)
subscriber
- The subscriber callback to fire for the given event class.eventClass
- The subscribed event class.<T> void removeSingleSubscription(IEventSubscriber<T> subscriber, java.lang.Class<T> eventClass)
subscriber
- The callback which is currently subscribed.eventClass
- The Event class which this IEventSubscriber is subscribed to.void changeUser(java.lang.String userId)
BrazeUser
can be retrieved at any time using getCurrentUser()
.userId
- An external user identifier. May not be longer than Constants.USER_ID_MAX_LENGTH_BYTES
.getCurrentUser()
void changeUser(java.lang.String userId, java.lang.String sdkAuthSignature)
changeUser(String)
but provides an sdk
auth signature for the new user before any networking begins. Otherwise,
the existing auth signature will be used.changeUser(String)
BrazeUser getCurrentUser()
BrazeUser
is available. Please use
getCurrentUser(IValueCallback)
for the asynchronous version of this method.void getCurrentUser(IValueCallback<BrazeUser> completionCallback)
getCurrentUser()
for the synchronous version of this method.completionCallback
- that has IValueCallback.onSuccess(T)
called with a non-null BrazeUser
or IValueCallback.onError()
called otherwise.void registerAppboyPushMessages(java.lang.String registrationId)
For FCM/ADM applications, this takes the FCM/ADM registration ID to send the device FCM/ADM messages. The registration ID is flushed immediately.
registrationId
- The registration IDfor the updated usage of this method.
void registerPushToken(java.lang.String pushToken)
pushToken
- The push notification registration token.java.lang.String getAppboyPushMessageRegistrationId()
for the updated usage of this method.
java.lang.String getRegisteredPushToken()
@Deprecated java.lang.String getInstallTrackingId()
getDeviceId()
for equivalent functionality. Deprecated since May 2021@Deprecated IAppboyImageLoader getAppboyImageLoader()
getImageLoader()
IBrazeImageLoader getImageLoader()
IBrazeImageLoader
for the Braze instance.@Deprecated void setAppboyImageLoader(IAppboyImageLoader appboyImageLoader)
setImageLoader(IBrazeImageLoader)
void setImageLoader(IBrazeImageLoader brazeImageLoader)
IBrazeImageLoader
for the Braze instance.
This IBrazeImageLoader
is used for all image relatedbrazeImageLoader
- The image loader to be set for the Braze instance. If null,
then the existing image loader is unchanged.int getContentCardCount()
Note that this method is synchronous and will block the current running thread.
requestContentCardsRefresh(boolean)
int getContentCardUnviewedCount()
Note that this method is synchronous and will block the current running thread.
requestContentCardsRefresh(boolean)
long getContentCardsLastUpdatedInSecondsFromEpoch()
Note that this method is synchronous and will block the current running thread.
requestContentCardsRefresh(boolean)
java.util.List<Card> getCachedContentCards()
void setGoogleAdvertisingId(java.lang.String googleAdvertisingId, boolean isLimitAdTrackingEnabled)
googleAdvertisingId
- The Google Advertising ID.isLimitAdTrackingEnabled
- Whether ad-tracking is enabled for the Google Advertising ID.IInAppMessage deserializeInAppMessageString(java.lang.String inAppMessageString)
inAppMessageString
- The in-app message JSON stringCard deserializeContentCard(java.lang.String contentCardString)
deserializeContentCard(JSONObject)
.contentCardString
- The string content of a Content Card's
JSONObject
obtained via JSONObject.toString()
.Card deserializeContentCard(org.json.JSONObject contentCardJson)
Card.forJsonPut()
output. Useful for caching Content Card
data and recreating them for your own purposes.
Card
. I.e. clicks and
impressions can be logged on the returned object.contentCardJson
- The JSONObject
representation of a Content Card
as obtained via Card.forJsonPut()
.void requestLocationInitialization()
void requestGeofences(double latitude, double longitude)
latitude
- A valid GPS latitude in range (-90, 90)longitude
- A valid GPS longitude in range (-180, 180)BrazeConfig.Builder.setAutomaticGeofenceRequestsEnabled(boolean)
,
ValidationUtils.isValidLocation(double, double)
java.lang.String getDeviceId()
Appboy.changeUser(String)
calls.@Deprecated void logFeedCardImpression(java.lang.String cardId)
Card.logImpression()
instead to log an impression.
cardId
- The ID of the feed card.Card.logImpression()
@Deprecated void logFeedCardClick(java.lang.String cardId)
Card.logClick()
instead to log a click.
cardId
- The ID of the feed card.Card.logClick()
void setSdkAuthenticationSignature(java.lang.String signature)
signature
- SDK Authentication signature