@trycourier/courier-react-native 5.6.17 → 5.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (226) hide show
  1. package/README.md +66 -135
  2. package/android/build.gradle +1 -1
  3. package/android/src/main/java/com/courierreactnative/CourierClientModule.kt +1 -0
  4. package/android/src/main/java/com/courierreactnative/CourierInboxViewManager.kt +2 -0
  5. package/android/src/main/java/com/courierreactnative/CourierPreferencesViewManager.kt +2 -0
  6. package/android/src/main/java/com/courierreactnative/CourierSharedModule.kt +3 -0
  7. package/android/src/main/java/com/courierreactnative/Utils.kt +11 -1
  8. package/courier-react-native.podspec +1 -1
  9. package/ios/CourierClientModule.swift +1 -0
  10. package/ios/CourierInboxReactNativeManager.swift +8 -0
  11. package/ios/CourierPreferencesReactNativeManager.swift +8 -0
  12. package/ios/CourierReactNativeDelegate.m +1 -1
  13. package/ios/CourierReactNativeEventEmitter.swift +1 -1
  14. package/ios/CourierReactNativeModule.m +1 -0
  15. package/ios/CourierSharedModule.swift +10 -3
  16. package/ios/Utils.swift +10 -0
  17. package/lib/commonjs/Broadcaster.js +5 -5
  18. package/lib/commonjs/Broadcaster.js.map +1 -1
  19. package/lib/commonjs/CourierApiUrls.js +29 -0
  20. package/lib/commonjs/CourierApiUrls.js.map +1 -0
  21. package/lib/commonjs/Modules.js.map +1 -1
  22. package/lib/commonjs/client/BrandClient.js.map +1 -1
  23. package/lib/commonjs/client/ClientModule.js.map +1 -1
  24. package/lib/commonjs/client/CourierClient.js +4 -1
  25. package/lib/commonjs/client/CourierClient.js.map +1 -1
  26. package/lib/commonjs/client/InboxClient.js.map +1 -1
  27. package/lib/commonjs/client/PreferenceClient.js.map +1 -1
  28. package/lib/commonjs/client/TokenClient.js.map +1 -1
  29. package/lib/commonjs/client/TrackingClient.js.map +1 -1
  30. package/lib/commonjs/index.js +22 -2
  31. package/lib/commonjs/index.js.map +1 -1
  32. package/lib/commonjs/models/CourierAuthenticationListener.js.map +1 -1
  33. package/lib/commonjs/models/CourierPushListener.js.map +1 -1
  34. package/lib/commonjs/models/CourierUserPreferences.js +13 -13
  35. package/lib/commonjs/models/CourierUserPreferences.js.map +1 -1
  36. package/lib/commonjs/models/InboxAction.js.map +1 -1
  37. package/lib/commonjs/models/InboxMessage.js.map +1 -1
  38. package/lib/commonjs/utils.js.map +1 -1
  39. package/lib/commonjs/views/CourierInboxView.js +13 -13
  40. package/lib/commonjs/views/CourierInboxView.js.map +1 -1
  41. package/lib/commonjs/views/CourierPreferencesView.js +4 -4
  42. package/lib/commonjs/views/CourierPreferencesView.js.map +1 -1
  43. package/lib/module/Broadcaster.js +7 -7
  44. package/lib/module/Broadcaster.js.map +1 -1
  45. package/lib/module/CourierApiUrls.js +20 -0
  46. package/lib/module/CourierApiUrls.js.map +1 -0
  47. package/lib/module/Modules.js +1 -1
  48. package/lib/module/Modules.js.map +1 -1
  49. package/lib/module/client/BrandClient.js +1 -1
  50. package/lib/module/client/BrandClient.js.map +1 -1
  51. package/lib/module/client/ClientModule.js +1 -1
  52. package/lib/module/client/ClientModule.js.map +1 -1
  53. package/lib/module/client/CourierClient.js +10 -7
  54. package/lib/module/client/CourierClient.js.map +1 -1
  55. package/lib/module/client/InboxClient.js +1 -1
  56. package/lib/module/client/InboxClient.js.map +1 -1
  57. package/lib/module/client/PreferenceClient.js +1 -1
  58. package/lib/module/client/PreferenceClient.js.map +1 -1
  59. package/lib/module/client/TokenClient.js +1 -1
  60. package/lib/module/client/TokenClient.js.map +1 -1
  61. package/lib/module/client/TrackingClient.js +1 -1
  62. package/lib/module/client/TrackingClient.js.map +1 -1
  63. package/lib/module/index.js +5 -2
  64. package/lib/module/index.js.map +1 -1
  65. package/lib/module/models/CourierAuthenticationListener.js +1 -1
  66. package/lib/module/models/CourierAuthenticationListener.js.map +1 -1
  67. package/lib/module/models/CourierInboxListener.js +1 -1
  68. package/lib/module/models/CourierPushListener.js.map +1 -1
  69. package/lib/module/models/CourierUserPreferences.js +13 -13
  70. package/lib/module/models/CourierUserPreferences.js.map +1 -1
  71. package/lib/module/models/InboxAction.js.map +1 -1
  72. package/lib/module/models/InboxMessage.js +1 -1
  73. package/lib/module/models/InboxMessage.js.map +1 -1
  74. package/lib/module/utils.js.map +1 -1
  75. package/lib/module/views/CourierInboxView.js +18 -18
  76. package/lib/module/views/CourierInboxView.js.map +1 -1
  77. package/lib/module/views/CourierPreferencesView.js +7 -7
  78. package/lib/module/views/CourierPreferencesView.js.map +1 -1
  79. package/lib/typescript/src/Broadcaster.d.ts +7 -7
  80. package/lib/typescript/src/Broadcaster.d.ts.map +1 -1
  81. package/lib/typescript/src/CourierApiUrls.d.ts +11 -0
  82. package/lib/typescript/src/CourierApiUrls.d.ts.map +1 -0
  83. package/lib/typescript/src/Modules.d.ts.map +1 -1
  84. package/lib/typescript/src/client/BrandClient.d.ts +1 -1
  85. package/lib/typescript/src/client/BrandClient.d.ts.map +1 -1
  86. package/lib/typescript/src/client/ClientModule.d.ts +1 -1
  87. package/lib/typescript/src/client/ClientModule.d.ts.map +1 -1
  88. package/lib/typescript/src/client/CourierClient.d.ts +9 -6
  89. package/lib/typescript/src/client/CourierClient.d.ts.map +1 -1
  90. package/lib/typescript/src/client/InboxClient.d.ts +1 -1
  91. package/lib/typescript/src/client/InboxClient.d.ts.map +1 -1
  92. package/lib/typescript/src/client/PreferenceClient.d.ts +1 -1
  93. package/lib/typescript/src/client/PreferenceClient.d.ts.map +1 -1
  94. package/lib/typescript/src/client/TokenClient.d.ts +1 -1
  95. package/lib/typescript/src/client/TokenClient.d.ts.map +1 -1
  96. package/lib/typescript/src/client/TrackingClient.d.ts +1 -1
  97. package/lib/typescript/src/client/TrackingClient.d.ts.map +1 -1
  98. package/lib/typescript/src/index.d.ts +6 -2
  99. package/lib/typescript/src/index.d.ts.map +1 -1
  100. package/lib/typescript/src/models/Android_CourierSheet.d.ts +1 -1
  101. package/lib/typescript/src/models/Android_CourierSheet.d.ts.map +1 -1
  102. package/lib/typescript/src/models/CourierAuthenticationListener.d.ts +1 -1
  103. package/lib/typescript/src/models/CourierAuthenticationListener.d.ts.map +1 -1
  104. package/lib/typescript/src/models/CourierBrand.d.ts.map +1 -1
  105. package/lib/typescript/src/models/CourierButton.d.ts +1 -1
  106. package/lib/typescript/src/models/CourierButton.d.ts.map +1 -1
  107. package/lib/typescript/src/models/CourierFont.d.ts.map +1 -1
  108. package/lib/typescript/src/models/CourierInboxListener.d.ts +1 -1
  109. package/lib/typescript/src/models/CourierInboxMessages.d.ts +1 -1
  110. package/lib/typescript/src/models/CourierInboxTheme.d.ts +4 -3
  111. package/lib/typescript/src/models/CourierInboxTheme.d.ts.map +1 -1
  112. package/lib/typescript/src/models/CourierInfoViewStyle.d.ts +2 -2
  113. package/lib/typescript/src/models/CourierInfoViewStyle.d.ts.map +1 -1
  114. package/lib/typescript/src/models/CourierPreferencesTheme.d.ts +7 -6
  115. package/lib/typescript/src/models/CourierPreferencesTheme.d.ts.map +1 -1
  116. package/lib/typescript/src/models/CourierPushListener.d.ts.map +1 -1
  117. package/lib/typescript/src/models/CourierUserPreferences.d.ts +1 -1
  118. package/lib/typescript/src/models/CourierUserPreferences.d.ts.map +1 -1
  119. package/lib/typescript/src/models/InboxAction.d.ts.map +1 -1
  120. package/lib/typescript/src/models/InboxMessage.d.ts +1 -1
  121. package/lib/typescript/src/models/InboxMessage.d.ts.map +1 -1
  122. package/lib/typescript/src/models/InboxMessageEvent.d.ts.map +1 -1
  123. package/lib/typescript/src/models/InboxMessageSet.d.ts +1 -1
  124. package/lib/typescript/src/models/iOS_CourierCell.d.ts.map +1 -1
  125. package/lib/typescript/src/models/iOS_CourierSheet.d.ts +1 -1
  126. package/lib/typescript/src/models/iOS_CourierSheet.d.ts.map +1 -1
  127. package/lib/typescript/src/utils.d.ts.map +1 -1
  128. package/lib/typescript/src/views/CourierInboxView.d.ts +5 -5
  129. package/lib/typescript/src/views/CourierInboxView.d.ts.map +1 -1
  130. package/lib/typescript/src/views/CourierPreferencesView.d.ts +3 -3
  131. package/lib/typescript/src/views/CourierPreferencesView.d.ts.map +1 -1
  132. package/package.json +8 -4
  133. package/src/Broadcaster.tsx +21 -15
  134. package/src/CourierApiUrls.tsx +30 -0
  135. package/src/Modules.tsx +22 -13
  136. package/src/client/BrandClient.tsx +6 -6
  137. package/src/client/ClientModule.tsx +4 -6
  138. package/src/client/CourierClient.tsx +20 -13
  139. package/src/client/InboxClient.tsx +40 -13
  140. package/src/client/PreferenceClient.tsx +47 -21
  141. package/src/client/TokenClient.tsx +14 -7
  142. package/src/client/TrackingClient.tsx +7 -6
  143. package/src/index.tsx +208 -115
  144. package/src/models/Android_CourierSheet.tsx +5 -5
  145. package/src/models/CourierAuthenticationListener.tsx +5 -9
  146. package/src/models/CourierBrand.tsx +6 -6
  147. package/src/models/CourierButton.tsx +5 -5
  148. package/src/models/CourierDevice.tsx +1 -1
  149. package/src/models/CourierFont.tsx +4 -4
  150. package/src/models/CourierInboxListener.tsx +3 -3
  151. package/src/models/CourierInboxMessages.tsx +2 -2
  152. package/src/models/CourierInboxTheme.tsx +56 -42
  153. package/src/models/CourierInfoViewStyle.tsx +5 -5
  154. package/src/models/CourierPaging.tsx +1 -1
  155. package/src/models/CourierPreferencesTheme.tsx +33 -27
  156. package/src/models/CourierPushListener.tsx +9 -7
  157. package/src/models/CourierPushProvider.tsx +1 -1
  158. package/src/models/CourierTrackingEvent.tsx +6 -6
  159. package/src/models/CourierUserPreferences.tsx +32 -28
  160. package/src/models/InboxAction.tsx +2 -6
  161. package/src/models/InboxMessage.tsx +4 -5
  162. package/src/models/InboxMessageEvent.tsx +7 -1
  163. package/src/models/InboxMessageFeed.tsx +1 -1
  164. package/src/models/InboxMessageSet.tsx +1 -1
  165. package/src/models/iOS_CourierCell.tsx +10 -5
  166. package/src/models/iOS_CourierSheet.tsx +4 -4
  167. package/src/utils.tsx +4 -7
  168. package/src/views/CourierInboxView.tsx +79 -71
  169. package/src/views/CourierPreferencesView.tsx +34 -35
  170. package/lib/example/src/App.js +0 -11
  171. package/lib/example/src/Emitter.js +0 -11
  172. package/lib/example/src/Env.js +0 -6
  173. package/lib/example/src/Home.js +0 -67
  174. package/lib/example/src/Poke.js +0 -75
  175. package/lib/example/src/Tabs.js +0 -36
  176. package/lib/example/src/Utils.js +0 -71
  177. package/lib/example/src/pages/Auth.js +0 -224
  178. package/lib/example/src/pages/Inbox.js +0 -38
  179. package/lib/example/src/pages/Preferences.js +0 -13
  180. package/lib/example/src/pages/PreferencesStack.js +0 -11
  181. package/lib/example/src/pages/Push.js +0 -93
  182. package/lib/example/src/pages/Styles.js +0 -26
  183. package/lib/example/src/pages/Tests.js +0 -1068
  184. package/lib/example/src/pages/inbox/InboxCustom.js +0 -141
  185. package/lib/example/src/pages/inbox/InboxDefault.js +0 -22
  186. package/lib/example/src/pages/inbox/InboxStyled.js +0 -220
  187. package/lib/example/src/pages/preferences/PreferencesCustom.js +0 -91
  188. package/lib/example/src/pages/preferences/PreferencesDefault.js +0 -17
  189. package/lib/example/src/pages/preferences/PreferencesDetail.js +0 -127
  190. package/lib/example/src/pages/preferences/PreferencesStyled.js +0 -110
  191. package/lib/package.json +0 -171
  192. package/lib/src/Broadcaster.js +0 -24
  193. package/lib/src/Modules.js +0 -26
  194. package/lib/src/client/BrandClient.js +0 -17
  195. package/lib/src/client/ClientModule.js +0 -14
  196. package/lib/src/client/CourierClient.js +0 -31
  197. package/lib/src/client/InboxClient.js +0 -99
  198. package/lib/src/client/PreferenceClient.js +0 -63
  199. package/lib/src/client/TokenClient.js +0 -27
  200. package/lib/src/client/TrackingClient.js +0 -17
  201. package/lib/src/index.js +0 -567
  202. package/lib/src/models/Android_CourierSheet.js +0 -1
  203. package/lib/src/models/CourierAuthenticationListener.js +0 -14
  204. package/lib/src/models/CourierBrand.js +0 -1
  205. package/lib/src/models/CourierButton.js +0 -1
  206. package/lib/src/models/CourierDevice.js +0 -1
  207. package/lib/src/models/CourierFont.js +0 -1
  208. package/lib/src/models/CourierInboxListener.js +0 -20
  209. package/lib/src/models/CourierInboxMessages.js +0 -1
  210. package/lib/src/models/CourierInboxTheme.js +0 -1
  211. package/lib/src/models/CourierInfoViewStyle.js +0 -1
  212. package/lib/src/models/CourierPaging.js +0 -1
  213. package/lib/src/models/CourierPreferencesTheme.js +0 -1
  214. package/lib/src/models/CourierPushListener.js +0 -14
  215. package/lib/src/models/CourierPushProvider.js +0 -8
  216. package/lib/src/models/CourierTrackingEvent.js +0 -8
  217. package/lib/src/models/CourierUserPreferences.js +0 -51
  218. package/lib/src/models/InboxAction.js +0 -1
  219. package/lib/src/models/InboxMessage.js +0 -1
  220. package/lib/src/models/InboxMessageFeed.js +0 -1
  221. package/lib/src/models/InboxMessageSet.js +0 -1
  222. package/lib/src/models/iOS_CourierCell.js +0 -1
  223. package/lib/src/models/iOS_CourierSheet.js +0 -1
  224. package/lib/src/utils.js +0 -27
  225. package/lib/src/views/CourierInboxView.js +0 -75
  226. package/lib/src/views/CourierPreferencesView.js +0 -33
