Modifier and Type | Method and Description |
---|---|
void |
changeUser(java.lang.String userId)
When you first start using Braze on a device, the user is considered "anonymous".
|
static void |
clearAppboyEndpointProvider()
Clear the currently set
IAppboyEndpointProvider |
void |
closeSession(android.app.Activity activity)
Closes the current session.
|
static boolean |
configure(android.content.Context context,
AppboyConfig config)
Optional static method to set configuration values for the Appboy singleton, overriding whatever values are
present in the appboy.xml.
|
Card |
deserializeContentCard(org.json.JSONObject contentCardJson)
Constructs a Content Card from its
Card.forJsonPut() output. |
Card |
deserializeContentCard(java.lang.String contentCardString)
Helper method for
IAppboy.deserializeContentCard(JSONObject) . |
IInAppMessage |
deserializeInAppMessageString(java.lang.String inAppMessageJsonString)
This function returns a deserialized in-app message from the message JSON string.
|
static void |
disableSdk(android.content.Context context)
Disables the Braze SDK.
|
static boolean |
enableMockAppboyNetworkRequestsAndDropEventsMode()
Testing utility method that enables mocking for all Braze SDK network requests, essentially turning the SDK "off".
|
static void |
enableSdk(android.content.Context context)
Enables the Braze SDK after an invocation of
disableSdk(Context) . |
static android.net.Uri |
getAppboyApiEndpoint(android.net.Uri appboyEndpoint)
If an
IAppboyEndpointProvider is configured, that provider's delegate is
used to generate the Uri for the Braze API endpoint. |
IAppboyImageLoader |
getAppboyImageLoader()
Returns the
IAppboyImageLoader for the Braze instance. |
java.lang.String |
getAppboyPushMessageRegistrationId()
Returns the FCM/ADM/Baidu 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.
|
static java.lang.String |
getConfiguredApiKey(android.content.Context context)
A helper method to determine if the SDK is configured with an API key.
|
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.
|
AppboyUser |
getCurrentUser()
Returns the user currently being tracked by Braze.
|
void |
getCurrentUser(IValueCallback<AppboyUser> completionCallback)
Returns the user currently being tracked by Braze.
|
static IAppboyNotificationFactory |
getCustomAppboyNotificationFactory()
Returns the currently set custom IAppboyNotificationFactory or null.
|
java.lang.String |
getDeviceId()
Get the device ID - a randomly generated, app specific ID that is stored on the device.
|
java.lang.String |
getInstallTrackingId()
Returns a unique device ID for install tracking.
|
static Appboy |
getInstance(android.content.Context context)
Static method that returns the Appboy singleton.
|
static boolean |
getOutboundNetworkRequestsOffline() |
void |
logContentCardsDisplayed()
Reports that Content Cards were displayed.
|
void |
logCustomEvent(java.lang.String eventName)
Reports a custom named event.
|
void |
logCustomEvent(java.lang.String eventNameInput,
AppboyProperties properties)
Reports a custom named event.
|
void |
logFeedCardClick(java.lang.String cardId) |
void |
logFeedCardImpression(java.lang.String cardId) |
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
IAppboy.logPurchase(String, String, BigDecimal, int) . |
void |
logPurchase(java.lang.String productId,
java.lang.String currencyCode,
java.math.BigDecimal price,
AppboyProperties properties)
In order to log a purchase, switch to
IAppboy.logPurchase(String, String, BigDecimal, int, AppboyProperties) . |
void |
logPurchase(java.lang.String productId,
java.lang.String currencyCode,
java.math.BigDecimal price,
int quantity)
In order to log a purchase, switch to
IAppboy.logPurchase(String, String, BigDecimal, int, AppboyProperties) . |
void |
logPurchase(java.lang.String productIdInput,
java.lang.String currencyCodeInput,
java.math.BigDecimal price,
int quantity,
AppboyProperties 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,
IAppboy.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.
|
<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.
|
static void |
setAppboyEndpointProvider(IAppboyEndpointProvider appboyEndpointProvider)
Sets an
IAppboyEndpointProvider to be used to route Braze API traffic
Note that if a custom endpoint is specified using AppboyConfig.Builder#setCustomEndpoint(String)
or via appboy.xml configuration, any IAppboyEndpointProvider previously set
using this method will be overridden when the Appboy singleton initializes. |
void |
setAppboyImageLoader(IAppboyImageLoader appboyImageLoader)
Sets the
IAppboyImageLoader for the Braze instance. |
static void |
setCustomAppboyNotificationFactory(IAppboyNotificationFactory customAppboyNotificationFactory)
Set a custom IAppboyNotificationFactory to be used to modify or create Braze push notifications.
|
void |
setGoogleAdvertisingId(java.lang.String googleAdvertisingId,
boolean limitAdTrackingEnabled)
Sets the Google Advertising ID and associated ad-tracking enabled field for this device.
|
static void |
setOutboundNetworkRequestsOffline(boolean isOffline)
Pauses or resumes outbound network requests from the Braze SDK at any point during runtime.
|
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 |
subscribeToSessionUpdates(IEventSubscriber<SessionStateChangedEvent> subscriber)
Subscribes to Session start and close events.
|
static void |
wipeData(android.content.Context context)
Hard resets all data created by the Braze SDK from the internal storage directory.
|
public static Appboy getInstance(android.content.Context context)
context
- Current contextpublic void openSession(android.app.Activity activity)
IAppboy
IAppboy.openSession(Activity)
within the session timeout of a call
to IAppboy.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.openSession
in interface IAppboy
activity
- The current Activity.public void closeSession(android.app.Activity activity)
IAppboy
IAppboy.openSession(Activity)
within the session timeout.closeSession
in interface IAppboy
activity
- The current Activity.public void logCustomEvent(java.lang.String eventName)
IAppboy
logCustomEvent
in interface IAppboy
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).public void logCustomEvent(java.lang.String eventNameInput, AppboyProperties properties)
IAppboy
logCustomEvent
in interface IAppboy
eventNameInput
- 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.public void logPurchase(java.lang.String productId, java.lang.String currencyCode, java.math.BigDecimal price)
IAppboy
IAppboy.logPurchase(String, String, BigDecimal, int)
. Using this
method will by default log a purchase with a quantity of one.logPurchase
in interface IAppboy
IAppboy.logPurchase(String, String, java.math.BigDecimal, int)
public void logPurchase(java.lang.String productId, java.lang.String currencyCode, java.math.BigDecimal price, AppboyProperties properties)
IAppboy
IAppboy.logPurchase(String, String, BigDecimal, int, AppboyProperties)
.
Using this method will by default log a purchase with a quantity of one.logPurchase
in interface IAppboy
IAppboy.logPurchase(String, String, java.math.BigDecimal, int, AppboyProperties)
public void logPurchase(java.lang.String productId, java.lang.String currencyCode, java.math.BigDecimal price, int quantity)
IAppboy
IAppboy.logPurchase(String, String, BigDecimal, int, AppboyProperties)
.logPurchase
in interface IAppboy
IAppboy.logPurchase(String, String, java.math.BigDecimal, int, AppboyProperties)
public void logPurchase(java.lang.String productIdInput, java.lang.String currencyCodeInput, java.math.BigDecimal price, int quantity, AppboyProperties properties)
IAppboy
logPurchase
in interface IAppboy
productIdInput
- The String identifier for the product purchased. Usually the Google Play SKU.currencyCodeInput
- 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.
public void logPushNotificationOpened(java.lang.String campaignId)
IAppboy
IAppboy.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.logPushNotificationOpened
in interface IAppboy
campaignId
- The ID of the campaign that triggered the push notification. This can be found as
an extra in the push notification intent.public void logPushNotificationOpened(android.content.Intent intent)
IAppboy
logPushNotificationOpened
in interface IAppboy
intent
- The push notification intent.public void logPushNotificationActionClicked(java.lang.String campaignId, java.lang.String actionId, java.lang.String actionType)
IAppboy
logPushNotificationActionClicked
in interface IAppboy
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
.public void logPushStoryPageClicked(java.lang.String campaignId, java.lang.String pageId)
IAppboy
logPushStoryPageClicked
in interface IAppboy
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.public void logContentCardsDisplayed()
IAppboy
logContentCardsDisplayed
in interface IAppboy
public void logFeedDisplayed()
IAppboy
logFeedDisplayed
in interface IAppboy
public void requestFeedRefreshFromCache()
IAppboy
IAppboy.requestFeedRefresh()
.requestFeedRefreshFromCache
in interface IAppboy
public void requestFeedRefresh()
IAppboy
requestFeedRefresh
in interface IAppboy
public void requestContentCardsRefresh(boolean fromCache)
IAppboy
IAppboy.subscribeToContentCardsUpdates(IEventSubscriber)
requestContentCardsRefresh
in interface IAppboy
fromCache
- whether to request data from offline storage.public void requestImmediateDataFlush()
IAppboy
requestImmediateDataFlush
in interface IAppboy
public void subscribeToNewInAppMessages(IEventSubscriber<InAppMessageEvent> subscriber)
IAppboy
InAppMessageEvent
.
IAppboy.removeSingleSubscription(com.appboy.events.IEventSubscriber, Class)
.
subscribeToNewInAppMessages
in interface IAppboy
subscriber
- A callback that should be executed when the news feed is updated.public void subscribeToContentCardsUpdates(IEventSubscriber<ContentCardsUpdatedEvent> subscriber)
IAppboy
ContentCardsUpdatedEvent
.
IAppboy.removeSingleSubscription(com.appboy.events.IEventSubscriber, Class)
.
subscribeToContentCardsUpdates
in interface IAppboy
subscriber
- A callback that will be executed when Content Cards are updated.public void subscribeToFeedUpdates(IEventSubscriber<FeedUpdatedEvent> subscriber)
IAppboy
FeedUpdatedEvent
.
IAppboy.removeSingleSubscription(com.appboy.events.IEventSubscriber, Class)
.
subscribeToFeedUpdates
in interface IAppboy
subscriber
- A callback that should be executed when the news feed is updated.public void subscribeToSessionUpdates(IEventSubscriber<SessionStateChangedEvent> subscriber)
IAppboy
SessionStateChangedEvent
.
IAppboy.removeSingleSubscription(com.appboy.events.IEventSubscriber, Class)
.
subscribeToSessionUpdates
in interface IAppboy
subscriber
- A callback that will be executed when a session is created or sealed.public void subscribeToNetworkFailures(IEventSubscriber<BrazeNetworkFailureEvent> subscriber)
IAppboy
subscribeToNetworkFailures
in interface IAppboy
subscriber
- A callback that will be executed when a network failure event has occurred.public <T> void removeSingleSubscription(IEventSubscriber<T> subscriber, java.lang.Class<T> eventClass)
IAppboy
removeSingleSubscription
in interface IAppboy
subscriber
- The callback which is currently subscribed.eventClass
- The Event class which this IEventSubscriber is subscribed to.public void changeUser(java.lang.String userId)
IAppboy
AppboyUser
can be retrieved at any time using IAppboy.getCurrentUser()
.changeUser
in interface IAppboy
userId
- An external user identifier. May not be longer than Constants.USER_ID_MAX_LENGTH_BYTES
.IAppboy.getCurrentUser()
public AppboyUser getCurrentUser()
IAppboy
AppboyUser
is available. Please use
IAppboy.getCurrentUser(IValueCallback)
for the asynchronous version of this method.getCurrentUser
in interface IAppboy
public void getCurrentUser(IValueCallback<AppboyUser> completionCallback)
IAppboy
IAppboy.getCurrentUser()
for the synchronous version of this method.getCurrentUser
in interface IAppboy
completionCallback
- that has IValueCallback.onSuccess(T)
called with a non-null AppboyUser
or IValueCallback.onError()
called otherwise.public void registerAppboyPushMessages(java.lang.String registrationId)
IAppboy
registerAppboyPushMessages
in interface IAppboy
registrationId
- The registration ID, or for apps integrating Baidu Cloud Push, the Baidu user idpublic java.lang.String getAppboyPushMessageRegistrationId()
IAppboy
getAppboyPushMessageRegistrationId
in interface IAppboy
public java.lang.String getInstallTrackingId()
IAppboy
getInstallTrackingId
in interface IAppboy
public IAppboyImageLoader getAppboyImageLoader()
IAppboy
IAppboyImageLoader
for the Braze instance.getAppboyImageLoader
in interface IAppboy
public void setAppboyImageLoader(IAppboyImageLoader appboyImageLoader)
IAppboy
IAppboyImageLoader
for the Braze instance. This IAppboyImageLoader
is used for all image relatedsetAppboyImageLoader
in interface IAppboy
appboyImageLoader
- The image loader to be set for the Braze instance. If null, then the existing image loader is unchanged.public int getContentCardCount()
IAppboy
getContentCardCount
in interface IAppboy
IAppboy.requestContentCardsRefresh(boolean)
public int getContentCardUnviewedCount()
IAppboy
getContentCardUnviewedCount
in interface IAppboy
IAppboy.requestContentCardsRefresh(boolean)
public long getContentCardsLastUpdatedInSecondsFromEpoch()
IAppboy
getContentCardsLastUpdatedInSecondsFromEpoch
in interface IAppboy
IAppboy.requestContentCardsRefresh(boolean)
public java.util.List<Card> getCachedContentCards()
IAppboy
getCachedContentCards
in interface IAppboy
public Card deserializeContentCard(java.lang.String contentCardString)
IAppboy
IAppboy.deserializeContentCard(JSONObject)
.deserializeContentCard
in interface IAppboy
contentCardString
- The string content of a Content Card's
JSONObject
obtained via JSONObject.toString()
.public Card deserializeContentCard(org.json.JSONObject contentCardJson)
IAppboy
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.deserializeContentCard
in interface IAppboy
contentCardJson
- The JSONObject
representation of a Content Card
as obtained via Card.forJsonPut()
.public void logFeedCardImpression(java.lang.String cardId)
logFeedCardImpression
in interface IAppboy
cardId
- The ID of the feed card.Card.logImpression()
public void logFeedCardClick(java.lang.String cardId)
logFeedCardClick
in interface IAppboy
cardId
- The ID of the feed card.Card.logClick()
public IInAppMessage deserializeInAppMessageString(java.lang.String inAppMessageJsonString)
IAppboy
deserializeInAppMessageString
in interface IAppboy
inAppMessageJsonString
- The in-app message JSON stringpublic void requestGeofences(double latitude, double longitude)
IAppboy
requestGeofences
in interface IAppboy
latitude
- A valid GPS latitude in range (-90, 90)longitude
- A valid GPS longitude in range (-180, 180)AppboyConfig.Builder#setAutomaticGeofenceRequestsEnabled(boolean)
,
ValidationUtils.isValidLocation(double, double)
public void setGoogleAdvertisingId(java.lang.String googleAdvertisingId, boolean limitAdTrackingEnabled)
IAppboy
setGoogleAdvertisingId
in interface IAppboy
googleAdvertisingId
- The Google Advertising ID.limitAdTrackingEnabled
- Whether ad-tracking is enabled for the Google Advertising ID.public java.lang.String getDeviceId()
changeUser(String)
calls.public static java.lang.String getConfiguredApiKey(android.content.Context context)
public static void setOutboundNetworkRequestsOffline(boolean isOffline)
isOffline
- If true, sets the SDK to offline and pauses all outbound network requests. If false,
all outbound network requests from the SDK are enabled.public static boolean getOutboundNetworkRequestsOffline()
setOutboundNetworkRequestsOffline(boolean)
public static void setAppboyEndpointProvider(IAppboyEndpointProvider appboyEndpointProvider)
IAppboyEndpointProvider
to be used to route Braze API traffic
Note that if a custom endpoint is specified using AppboyConfig.Builder#setCustomEndpoint(String)
or via appboy.xml configuration, any IAppboyEndpointProvider
previously set
using this method will be overridden when the Appboy singleton initializes.appboyEndpointProvider
- The IAppboyEndpointProvider that will return the URI for routing Braze trafficpublic static void clearAppboyEndpointProvider()
IAppboyEndpointProvider
public static android.net.Uri getAppboyApiEndpoint(android.net.Uri appboyEndpoint)
IAppboyEndpointProvider
is configured, that provider's delegate is
used to generate the Uri for the Braze API endpoint. Otherwise, return the Uri given.appboyEndpoint
- A Uri for a Braze API endpointpublic static void setCustomAppboyNotificationFactory(IAppboyNotificationFactory customAppboyNotificationFactory)
Application.onCreate()
method of your Application
class.customAppboyNotificationFactory
- The IAppboyNotificationFactory that will return the notification to be displayed.public static IAppboyNotificationFactory getCustomAppboyNotificationFactory()
public static boolean configure(android.content.Context context, AppboyConfig config)
context
- Application contextconfig
- An AppboyConfig to override any values in the `appboy.xml` configuration or from a
previously set AppboyConfigpublic static boolean enableMockAppboyNetworkRequestsAndDropEventsMode()
public static void disableSdk(android.content.Context context)
enableSdk(Context)
is called.
Appboy
should not be used. A new instance of getInstance(Context)
should be obtained after this call.
enableSdk(Context)
.public static void enableSdk(android.content.Context context)
disableSdk(Context)
. Note that the Braze SDK is enabled by default.
public static void wipeData(android.content.Context context)
Appboy
instance will be unusable after this call. Subsequent calls
to getInstance(Context)
will be usable.