Skip to content

Latest commit

 

History

History
149 lines (118 loc) · 4.5 KB

Preferences.md

File metadata and controls

149 lines (118 loc) · 4.5 KB
android-preferences-banner

Courier Preferences

In-app notification settings that allow your users to customize which of your notifications they receive. Allows you to build high quality, flexible preference settings very quickly.

Requirements

Requirement Reason
Authentication Needed to view preferences that belong to a user.

Default Preferences View

The default CourierPreferences styles.

default-inbox-styles
// Get the view by id
val preferences: CourierPreferences = view.findViewById(R.id.courierPreferences)

// Set the mode and listen to errors
preferences.apply {
    mode = CourierPreferences.Mode.Topic
    onError = { e ->
        print(e)
    }
}

Styled Preferences View

The styles you can use to quickly customize the CourierPreferences.

default-inbox-styles
val preferences: CourierPreferences = view.findViewById(R.id.courierPreferences)

preferences.apply {
    
    val availableChannels = listOf(
        CourierPreferenceChannel.PUSH,
        CourierPreferenceChannel.SMS,
        CourierPreferenceChannel.EMAIL
    )
    
    mode = CourierPreferences.Mode.Channels(availableChannels)
    
    onError = { e ->
        print(e)
    }
    
}

val font = ResourcesCompat.getFont(requireContext(), R.font.poppins)
val purple500 = ContextCompat.getColor(requireContext(), R.color.courier_purple)
val purple200 = ContextCompat.getColor(requireContext(), R.color.purple_200)
val grey500 = ContextCompat.getColor(requireContext(), android.R.color.darker_gray)

val theme = CourierPreferencesTheme(
    brandId = "7S9RBWHHS9MBYRPSRYAFYF9K3Q1M", // Optional
    loadingIndicatorColor = purple500,
    sectionTitleFont = CourierStyles.Font(
        typeface = font,
        color = purple500,
        sizeInSp = 22,
    ),
    topicDividerItemDecoration = DividerItemDecoration(context, DividerItemDecoration.VERTICAL),
    topicTitleFont = CourierStyles.Font(
        typeface = font,
    ),
    topicSubtitleFont = CourierStyles.Font(
        typeface = font,
        color = grey500,
    ),
    sheetTitleFont = CourierStyles.Font(
        typeface = font,
        color = purple500,
        sizeInSp = 22,
    ),
    sheetDividerItemDecoration = DividerItemDecoration(context, DividerItemDecoration.VERTICAL),
    sheetSettingStyles = CourierStyles.Preferences.SettingStyles(
        font = CourierStyles.Font(
            typeface = font,
        ),
        toggleThumbColor = purple500,
        toggleTrackColor = purple200,
    )
)

preferences.lightTheme = theme
preferences.darkTheme = theme

Courier Studio Branding (Optional)

setting

You can control your branding from the Courier Studio.

Supported Brand Styles Support
Primary Color
Show/Hide Courier Footer

👋 Branding APIs can be found here

👋 Preference APIs can be found here