package/src/index.tsx CHANGED
@@ -1,7 +1,4 @@
1
- import {
2
- Platform,
3
- EmitterSubscription,
4
- } from 'react-native';
1
+ import { Platform, EmitterSubscription } from 'react-native';
5
2
 
6
3
  // Imports
7
4
  import { CourierInboxListener } from './models/CourierInboxListener';
@@ -11,12 +8,25 @@ import { InboxMessage } from './models/InboxMessage';
11
8
  import { CourierPushProvider } from './models/CourierPushProvider';
12
9
  import { Modules } from './Modules';
13
10
  import Broadcaster from './Broadcaster';
11
+ import {
12
+ CourierApiRegion,
13
+ CourierApiUrls,
14
+ DEFAULT_COURIER_API_URLS,
15
+ EU_COURIER_API_URLS,
16
+ getCourierApiUrlsForRegion,
17
+ } from './CourierApiUrls';
14
18
  import { CourierClient } from './client/CourierClient';
15
19
  import { Events, CourierUtils } from './utils';
16
20
  import { InboxMessageFeed } from './models/InboxMessageFeed';
17
21
  import { InboxMessageEvent } from './models/InboxMessageEvent';
18
22
 
19
- export { CourierClient } from './client/CourierClient' ;
23
+ export { CourierClient } from './client/CourierClient';
24
+ export type { CourierApiUrls, CourierApiRegion };
25
+ export {
26
+ DEFAULT_COURIER_API_URLS,
27
+ EU_COURIER_API_URLS,
28
+ getCourierApiUrlsForRegion,
29
+ };
20
30
  export { BrandClient } from './client/BrandClient';
