Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ dependencies {
implementation 'com.google.code.gson:gson:2.11.0'

// Courier Core SDK
api 'com.github.trycourier:courier-android:5.3.0'
api 'com.github.trycourier:courier-android:5.3.1'
api 'androidx.recyclerview:recyclerview:1.3.2'

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ class CourierInboxViewManager : SimpleViewManager<CourierInbox>() {
val dividerItemDecoration = android?.getString("dividerItemDecoration")

val brandId = getString("brandId")
val backgroundColor = getString("backgroundColor")

val tabIndicatorColor = getString("tabIndicatorColor")
val tabStyle = getMap("tabStyle")
Expand All @@ -139,6 +140,7 @@ class CourierInboxViewManager : SimpleViewManager<CourierInbox>() {

return CourierInboxTheme(
brandId = brandId,
backgroundColor = backgroundColor?.toColor(),
tabIndicatorColor = tabIndicatorColor?.toColor(),
tabStyle = tabStyle?.toTabStyle(context) ?: CourierStyles.Inbox.TabStyle(
selected = CourierStyles.Inbox.TabItemStyle(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class CourierPreferencesViewManager : SimpleViewManager<CourierPreferences>() {
private fun ReadableMap.toTheme(view: CourierPreferences): CourierPreferencesTheme {

val brandId = getString("brandId")
val backgroundColor = getString("backgroundColor")
val loadingIndicatorColor = getString("loadingIndicatorColor")
val sectionTitleFont = getMap("sectionTitleFont")
val topicTitleFont = getMap("topicTitleFont")
Expand All @@ -118,6 +119,7 @@ class CourierPreferencesViewManager : SimpleViewManager<CourierPreferences>() {

return CourierPreferencesTheme(
brandId = brandId,
backgroundColor = backgroundColor?.toColor(),
loadingIndicatorColor = loadingIndicatorColor?.toColor(),
sectionTitleFont = sectionTitleFont?.toFont(context) ?: defaultTheme.sectionTitleFont,
topicDividerItemDecoration = topicDividerItemDecoration?.toDivider(context),
Expand Down
2 changes: 1 addition & 1 deletion android/src/main/java/com/courierreactnative/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import com.facebook.react.modules.core.DeviceEventManagerModule
import com.google.gson.GsonBuilder

internal object Utils {
val COURIER_AGENT = CourierAgent.ReactNativeAndroid(version = "5.7.0")
val COURIER_AGENT = CourierAgent.ReactNativeAndroid(version = "5.7.1")
}

internal fun ReactContext.sendEvent(eventName: String, value: Any?) {
Expand Down
2 changes: 1 addition & 1 deletion courier-react-native.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Pod::Spec.new do |s|
s.source_files = "ios/**/*.{h,m,mm,swift}"

# Courier Core Dependency
s.dependency "Courier_iOS", "5.8.0"
s.dependency "Courier_iOS", "5.8.1"

# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
Expand Down
30 changes: 18 additions & 12 deletions example/src/AuthPreferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface AuthPreferencesData {
}

export async function loadAuthPreferences(): Promise<AuthPreferencesData> {
const results = await AsyncStorage.getMany([
const pairs = await AsyncStorage.multiGet([
KEYS.environment,
KEYS.userId,
KEYS.tenantId,
Expand All @@ -36,6 +36,11 @@ export async function loadAuthPreferences(): Promise<AuthPreferencesData> {
KEYS.inboxWebSocketUrl,
]);

const results: Record<string, string | null> = {};
for (const [key, value] of pairs) {
results[key] = value;
}

return {
environment:
(results[KEYS.environment] as CourierEnvironment) ??
Expand All @@ -54,19 +59,20 @@ export async function loadAuthPreferences(): Promise<AuthPreferencesData> {
export async function saveAuthPreferences(
data: Partial<AuthPreferencesData>
): Promise<void> {
const entries: Record<string, string> = {};
const pairs: [string, string][] = [];
if (data.environment !== undefined)
entries[KEYS.environment] = data.environment;
if (data.userId !== undefined) entries[KEYS.userId] = data.userId;
if (data.tenantId !== undefined) entries[KEYS.tenantId] = data.tenantId;
if (data.apiKey !== undefined) entries[KEYS.apiKey] = data.apiKey;
if (data.restUrl !== undefined) entries[KEYS.restUrl] = data.restUrl;
if (data.graphqlUrl !== undefined) entries[KEYS.graphqlUrl] = data.graphqlUrl;
pairs.push([KEYS.environment, data.environment]);
if (data.userId !== undefined) pairs.push([KEYS.userId, data.userId]);
if (data.tenantId !== undefined) pairs.push([KEYS.tenantId, data.tenantId]);
if (data.apiKey !== undefined) pairs.push([KEYS.apiKey, data.apiKey]);
if (data.restUrl !== undefined) pairs.push([KEYS.restUrl, data.restUrl]);
if (data.graphqlUrl !== undefined)
pairs.push([KEYS.graphqlUrl, data.graphqlUrl]);
if (data.inboxGraphqlUrl !== undefined)
entries[KEYS.inboxGraphqlUrl] = data.inboxGraphqlUrl;
pairs.push([KEYS.inboxGraphqlUrl, data.inboxGraphqlUrl]);
if (data.inboxWebSocketUrl !== undefined)
entries[KEYS.inboxWebSocketUrl] = data.inboxWebSocketUrl;
if (Object.keys(entries).length > 0) {
await AsyncStorage.setMany(entries);
pairs.push([KEYS.inboxWebSocketUrl, data.inboxWebSocketUrl]);
if (pairs.length > 0) {
await AsyncStorage.multiSet(pairs);
}
}
1 change: 1 addition & 0 deletions example/src/pages/Styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const Styles = (isDark: boolean) => {
Platform.OS === 'ios' ? 'Avenir Medium' : 'fonts/poppins_regular.otf',
},
Colors: {
background: isDark ? '#1C1C1E' : '#FFFFFF',
heading: isDark ? '#9747FF' : '#9747FF',
title: isDark ? '#FFFFFF' : '#000000',
subtitle: isDark ? '#9A9A9A' : '#BEBEBE',
Expand Down
1 change: 1 addition & 0 deletions example/src/pages/inbox/InboxStyled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const InboxStyled = () => {

return {
brandId: Env.brandId,
backgroundColor: styles.Colors.background,
tabIndicatorColor: styles.Colors.action,
tabStyle: {
selected: {
Expand Down
1 change: 1 addition & 0 deletions example/src/pages/preferences/PreferencesStyled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const PreferencesStyled = () => {

return {
brandId: Env.brandId,
backgroundColor: styles.Colors.background,
sectionTitleFont: {
family: styles.Fonts.heading,
size: styles.TextSizes.heading,
Expand Down
8 changes: 8 additions & 0 deletions ios/CourierInboxReactNativeManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ class CourierInboxView : UIView {
let lightTheme = theme?["light"] as? NSDictionary
let darkTheme = theme?["dark"] as? NSDictionary

let lightBgColor = (lightTheme?["backgroundColor"] as? String)?.toColor()
let darkBgColor = (darkTheme?["backgroundColor"] as? String)?.toColor()
if let bgColor = traitCollection.userInterfaceStyle == .dark ? darkBgColor ?? lightBgColor : lightBgColor ?? darkBgColor {
self.backgroundColor = bgColor
} else {
self.backgroundColor = nil
}

let courierInbox = CourierInbox(
canSwipePages: self.canSwipePages,
lightTheme: lightTheme?.toInboxTheme() ?? .defaultLight,
Expand Down
8 changes: 8 additions & 0 deletions ios/CourierPreferencesReactNativeManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ class CourierPreferencesView : UIView {
let lightTheme = theme?["light"] as? NSDictionary
let darkTheme = theme?["dark"] as? NSDictionary

let lightBgColor = (lightTheme?["backgroundColor"] as? String)?.toColor()
let darkBgColor = (darkTheme?["backgroundColor"] as? String)?.toColor()
if let bgColor = traitCollection.userInterfaceStyle == .dark ? darkBgColor ?? lightBgColor : lightBgColor ?? darkBgColor {
self.backgroundColor = bgColor
} else {
self.backgroundColor = nil
}

let courierPreferences = CourierPreferences(
mode: mode?.toMode() ?? .channels(CourierUserPreferencesChannel.allCases),
lightTheme: lightTheme?.toPreferencesTheme() ?? .defaultLight,
Expand Down
2 changes: 1 addition & 1 deletion ios/CourierReactNativeDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ - (id)init {
if (self) {

// Set the user agent
Courier.agent = [CourierAgent reactNativeIOS:@"5.7.0"];
Courier.agent = [CourierAgent reactNativeIOS:@"5.7.1"];

// Register for remote notifications
UIApplication *app = [UIApplication sharedApplication];
Expand Down
2 changes: 1 addition & 1 deletion ios/CourierReactNativeEventEmitter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal class CourierReactNativeEventEmitter: RCTEventEmitter {

// Set the user agent
// Used to know the platform performing requests
Courier.agent = CourierAgent.reactNativeIOS("5.7.0")
Courier.agent = CourierAgent.reactNativeIOS("5.7.1")

}

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@trycourier/courier-react-native",
"version": "5.7.0",
"version": "5.7.1",
"description": "Inbox, Push Notifications, and Preferences for React Native",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down
1 change: 1 addition & 0 deletions src/models/CourierInboxTheme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export interface CourierArchivingSwipeActionStyle {

export interface CourierInboxTheme {
brandId?: string;
backgroundColor?: string;
tabIndicatorColor?: string;
tabStyle?: CourierInboxTabStyle;
readingSwipeActionStyle?: CourierReadingSwipeActionStyle;
Expand Down
1 change: 1 addition & 0 deletions src/models/CourierPreferencesTheme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type CourierPreferencesMode =

export interface CourierPreferencesTheme {
brandId?: string;
backgroundColor?: string;
loadingIndicatorColor?: string;
sectionTitleFont?: CourierFont;
topicTitleFont?: CourierFont;
Expand Down
Loading