BrazeNotificationUtils

Functions

Link copied to clipboard
fun cancelNotification(context: Context, notificationId: Int)

Creates a request to cancel a push notification in the notification center.

Link copied to clipboard

Returns an id for the new notification we'll send to the notification center. Notification id is used by the Android OS to override currently active notifications with identical ids. If a custom notification id is not defined in the payload, Braze derives an id value from the message's contents to prevent duplication in the notification center.

Link copied to clipboard

This method will retrieve notification priority from notificationExtras bundle if it has been set. Otherwise returns the default priority.

Link copied to clipboard

Returns the channel id for a valid NotificationChannel, creating one if necessary.

Link copied to clipboard
fun getValidNotificationChannel(notificationManager: NotificationManager, notificationExtras: Bundle?): NotificationChannel?

Returns an existing notification channel. The notification extras are first checked for a notification channel that exists. If not, then the default Braze notification channel is returned if it exists. If neither exist on the device, then null is returned.

Link copied to clipboard

Handles a request to cancel a push notification in the notification center. Called by BrazePushReceiver when a Braze cancel notification intent is received.

Parses the notification bundle for any associated ContentCards, if present. If found, the card object is added to card storage.

Link copied to clipboard

Handles a push notification deletion by the user. Called by BrazePushReceiver receiver when a Braze push notification delete intent is received.

Link copied to clipboard

Handles a push notification click. Called by BrazePushReceiver when a Braze push notification click intent is received.

Link copied to clipboard

Handles a push story page click. Called by BrazePushReceiver when an Braze push story click intent is received.

Link copied to clipboard

Checks the incoming notification intent to determine whether it is a Braze push message.

Link copied to clipboard

Checks the notification intent to determine whether this is a notification message or a silent push.

Link copied to clipboard

Returns true if the bundle is from a push sent by Braze for uninstall tracking. Uninstall tracking push can be ignored.

Link copied to clipboard

Checks whether the given integer value is a valid Android notification visibility constant.

Link copied to clipboard
fun logBaiduNotificationClick(context: Context?, customContentString: String?)

Logs a notification click with Braze if the extras passed down indicate that they are from Braze and contain a campaign Id.

Link copied to clipboard

Checks that the notification is a story that has only just been received. If so, each image within the story is put in the Braze image loader's cache.

Link copied to clipboard

Refreshes a feature flags refresh from Braze if appropriate based on the payload of the push notification. The SDK will respect the rate limit for feature flag refreshes.

Link copied to clipboard

Requests a geofence refresh from Braze if appropriate based on the payload of the push notification.

Link copied to clipboard

Opens any available deep links with an Intent.ACTION_VIEW intent, placing the main activity on the back stack. If no deep link is available, opens the main activity.

Link copied to clipboard

Sends a push notification opened broadcast to the client broadcast receiver.

Link copied to clipboard

Creates and sends a broadcast message that can be listened for by the host app. The broadcast message intent contains all of the data sent as part of the Braze push message.

Link copied to clipboard

Set accent color for devices on Lollipop and above. We use the push-specific accent color if it exists in the notificationExtras, otherwise we search for a default set in braze.xml or don't set the color at all (and the system notification gray default is used).

Link copied to clipboard

Set category for devices on Lollipop and above. Category is one of the predefined notification categories (see the CATEGORY_* constants in Notification) that best describes a Notification. May be used by the system for ranking and filtering.

Link copied to clipboard

Sets notification content if it exists in the payload.

Link copied to clipboard
fun setContentIntentIfPresent(context: Context, notificationBuilder: NotificationCompat.Builder, notificationExtras: Bundle?)

Create broadcast intent that will fire when the notification has been opened. BrazePushReceiver will be notified, log a click, then send a broadcast to the client receiver.

Link copied to clipboard
fun setDeleteIntent(context: Context, notificationBuilder: NotificationCompat.Builder, notificationExtras: Bundle?)
Link copied to clipboard

Set large icon. We use the large icon URL if it exists in the notificationExtras. Otherwise we search for a drawable defined in braze.xml. If that doesn't exists, we do nothing.

Link copied to clipboard

Sets the notification number, set via NotificationCompat.Builder.setNumber. On Android O, this number is used with notification badges.

Link copied to clipboard
fun setNotificationDurationAlarm(context: Context, thisClass: Class<*>?, notificationId: Int, durationInMillis: Int)

Creates an alarm which will issue a broadcast to cancel the notification specified by the given notificationId after the given duration.

Link copied to clipboard

Sets the priority of the notification if a priority is present in the notification extras.

Link copied to clipboard

Set the public version of the notification for notifications with private visibility.

Link copied to clipboard

This method exists to disable NotificationCompat.Builder.setShowWhen for push stories.

Link copied to clipboard
fun setSmallIcon(appConfigurationProvider: BrazeConfigurationProvider, notificationBuilder: NotificationCompat.Builder): Int

Sets the icon used in the notification bar itself. If a drawable defined in braze.xml is found, we use that. Otherwise, fall back to the application icon.

Link copied to clipboard

Notifications can optionally include a sound to play when the notification is delivered.

Link copied to clipboard

Sets the subText of the notification if a summary is present in the notification extras.

Link copied to clipboard

Sets notification ticker to the title if it exists in the payload.

Link copied to clipboard
Link copied to clipboard

Set visibility for devices on Lollipop and above.

Link copied to clipboard

This method will wake the device using a wake lock if the android.Manifest.permission.WAKE_LOCK permission is present in the manifest. If the permission is not present, this does nothing. If the screen is already on, and the permission is present, this does nothing. If the priority of the incoming notification is min, this does nothing.

fun wakeScreenIfAppropriate(context: Context, configurationProvider: BrazeConfigurationProvider, notificationExtras: Bundle?): Boolean

Properties

Link copied to clipboard

The Class of the notification receiver used by this application.