21
31
  export { CourierBrandResponse } from './models/CourierBrand';
22
32
  export { CourierDevice } from './models/CourierDevice';
@@ -40,18 +50,33 @@ export { iOS_CourierSheet } from './models/iOS_CourierSheet';
40
50
  export { InboxMessage } from './models/InboxMessage';
41
51
  export { InboxMessageFeed } from './models/InboxMessageFeed';
42
52
  export { InboxMessageEvent } from './models/InboxMessageEvent';
43
- export { CourierInboxButtonStyle, CourierInboxTextStyle, CourierInboxUnreadIndicatorStyle, CourierInboxTheme } from './models/CourierInboxTheme';
44
- export { CourierPreferencesTheme, CourierPreferencesMode, CourierPreferencesChannel } from './models/CourierPreferencesTheme';
45
- export type iOSForegroundPresentationOptions = 'sound' | 'badge' | 'list' | 'banner';
53
+ export {
54
+ CourierInboxButtonStyle,
55
+ CourierInboxTextStyle,
56
+ CourierInboxUnreadIndicatorStyle,
57
+ CourierInboxTheme,
58
+ } from './models/CourierInboxTheme';
59
+ export {
60
+ CourierPreferencesTheme,
61
+ CourierPreferencesMode,
62
+ CourierPreferencesChannel,
63
+ } from './models/CourierPreferencesTheme';
64
+ export type iOSForegroundPresentationOptions =
65
+ | 'sound'
66
+ | 'badge'
67
+ | 'list'
68
+ | 'banner';
46
69
  export { CourierUtils } from './utils';
47
70
 
48
71
  class Courier {
49
-
50
72
  // Singleton
51
73
  private static _sharedInstance: Courier;
52
74
 
53
75
  // Listeners
54
- private authenticationListeners = new Map<string, CourierAuthenticationListener>();
76
+ private authenticationListeners = new Map<
77
+ string,
78
+ CourierAuthenticationListener
79
+ >();
55
80
  private inboxListeners = new Map<string, CourierInboxListener>();
56
81
  private pushListeners = new Map<string, CourierPushListener>();
57
82
 
@@ -62,27 +87,23 @@ class Courier {
62
87
  private pushNotificationDeliveredEmitter: EmitterSubscription | undefined;
63
88
 
64
89
  public constructor() {
65
-
66
90
  // Sets the initial SDK values
67
91
  // will show all foreground notification styles in iOS
68
92
  Courier.setIOSForegroundPresentationOptions({
69
- options: ['sound', 'badge', 'list', 'banner']
93
+ options: ['sound', 'badge', 'list', 'banner'],
70
94
  });
71
95
 
72
96
  // Attach the push notification listeners
73
97
  this.attachPushNotificationListeners();
74
-
75
98
  }
76
99
 
77
100
  // Returns the public shared instance
78
101
  public static get shared(): Courier {
79
-
80
102
  if (!this._sharedInstance) {
81
103
  this._sharedInstance = new Courier();
82
104
  }
83
105
 
84
106
  return this._sharedInstance;
85
-
86
107
  }
87
108
 
88
109
  // Debugging
@@ -99,39 +120,47 @@ class Courier {
99
120
  // System (Static)
100
121
 
101
122
  private async attachPushNotificationListeners() {
102
-
103
123
  // Remove existing listeners
104
124
  // Only allows one subscription to be active
105
125
  this.pushNotificationClickedEmitter?.remove();
106
126
  this.pushNotificationDeliveredEmitter?.remove();
107
127
 
108
128
  // When a push notification is clicked
109
- this.pushNotificationClickedEmitter = await this.systemBroadcaster.addListener(Events.Push.CLICKED, (event) => {
110
- try {
111
- const message = JSON.parse(event);
112
- this.pushListeners.forEach(listener => {
113
- if (listener.onPushNotificationClicked) {
114
- listener.onPushNotificationClicked(message);
115
- }
116
- });
117
- } catch (error) {
118
- Courier.log(`Error parsing push notification clicked event: ${error}`);
119
- }
120
- });
129
+ this.pushNotificationClickedEmitter =
130
+ await this.systemBroadcaster.addListener(Events.Push.CLICKED, (event) => {
131
+ try {
132
+ const message = JSON.parse(event);
133
+ this.pushListeners.forEach((listener) => {
134
+ if (listener.onPushNotificationClicked) {
135
+ listener.onPushNotificationClicked(message);
136
+ }
137
+ });
138
+ } catch (error) {
139
+ Courier.log(
140
+ `Error parsing push notification clicked event: ${error}`
141
+ );
142
+ }
143
+ });
121
144
 
122
145
  // When a push notification is delivered
123
- this.pushNotificationDeliveredEmitter = await this.systemBroadcaster.addListener(Events.Push.DELIVERED, (event) => {
124
- try {
125
- const message = JSON.parse(event);
126
- this.pushListeners.forEach(listener => {
127
- if (listener.onPushNotificationDelivered) {
128
- listener.onPushNotificationDelivered(message);
146
+ this.pushNotificationDeliveredEmitter =
147
+ await this.systemBroadcaster.addListener(
148
+ Events.Push.DELIVERED,
149
+ (event) => {
150
+ try {
151
+ const message = JSON.parse(event);
152
+ this.pushListeners.forEach((listener) => {
153
+ if (listener.onPushNotificationDelivered) {
154
+ listener.onPushNotificationDelivered(message);
155
+ }
156
+ });
157
+ } catch (error) {
158
+ Courier.log(
159
+ `Error parsing push notification delivered event: ${error}`
160
+ );
129
161
  }
130
- });
131
- } catch (error) {
132
- Courier.log(`Error parsing push notification delivered event: ${error}`);
133
- }
134
- });
162
+ }
163
+ );
135
164
  }
136
165
 
137
166
  /**
@@ -140,8 +169,9 @@ class Courier {
140
169
  * @param props An object containing an array of iOSForegroundPresentationOptions.
141
170
  * @returns A string indicating the result of the operation. Returns 'unsupported' on non-iOS platforms.
142
171
  */
143
- public static setIOSForegroundPresentationOptions(props: { options: iOSForegroundPresentationOptions[] }): string {
144
-
172
+ public static setIOSForegroundPresentationOptions(props: {
173
+ options: iOSForegroundPresentationOptions[];
174
+ }): string {
145
175
  // Only works on iOS
146
176
  if (Platform.OS !== 'ios') return 'unsupported';
147
177
 
@@ -149,7 +179,6 @@ class Courier {
149
179
  return Modules.System.setIOSForegroundPresentationOptions({
150
180
  options: normalizedParams,
151
181
  });
152
-
153
182
  }
154
183
 
155
184
  /**
@@ -183,8 +212,7 @@ class Courier {
183
212
  * @returns {Promise<CourierClient | undefined>} The current CourierClient instance, or undefined if not initialized.
184
213
  */
185
214
  public async getClient(): Promise<CourierClient | undefined> {
186
-
187
- const client = await Modules.Shared.getClient() ?? undefined;
215
+ const client = (await Modules.Shared.getClient()) ?? undefined;
188
216
 
189
217
  if (!client) {
190
218
  return undefined;
@@ -199,8 +227,8 @@ class Courier {
199
227
  clientKey: clientObj.clientKey,
200
228
  connectionId: clientObj.connectionId,
201
229
  tenantId: clientObj.tenantId,
230
+ apiUrls: clientObj.apiUrls,
202
231
  });
203
-
204
232
  }
205
233
 
206
234
  // Authentication
@@ -210,7 +238,7 @@ class Courier {
210
238
  * @returns {Promise<string | undefined>} The current user ID, or undefined if not set.
211
239
  */
212
240
  public async getUserId(): Promise<string | undefined> {
213
- return await Modules.Shared.getUserId() ?? undefined;
241
+ return (await Modules.Shared.getUserId()) ?? undefined;
214
242
  }
215
243
 
216
244
  /**
@@ -218,7 +246,7 @@ class Courier {
218
246
  * @returns {Promise<string | undefined>} The current tenant ID, or undefined if not set.
219
247
  */
220
248
  public async getTenantId(): Promise<string | undefined> {
221
- return await Modules.Shared.getTenantId() ?? undefined;
249
+ return (await Modules.Shared.getTenantId()) ?? undefined;
222
250
  }
223
251
 
224
252
  /**
@@ -226,7 +254,8 @@ class Courier {
226
254
  * @returns {Promise<boolean>} True if a user is signed in, false otherwise.
227
255
  */
228
256
  public async isUserSignedIn(): Promise<boolean> {
229
- const isSignedIn: string = await Modules.Shared.getIsUserSignedIn() ?? 'false';
257
+ const isSignedIn: string =
258
+ (await Modules.Shared.getIsUserSignedIn()) ?? 'false';
230
259
  return isSignedIn.toLowerCase() === 'true';
231
260
  }
232
261
 
@@ -248,13 +277,21 @@ class Courier {
248
277
  * @param {boolean} [props.showLogs] - Whether to show debug logs (defaults to __DEV__).
249
278
  * @returns {Promise<void>} A promise that resolves when the sign-in process is complete.
250
279
  */
251
- public async signIn(props: { accessToken: string, clientKey?: string, userId: string, tenantId?: string, showLogs?: boolean }): Promise<void> {
280
+ public async signIn(props: {
281
+ accessToken: string;
282
+ clientKey?: string;
283
+ userId: string;
284
+ tenantId?: string;
285
+ apiUrls?: CourierApiUrls;
286
+ showLogs?: boolean;
287
+ }): Promise<void> {
252
288
  this.isDebugging = props.showLogs ?? __DEV__;
253
289
  return await Modules.Shared.signIn(
254
290
  props.accessToken,
255
291
  props.clientKey,
256
292
  props.userId,
257
293
  props.tenantId,
294
+ props.apiUrls ?? null,
258
295
  this.isDebugging
259
296
  );
260
297
  }
@@ -265,19 +302,22 @@ class Courier {
265
302
  * @param {function} props.onUserChanged - Callback function triggered when the user changes.
266
303
  * @returns {CourierAuthenticationListener} The created authentication listener.
267
304
  */
268
- public async addAuthenticationListener(props: { onUserChanged: (userId?: string) => void }): Promise<CourierAuthenticationListener> {
269
-
305
+ public async addAuthenticationListener(props: {
306
+ onUserChanged: (userId?: string) => void;
307
+ }): Promise<CourierAuthenticationListener> {
270
308
  // Create a listener
271
309
  const listenerId = `authentication_${CourierUtils.generateUUID()}`;
272
310
 
273
311
  // Attach the listener
274
312
  const listener = new CourierAuthenticationListener(listenerId);
275
- listener.onUserChanged = await this.sharedBroadcaster.addListener(listenerId, (event) => props.onUserChanged(event));
313
+ listener.onUserChanged = await this.sharedBroadcaster.addListener(
314
+ listenerId,
315
+ (event) => props.onUserChanged(event)
316
+ );
276
317
  const id = await Modules.Shared.addAuthenticationListener(listenerId);
277
318
  this.authenticationListeners.set(id, listener);
278
319
 
279
320
  return listener;
280
-
281
321
  }
282
322
 
283
323
  /**
@@ -286,8 +326,9 @@ class Courier {
286
326
  * @param {string} props.listenerId - The ID of the listener to remove.
287
327
  * @returns {Promise<string>} A promise that resolves to the ID of the removed listener.
288
328
  */
289
- public async removeAuthenticationListener(props: { listenerId: string }): Promise<string> {
290
-
329
+ public async removeAuthenticationListener(props: {
330
+ listenerId: string;
331
+ }): Promise<string> {
291
332
  // Remove the native listener
292
333
  await Modules.Shared.removeAuthenticationListener(props.listenerId);
293
334
 
@@ -299,7 +340,6 @@ class Courier {
299
340
  }
300
341
 
301
342
  return props.listenerId;
302
-
303
343
  }
304
344
 
305
345
  /**
@@ -307,7 +347,6 @@ class Courier {
307
347
  * This method clears all registered authentication listeners, both native and JavaScript.
308
348
  */
309
349
  public async removeAllAuthenticationListeners() {
310
-
311
350
  // Remove all native listeners
312
351
  await Modules.Shared.removeAllAuthenticationListeners();
313
352
 
@@ -318,7 +357,6 @@ class Courier {
318
357
 
319
358
  // Clear the map of authentication listeners
320
359
  this.authenticationListeners.clear();
321
-
322
360
  }
323
361
 
324
362
  // Push
@@ -352,7 +390,9 @@ class Courier {
352
390
  * @param {CourierPushProvider} props.provider - The push notification provider.
353
391
  * @returns {Promise<string | undefined>} A promise that resolves to the token or undefined if not found.
354
392
  */
355
- public async getTokenForProvider(props: { provider: CourierPushProvider }): Promise<string | undefined> {
393
+ public async getTokenForProvider(props: {
394
+ provider: CourierPushProvider;
395
+ }): Promise<string | undefined> {
356
396
  return await Modules.Shared.getToken(props.provider);
357
397
  }
358
398
 
@@ -363,7 +403,7 @@ class Courier {
363
403
  * @param {string} props.token - The push notification token.
364
404
  * @returns {Promise<void>} A promise that resolves when the token is set.
365
405
  */
366
- public async setToken(props: { key: string, token: string }): Promise<void> {
406
+ public async setToken(props: { key: string; token: string }): Promise<void> {
367
407
  return await Modules.Shared.setToken(props.key, props.token);
368
408
  }
369
409
 
@@ -374,7 +414,10 @@ class Courier {
374
414
  * @param {string} props.token - The push notification token.
375
415
  * @returns {Promise<void>} A promise that resolves when the token is set.
376
416
  */
377
- public async setTokenForProvider(props: { provider: CourierPushProvider, token: string }): Promise<void> {
417
+ public async setTokenForProvider(props: {
418
+ provider: CourierPushProvider;
419
+ token: string;
420
+ }): Promise<void> {
378
421
  return await Modules.Shared.setToken(props.provider, props.token);
379
422
  }
380
423
 
@@ -385,8 +428,10 @@ class Courier {
385
428
  * @param {function} [props.onPushNotificationDelivered] - Callback function triggered when a push notification is delivered.
386
429
  * @returns {CourierPushListener} The created push notification listener.
387
430
  */
388
- public addPushNotificationListener(props: { onPushNotificationClicked?: (push: any) => void, onPushNotificationDelivered?: (push: any) => void }): CourierPushListener {
389
-
431
+ public addPushNotificationListener(props: {
432
+ onPushNotificationClicked?: (push: any) => void;
433
+ onPushNotificationDelivered?: (push: any) => void;
434
+ }): CourierPushListener {
390
435
  const listenerId = `push_${CourierUtils.generateUUID()}`;
391
436
 
392
437
  const pushListener = new CourierPushListener(
@@ -405,7 +450,6 @@ class Courier {
405
450
  Modules.System.registerPushNotificationClickedOnKilledState();
406
451
 
407
452
  return pushListener;
408
-
409
453
  }
410
454
 
411
455
  /**
@@ -414,7 +458,9 @@ class Courier {
414
458
  * @param {string} props.listenerId - The ID of the listener to remove.
415
459
  * @returns {string} The ID of the removed listener.
416
460
  */
417
- public async removePushNotificationListener(props: { listenerId: string }): Promise<string> {
461
+ public async removePushNotificationListener(props: {
462
+ listenerId: string;
463
+ }): Promise<string> {
418
464
  if (this.pushListeners.has(props.listenerId)) {
419
465
  this.pushListeners.delete(props.listenerId);
420
466
  }
@@ -523,15 +569,28 @@ class Courier {
523
569
  * @returns {CourierInboxListener} A listener object that can be used to remove the listener later.
524
570
  */
525
571
  public async addInboxListener(props: {
526
- onLoading?: (isRefresh: boolean) => void,
527
- onError?: (error: string) => void,
528
- onUnreadCountChanged?: (unreadCount: number) => void,
529
- onTotalCountChanged?: (totalCount: number, feed: string) => void,
530
- onMessagesChanged?: (messages: InboxMessage[], canPaginate: boolean, feed: InboxMessageFeed) => void,
531
- onPageAdded?: (messages: InboxMessage[], canPaginate: boolean, isFirstPage: boolean, feed: InboxMessageFeed) => void,
532
- onMessageEvent?: (message: InboxMessage, index: number, feed: InboxMessageFeed, eventName: InboxMessageEvent) => void
572
+ onLoading?: (isRefresh: boolean) => void;
573
+ onError?: (error: string) => void;
574
+ onUnreadCountChanged?: (unreadCount: number) => void;
575
+ onTotalCountChanged?: (totalCount: number, feed: string) => void;
576
+ onMessagesChanged?: (
577
+ messages: InboxMessage[],
578
+ canPaginate: boolean,
579
+ feed: InboxMessageFeed
580
+ ) => void;
581
+ onPageAdded?: (
582
+ messages: InboxMessage[],
583
+ canPaginate: boolean,
584
+ isFirstPage: boolean,
585
+ feed: InboxMessageFeed
586
+ ) => void;
587
+ onMessageEvent?: (
588
+ message: InboxMessage,
589
+ index: number,
590
+ feed: InboxMessageFeed,
591
+ eventName: InboxMessageEvent
592
+ ) => void;
533
593
  }): Promise<CourierInboxListener> {
534
-
535
594
  // Generate a unique ID for the listener
536
595
  const listenerId = `inbox_${CourierUtils.generateUUID()}`;
537
596
 
@@ -550,49 +609,84 @@ class Courier {
550
609
  const listener = new CourierInboxListener(listenerId);
551
610
 
552
611
  // 1) onLoading
553
- listener.onLoading = await this.sharedBroadcaster.addListener(listenerIds.loading, (event: any) => {
554
- // event is simply the boolean "isRefresh"
555
- props.onLoading?.(event);
556
- });
612
+ listener.onLoading = await this.sharedBroadcaster.addListener(
613
+ listenerIds.loading,
614
+ (event: any) => {
615
+ // event is simply the boolean "isRefresh"
616
+ props.onLoading?.(event);
617
+ }
618
+ );
557
619
 
558
620
  // 2) onError
559
- listener.onError = await this.sharedBroadcaster.addListener(listenerIds.error, (event: any) => {
560
- // event is the error message (string)
561
- props.onError?.(event);
562
- });
621
+ listener.onError = await this.sharedBroadcaster.addListener(
622
+ listenerIds.error,
623
+ (event: any) => {
624
+ // event is the error message (string)
625
+ props.onError?.(event);
626
+ }
627
+ );
563
628
 
564
629
  // 3) onUnreadCountChanged
565
- listener.onUnreadCountChanged = await this.sharedBroadcaster.addListener(listenerIds.unreadCount, (event: any) => {
566
- // event is the unread count (number)
567
- props.onUnreadCountChanged?.(event);
568
- });
630
+ listener.onUnreadCountChanged = await this.sharedBroadcaster.addListener(
631
+ listenerIds.unreadCount,
632
+ (event: any) => {
633
+ // event is the unread count (number)
634
+ props.onUnreadCountChanged?.(event);
635
+ }
636
+ );
569
637
 
570
638
  // 4) onTotalCountChanged
571
- listener.onTotalCountChanged = await this.sharedBroadcaster.addListener(listenerIds.totalCount, (event: any) => {
572
- // event => { feed: "feed"|"archive", totalCount: number }
573
- props.onTotalCountChanged?.(event.totalCount, event.feed);
574
- });
639
+ listener.onTotalCountChanged = await this.sharedBroadcaster.addListener(
640
+ listenerIds.totalCount,
641
+ (event: any) => {
642
+ // event => { feed: "feed"|"archive", totalCount: number }
643
+ props.onTotalCountChanged?.(event.totalCount, event.feed);
644
+ }
645
+ );
575
646
 
576
647
  // 5) onMessagesChanged
577
- listener.onMessagesChanged = await this.sharedBroadcaster.addListener(listenerIds.messagesChanged, (event: any) => {
578
- // event => { feed: "feed"|"archive", messages: any[], totalMessageCount: number, canPaginate: boolean }
579
- const convertedMessages = this.convertMessages(event.messages);
580
- props.onMessagesChanged?.(convertedMessages, event.canPaginate, event.feed);
581
- });
648
+ listener.onMessagesChanged = await this.sharedBroadcaster.addListener(
649
+ listenerIds.messagesChanged,
650
+ (event: any) => {
651
+ // event => { feed: "feed"|"archive", messages: any[], totalMessageCount: number, canPaginate: boolean }
652
+ const convertedMessages = this.convertMessages(event.messages);
653
+ props.onMessagesChanged?.(
654
+ convertedMessages,
655
+ event.canPaginate,
656
+ event.feed
657
+ );
658
+ }
659
+ );
582
660
 
583
661
  // 6) onPageAdded
584
- listener.onPageAdded = await this.sharedBroadcaster.addListener(listenerIds.pageAdded, (event: any) => {
585
- // event => { feed: "feed"|"archive", messages: any[], totalMessageCount: number, canPaginate: boolean, isFirstPage: boolean }
586
- const convertedMessages = this.convertMessages(event.messages);
587
- props.onPageAdded?.(convertedMessages, event.canPaginate, event.isFirstPage, event.feed);
588
- });
662
+ listener.onPageAdded = await this.sharedBroadcaster.addListener(
663
+ listenerIds.pageAdded,
664
+ (event: any) => {
665
+ // event => { feed: "feed"|"archive", messages: any[], totalMessageCount: number, canPaginate: boolean, isFirstPage: boolean }
666
+ const convertedMessages = this.convertMessages(event.messages);
667
+ props.onPageAdded?.(
668
+ convertedMessages,
669
+ event.canPaginate,
670
+ event.isFirstPage,
671
+ event.feed
672
+ );
673
+ }
674
+ );
589
675
 
590
676
  // 7) onMessageEvent
591
- listener.onMessageEvent = await this.sharedBroadcaster.addListener(listenerIds.messageEvent, (event: any) => {
592
- // event => { feed: "feed"|"archive", index: number, event: string, message: any }
593
- const convertedMessage = InboxMessage.fromJson(event.message);
594
- props.onMessageEvent?.(convertedMessage, event.index, event.feed, event.event);
595
- });
677
+ listener.onMessageEvent = await this.sharedBroadcaster.addListener(
678
+ listenerIds.messageEvent,
679
+ (event: any) => {
680
+ // event => { feed: "feed"|"archive", index: number, event: string, message: any }
681
+ const convertedMessage = InboxMessage.fromJson(event.message);
682
+ props.onMessageEvent?.(
683
+ convertedMessage,
684
+ event.index,
685
+ event.feed,
686
+ event.event
687
+ );
688
+ }
689
+ );
596
690
 
597
691
  // Attach the listener to native iOS/Android via bridging
598
692
  const id = await Modules.Shared.addInboxListener(
@@ -613,7 +707,7 @@ class Courier {
613
707
  }
614
708
 
615
709
  private convertMessages(messages: string[]): InboxMessage[] {
616
- return messages.map(jsonString => InboxMessage.fromJson(jsonString));
710
+ return messages.map((jsonString) => InboxMessage.fromJson(jsonString));
617
711
  }
618
712
 
619
713
  /**
@@ -622,14 +716,14 @@ class Courier {
622
716
  * @param {string} props.listenerId - The ID of the listener to remove.
623
717
  * @returns {string} The ID of the removed listener.
624
718
  */
625
- public async removeInboxListener(props: { listenerId: string }): Promise<string> {
626
-
719
+ public async removeInboxListener(props: {
720
+ listenerId: string;
721
+ }): Promise<string> {
627
722
  // Call native code
628
723
  await Modules.Shared.removeInboxListener(props.listenerId);
629
724
 
630
725
  // Remove the listener
631
726
  if (this.inboxListeners.has(props.listenerId)) {
632
-
633
727
  // Remove emitters
634
728
  const listener = this.inboxListeners.get(props.listenerId);
635
729
  listener?.onLoading?.remove();
@@ -642,18 +736,15 @@ class Courier {
642
736
 
643
737
  // Remove the listener
644
738
  this.inboxListeners.delete(props.listenerId);
645
-
646
739
  }
647
740
 
648
741
  return props.listenerId;
649
-
650
742
  }
651
743
 
652
744
  /**
653
745
  * Removes all inbox listeners.
654
746
  */
655
747
  public async removeAllInboxListeners() {
656
-
657
748
  // Call native code
658
749
  await Modules.Shared.removeAllInboxListeners();
659
750
 
@@ -669,7 +760,6 @@ class Courier {
669
760
  });
670
761
 
671
762
  this.inboxListeners.clear();
672
-
673
763
  }
674
764
 
675
765
  /**
@@ -685,8 +775,12 @@ class Courier {
685
775
  * Fetches the next page of inbox messages.
686
776
  * @returns {Promise<InboxMessage[]>} A promise that resolves with an array of fetched inbox messages.
687
777
  */
688
- public async fetchNextPageOfMessages(props: { inboxMessageFeed: InboxMessageFeed }): Promise<InboxMessage[]> {
689
- const data = await Modules.Shared.fetchNextPageOfMessages(props.inboxMessageFeed);
778
+ public async fetchNextPageOfMessages(props: {
779
+ inboxMessageFeed: InboxMessageFeed;
780
+ }): Promise<InboxMessage[]> {
781
+ const data = await Modules.Shared.fetchNextPageOfMessages(
782
+ props.inboxMessageFeed
783
+ );
690
784
  const parsedData = data ? JSON.parse(data) : undefined;
691
785
  return parsedData?.messages ?? [];
692
786
  }
@@ -699,7 +793,6 @@ class Courier {
699
793
  Modules.Shared.setIsUITestsActive(isActive);
700
794
  }
701
795
  }
702
-
703
796
  }
704
797
 
705
798
  export default Courier;
@@ -1,7 +1,7 @@
1
- import { CourierFont } from "./CourierFont"
1
+ import { CourierFont } from './CourierFont';
2
2
 
3
3
  export interface Android_CourierSheet {
4
- font?: CourierFont
5
- toggleTrackColor?: string
6
- toggleThumbColor?: string
7
- }
4
+ font?: CourierFont;
5
+ toggleTrackColor?: string;
6
+ toggleThumbColor?: string;
7
+ }
@@ -1,23 +1,19 @@
1
- import { EmitterSubscription } from "react-native";
2
- import Courier from "..";
1
+ import { EmitterSubscription } from 'react-native';
2
+ import Courier from '..';
3
3
 
4
4
  export class CourierAuthenticationListener {
5
-
6
- readonly listenerId: string
7
- public onUserChanged?: EmitterSubscription
5
+ readonly listenerId: string;
6
+ public onUserChanged?: EmitterSubscription;
8
7
 
9
8
  constructor(id: string) {
10
9
  this.listenerId = id;
11
10
  }
12
11
 
13
12
  public async remove() {
14
-
15
13
  // Remove the native inbox listener
16
14
  await Courier.shared.removeInboxListener({ listenerId: this.listenerId });
17
15
 
18
16
  // Remove the emitter
19
17
  this.onUserChanged?.remove();
20
-
21
18
  }
22
-
23
- }
19
+ }
@@ -1,18 +1,18 @@
1
1
  export interface CourierBrandResponse {
2
- data?: CourierBrandData
2
+ data?: CourierBrandData;
3
3
  }
4
4
 
5
5
  export interface CourierBrandData {
6
- brand?: CourierBrand
6
+ brand?: CourierBrand;
7
7
  }
8
8
 
9
9
  export interface CourierBrand {
10
- settings?: CourierBrandSettings
10
+ settings?: CourierBrandSettings;
11
11
  }
12
12
 
13
13
  export interface CourierBrandSettings {
14
- inapp?: CourierBrandInApp
15
- colors?: CourierBrandColors
14
+ inapp?: CourierBrandInApp;
15
+ colors?: CourierBrandColors;
16
16
  }
17
17
 
18
18
  export interface CourierBrandInApp {
@@ -21,4 +21,4 @@ export interface CourierBrandInApp {
21
21
 
22
22
  export interface CourierBrandColors {
23
23
  primary?: string;
24
- }
24
+ }