@trycourier/courier-react-native 1.0.9 → 2.0.0-beta1

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 (89) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +16 -412
  3. package/android/build.gradle +48 -83
  4. package/android/src/main/AndroidManifest.xml +0 -1
  5. package/android/src/main/AndroidManifestNew.xml +2 -0
  6. package/android/src/main/java/com/courierreactnative/CourierReactNativeActivity.kt +10 -10
  7. package/android/src/main/java/com/courierreactnative/CourierReactNativeModule.kt +146 -137
  8. package/android/src/main/java/com/courierreactnative/CourierReactNativePackage.kt +1 -3
  9. package/android/src/main/java/com/courierreactnative/CourierReactNativeViewManager.kt +43 -0
  10. package/courier-react-native.podspec +12 -4
  11. package/ios/CourierReactNative-Bridging-Header.h +0 -1
  12. package/ios/CourierReactNative.xcodeproj/project.pbxproj +4 -4
  13. package/ios/CourierReactNative.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
  14. package/ios/CourierReactNativeModule.m +53 -0
  15. package/ios/{CourierReactNative.swift → CourierReactNativeModule.swift} +178 -45
  16. package/ios/CourierReactNativeViewManager.m +15 -0
  17. package/ios/CourierReactNativeViewManager.swift +348 -0
  18. package/lib/commonjs/index.js +86 -210
  19. package/lib/commonjs/index.js.map +1 -1
  20. package/lib/commonjs/models/CourierInboxListener.js +26 -0
  21. package/lib/commonjs/models/CourierInboxListener.js.map +1 -0
  22. package/lib/commonjs/models/CourierInboxTheme.js +2 -0
  23. package/lib/commonjs/models/CourierInboxTheme.js.map +1 -0
  24. package/lib/commonjs/models/InboxAction.js +2 -0
  25. package/lib/commonjs/models/InboxAction.js.map +1 -0
  26. package/lib/commonjs/models/InboxMessage.js +6 -0
  27. package/lib/commonjs/models/InboxMessage.js.map +1 -0
  28. package/lib/commonjs/views/CourierInboxView.js +53 -0
  29. package/lib/commonjs/views/CourierInboxView.js.map +1 -0
  30. package/lib/module/index.js +80 -209
  31. package/lib/module/index.js.map +1 -1
  32. package/lib/module/models/CourierInboxListener.js +18 -0
  33. package/lib/module/models/CourierInboxListener.js.map +1 -0
  34. package/lib/module/models/CourierInboxTheme.js +2 -0
  35. package/lib/module/models/CourierInboxTheme.js.map +1 -0
  36. package/lib/module/models/InboxAction.js +2 -0
  37. package/lib/module/models/InboxAction.js.map +1 -0
  38. package/lib/module/models/InboxMessage.js +2 -0
  39. package/lib/module/models/InboxMessage.js.map +1 -0
  40. package/lib/module/views/CourierInboxView.js +45 -0
  41. package/lib/module/views/CourierInboxView.js.map +1 -0
  42. package/lib/typescript/index.d.ts +46 -92
  43. package/lib/typescript/index.d.ts.map +1 -0
  44. package/lib/typescript/models/CourierInboxListener.d.ts +9 -0
  45. package/lib/typescript/models/CourierInboxListener.d.ts.map +1 -0
  46. package/lib/typescript/models/CourierInboxTheme.d.ts +34 -0
  47. package/lib/typescript/models/CourierInboxTheme.d.ts.map +1 -0
  48. package/lib/typescript/models/InboxAction.d.ts +8 -0
  49. package/lib/typescript/models/InboxAction.d.ts.map +1 -0
  50. package/lib/typescript/models/InboxMessage.d.ts +18 -0
  51. package/lib/typescript/models/InboxMessage.d.ts.map +1 -0
  52. package/lib/typescript/views/CourierInboxView.d.ts +16 -0
  53. package/lib/typescript/views/CourierInboxView.d.ts.map +1 -0
  54. package/package.json +61 -44
  55. package/src/index.tsx +213 -0
  56. package/src/models/CourierInboxListener.tsx +25 -0
  57. package/src/models/CourierInboxTheme.tsx +30 -0
  58. package/src/models/InboxAction.tsx +5 -0
  59. package/src/models/InboxMessage.tsx +16 -0
  60. package/src/views/CourierInboxView.tsx +85 -0
  61. package/android/.gradle/7.1/dependencies-accessors/dependencies-accessors.lock +0 -0
  62. package/android/.gradle/7.1/dependencies-accessors/gc.properties +0 -0
  63. package/android/.gradle/7.1/executionHistory/executionHistory.lock +0 -0
  64. package/android/.gradle/7.1/fileChanges/last-build.bin +0 -0
  65. package/android/.gradle/7.1/fileHashes/fileHashes.bin +0 -0
  66. package/android/.gradle/7.1/fileHashes/fileHashes.lock +0 -0
  67. package/android/.gradle/7.1/gc.properties +0 -0
  68. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  69. package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
  70. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  71. package/android/.gradle/checksums/checksums.lock +0 -0
  72. package/android/.gradle/checksums/md5-checksums.bin +0 -0
  73. package/android/.gradle/checksums/sha1-checksums.bin +0 -0
  74. package/android/.gradle/vcs-1/gc.properties +0 -0
  75. package/android/.idea/compiler.xml +0 -6
  76. package/android/.idea/gradle.xml +0 -17
  77. package/android/.idea/jarRepositories.xml +0 -35
  78. package/android/.idea/misc.xml +0 -10
  79. package/android/.idea/vcs.xml +0 -6
  80. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  81. package/android/gradle/wrapper/gradle-wrapper.properties +0 -5
  82. package/android/gradlew +0 -185
  83. package/android/gradlew.bat +0 -89
  84. package/android/local.properties +0 -8
  85. package/android/src/main/java/com/courierreactnative/NotificationPermissionStatus.kt +0 -6
  86. package/ios/CourierReactNative.m +0 -52
  87. package/ios/CourierReactNativeDelegate.h +0 -20
  88. package/ios/CourierReactNativeDelegate.m +0 -125
  89. package/src/index.ts +0 -337
@@ -1,48 +1,39 @@
1
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
-
3
- /* eslint no-underscore-dangle: 0 */
4
-
5
- /* eslint class-methods-use-this: 0 */
6
- import { NativeModules, Platform, DeviceEventEmitter, NativeEventEmitter } from 'react-native';
7
- const LINKING_ERROR = `The package '@trycourier/courier-react-native' doesn't seem to be linked. Make sure: \n\n${Platform.select({
1
+ import { NativeModules, NativeEventEmitter, Platform } from 'react-native';
2
+ import { CourierInboxListener } from './models/CourierInboxListener';
3
+ export { CourierInboxView } from './views/CourierInboxView';
4
+ const LINKING_ERROR = `The package '@trycourier/courier-react-native' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
8
5
  ios: "- You have run 'pod install'\n",
9
6
  default: ''
10
- })}- You rebuilt the app after installing the package\n` + `- You are not using Expo managed workflow\n`;
11
- const CourierReactNativeModules = NativeModules.CourierReactNative ? NativeModules.CourierReactNative : new Proxy({}, {
7
+ }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
8
+ const CourierReactNativeModules = NativeModules.CourierReactNativeModule ? NativeModules.CourierReactNativeModule : new Proxy({}, {
12
9
  get() {
13
10
  throw new Error(LINKING_ERROR);
14
11
  }
15
-
16
12
  });
17
- const CourierEventEmitter = new NativeEventEmitter(NativeModules.CourierReactNative);
18
- export let CourierProvider;
19
-
20
- (function (CourierProvider) {
21
- CourierProvider["FCM"] = "firebase-fcm";
22
- CourierProvider["APNS"] = "apn";
23
- })(CourierProvider || (CourierProvider = {}));
24
-
13
+ const CourierEventEmitter = new NativeEventEmitter(NativeModules.CourierReactNativeModule);
25
14
  class Courier {
15
+ _isDebugging = false;
26
16
  constructor() {
27
- _defineProperty(this, "PUSH_NOTIFICATION_CLICKED", 'pushNotificationClicked');
28
-
29
- _defineProperty(this, "PUSH_NOTIFICATION_DELIVERED", 'pushNotificationDelivered');
30
-
31
- _defineProperty(this, "_isDebugging", false);
32
-
33
- _defineProperty(this, "debugListener", void 0);
34
-
35
17
  // Sets the initial SDK values
36
18
  // Defaults to React Native level debugging
37
19
  // and will show all foreground notification styles in iOS
38
20
  this.setDefaults();
39
21
  }
40
22
 
23
+ // Returns the public shared instance
24
+ static get shared() {
25
+ if (!this._sharedInstance) {
26
+ this._sharedInstance = new Courier();
27
+ }
28
+ return this._sharedInstance;
29
+ }
41
30
  async setDefaults() {
42
31
  try {
43
- await Promise.all([this.setIsDebugging(__DEV__), this.iOSForegroundPresentationOptions({
44
- options: ['sound', 'badge', 'list', 'banner']
45
- })]);
32
+ await Promise.all([this.setIsDebugging(__DEV__)
33
+ // this.iOSForegroundPresentationOptions({
34
+ // options: ['sound', 'badge', 'list', 'banner'],
35
+ // }),
36
+ ]);
46
37
  } catch (error) {
47
38
  console.log(error);
48
39
  }
@@ -55,33 +46,31 @@ class Courier {
55
46
  */
56
47
  async setIsDebugging(isDebugging) {
57
48
  var _this$debugListener;
58
-
59
49
  // Remove the existing listener if needed
60
- (_this$debugListener = this.debugListener) === null || _this$debugListener === void 0 ? void 0 : _this$debugListener.remove(); // Set a new listener
61
- // listener needs to be registered first to catch the event
50
+ (_this$debugListener = this.debugListener) === null || _this$debugListener === void 0 ? void 0 : _this$debugListener.remove();
62
51
 
52
+ // Set a new listener
53
+ // listener needs to be registered first to catch the event
63
54
  if (isDebugging) {
64
55
  this.debugListener = CourierEventEmitter.addListener('courierDebugEvent', event => {
65
56
  console.log('\x1b[36m%s\x1b[0m', 'COURIER', event);
66
57
  });
67
58
  }
68
-
69
59
  this._isDebugging = await CourierReactNativeModules.setDebugMode(isDebugging);
70
60
  return this._isDebugging;
71
61
  }
72
-
73
62
  get isDebugging() {
74
63
  return this._isDebugging;
75
64
  }
65
+
76
66
  /**
77
67
  * Returns the current user id stored in local native storage
78
68
  * @example const userId = await Courier.userId
79
69
  */
80
-
81
-
82
70
  get userId() {
83
71
  return CourierReactNativeModules.getUserId();
84
72
  }
73
+
85
74
  /**
86
75
  * Signs user in and persists signin in between sessions
87
76
  * using native level storage apis
@@ -90,6 +79,7 @@ class Courier {
90
79
  * ```
91
80
  *await Courier.signIn({
92
81
  accessToken: YOUR_COURIER_GENERATED_JWT,
82
+ clientKey: YOUR_CLIENT_KEY,
93
83
  userId: YOUR_USER_ID,
94
84
  })
95
85
  * ```
@@ -97,200 +87,81 @@ class Courier {
97
87
  * that is requested from your backend
98
88
  * https://www.courier.com/docs/reference/auth/issue-token/
99
89
  */
100
-
101
-
102
- signIn(_ref) {
103
- let {
104
- accessToken,
105
- userId
106
- } = _ref;
107
- return CourierReactNativeModules.signIn(userId, accessToken);
90
+ signIn(props) {
91
+ return CourierReactNativeModules.signIn(props.accessToken, props.clientKey ?? null, props.userId);
108
92
  }
109
- /**
110
- * Logs user out of native level user storage.
111
- * This will clear the userId, accessToken, and apns / fcm tokens and
112
- * delete the matching devices apns / fcm tokens for the user in Courier token management
113
- * @example await Courier.signOut()
114
- */
115
93
 
116
-
117
- signOut() {
118
- return CourierReactNativeModules.signOut();
119
- }
120
94
  /**
121
- * Sets the current Apple Push Notification Service (APNS) token
122
- * using Courier token management apis
123
- * @example const apnsToken = await Courier.apnsToken
95
+ * TODO
96
+ * @param props
97
+ * @returns
124
98
  */
125
-
126
-
127
- get apnsToken() {
128
- if (Platform.OS !== 'ios') return Promise.resolve(undefined);
129
- return CourierReactNativeModules.getApnsToken();
99
+ readMessage(props) {
100
+ return CourierReactNativeModules.readMessage(props.messageId);
130
101
  }
131
- /**
132
- * Sets the current Firebase Cloud Messaging (FCM) token
133
- * using Courier token management apis
134
- * @example const fcmToken = await Courier.fcmToken
135
- */
136
102
 
137
-
138
- get fcmToken() {
139
- return CourierReactNativeModules.getFcmToken();
140
- }
141
103
  /**
142
- * Sets the current Firebase Cloud Messaging (FCM) token
143
- * using Courier token management apis
144
- * @example await setFcmToken('asdf...asdf')
104
+ * TODO
105
+ * @param props
106
+ * @returns
145
107
  */
146
-
147
-
148
- setFcmToken(token) {
149
- return CourierReactNativeModules.setFcmToken(token);
108
+ unreadMessage(props) {
109
+ return CourierReactNativeModules.unreadMessage(props.messageId);
150
110
  }
151
- /**
152
- * Hits the Courier /send endpoint and sends a test push notification
153
- * @example
154
- * ```
155
- *const messageId = await sendPush({
156
- authKey: YOUR_AUTH_KEY_THAT_SHOULD_NOT_STAY_IN_YOUR_PRODUCTION_APP,
157
- userId: USER_ID,
158
- title: 'This is a title',
159
- body: 'This is a body',
160
- providers: [CourierProvider.APNS, CourierProvider.FCM],
161
- });
162
- * ```
163
- * @returns promise
164
- */
165
111
 
166
-
167
- sendPush(_ref2) {
168
- let {
169
- authKey,
170
- userId,
171
- title,
172
- body,
173
- providers
174
- } = _ref2;
175
- return CourierReactNativeModules.sendPush(authKey, userId, title, body, providers);
176
- }
177
112
  /**
178
- * Gets notification permission status at a system level.
179
- * @example const permissionStatus = await Courier.getNotificationPermissionStatus()
113
+ * TODO
114
+ * @param props
115
+ * @returns
180
116
  */
181
-
182
-
183
- get notificationPermissionStatus() {
184
- return CourierReactNativeModules.getNotificationPermissionStatus();
117
+ readAllInboxMessages() {
118
+ return CourierReactNativeModules.readAllInboxMessages();
185
119
  }
186
- /**
187
- * Requests notification permission status at a system level.
188
- * Returns the string associated with the permission status.
189
- * Will return the current status and will not present a popup
190
- * if the user has already been asked for permission.
191
- * @example const permissionStatus = await Courier.requestNotificationPermission()
192
- */
193
120
 
194
-
195
- requestNotificationPermission() {
196
- return CourierReactNativeModules.requestNotificationPermission();
197
- }
198
121
  /**
199
- * Sets the push notification presentation style when the app is in the foreground
200
- * This does not affect how the notification is shown when the app is killed or in the background states
201
- *
202
- * Defaults to sound, badge, list and/or banner.
203
- *
204
- * @example iOSForegroundPresentationOptions({options: ['sound']});
122
+ * TODO
123
+ * @param props
124
+ * @returns
205
125
  */
206
-
207
-
208
- iOSForegroundPresentationOptions(_ref3) {
209
- let {
210
- options
211
- } = _ref3;
212
- // Only works on iOS
213
- if (Platform.OS !== 'ios') return Promise.resolve();
214
- const normalizedParams = Array.from(new Set(options));
215
- return CourierReactNativeModules.iOSForegroundPresentationOptions({
216
- options: normalizedParams
217
- });
218
- }
219
- /**
220
- * @example
221
- *```
222
- const unsubPushListeners = () => {
223
- return Courier.registerPushNotificationListeners<YOUR_NOTIFICATION_TYPE>({
224
- onPushNotificationClicked: (push) => {
225
- ...
226
- },
227
- onPushNotificationDelivered: (push) => {
228
- ...
229
- },
230
- })
231
- }
232
- // To unsubscribe the listeners
233
- unsubPushListeners()
234
- *```
235
- * @returns function that can be used to unsubscribe from registered listeners
236
- */
237
-
238
-
239
- registerPushNotificationListeners(_ref4) {
240
- let {
241
- onPushNotificationClicked,
242
- onPushNotificationDelivered
243
- } = _ref4;
244
- let notificationClickedListener;
245
- let notificationDeliveredListener; // Android
246
-
247
- if (Platform.OS === 'android') {
248
- notificationClickedListener = DeviceEventEmitter.addListener(this.PUSH_NOTIFICATION_CLICKED, event => {
249
- try {
250
- onPushNotificationClicked(JSON.parse(event));
251
- } catch (error) {
252
- console.log(error);
253
- }
126
+ addInboxListener(props) {
127
+ // Create the initial listeners
128
+ const inboxListener = new CourierInboxListener();
129
+ if (props.onInitialLoad) {
130
+ inboxListener.onInitialLoad = CourierEventEmitter.addListener('inboxInitialLoad', () => {
131
+ props.onInitialLoad();
254
132
  });
255
- notificationDeliveredListener = DeviceEventEmitter.addListener(this.PUSH_NOTIFICATION_DELIVERED, event => {
256
- try {
257
- onPushNotificationDelivered(JSON.parse(event));
258
- } catch (error) {
259
- console.log(error);
260
- }
261
- });
262
- } // iOS
263
-
264
-
265
- if (Platform.OS === 'ios') {
266
- notificationClickedListener = CourierEventEmitter.addListener(this.PUSH_NOTIFICATION_CLICKED, event => {
267
- try {
268
- onPushNotificationClicked(JSON.parse(event));
269
- } catch (error) {
270
- console.log(error);
271
- }
133
+ }
134
+ if (props.onError) {
135
+ inboxListener.onError = CourierEventEmitter.addListener('inboxError', event => {
136
+ props.onError(event);
272
137
  });
273
- notificationDeliveredListener = CourierEventEmitter.addListener(this.PUSH_NOTIFICATION_DELIVERED, event => {
274
- try {
275
- onPushNotificationDelivered(JSON.parse(event));
276
- } catch (error) {
277
- console.log(error);
278
- }
138
+ }
139
+ if (props.onMessagesChanged) {
140
+ inboxListener.onMessagesChanged = CourierEventEmitter.addListener('inboxMessagesChanged', event => {
141
+ props.onMessagesChanged(event.messages, event.unreadMessageCount, event.totalMessageCount, event.canPaginate);
279
142
  });
280
- } // When listener is registered
281
- // Attempt to fetch the last message that was clicked
282
- // This is needed for when the app is killed and the
283
- // user launched the app by clicking on a notifications
284
-
143
+ }
144
+ inboxListener.listenerId = CourierReactNativeModules.addInboxListener(null);
145
+ return inboxListener;
146
+ }
285
147
 
286
- CourierReactNativeModules.registerPushNotificationClickedOnKilledState();
287
- return () => {
288
- notificationClickedListener.remove();
289
- notificationDeliveredListener.remove();
290
- };
148
+ /**
149
+ * TODO
150
+ * @param props
151
+ * @returns
152
+ */
153
+ removeInboxListener(props) {
154
+ return CourierReactNativeModules.removeInboxListener(props.listenerId);
291
155
  }
292
156
 
157
+ /**
158
+ * TODO
159
+ * @param props
160
+ * @returns
161
+ */
162
+ async refreshInbox() {
163
+ return CourierReactNativeModules.refreshInbox();
164
+ }
293
165
  }
294
-
295
- export default new Courier();
166
+ export default Courier;
296
167
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["NativeModules","Platform","DeviceEventEmitter","NativeEventEmitter","LINKING_ERROR","select","ios","default","CourierReactNativeModules","CourierReactNative","Proxy","get","Error","CourierEventEmitter","CourierProvider","Courier","constructor","setDefaults","Promise","all","setIsDebugging","__DEV__","iOSForegroundPresentationOptions","options","error","console","log","isDebugging","debugListener","remove","addListener","event","_isDebugging","setDebugMode","userId","getUserId","signIn","accessToken","signOut","apnsToken","OS","resolve","undefined","getApnsToken","fcmToken","getFcmToken","setFcmToken","token","sendPush","authKey","title","body","providers","notificationPermissionStatus","getNotificationPermissionStatus","requestNotificationPermission","normalizedParams","Array","from","Set","registerPushNotificationListeners","onPushNotificationClicked","onPushNotificationDelivered","notificationClickedListener","notificationDeliveredListener","PUSH_NOTIFICATION_CLICKED","JSON","parse","PUSH_NOTIFICATION_DELIVERED","registerPushNotificationClickedOnKilledState"],"sources":["index.ts"],"sourcesContent":["/* eslint no-underscore-dangle: 0 */\n/* eslint class-methods-use-this: 0 */\nimport {\n NativeModules,\n Platform,\n DeviceEventEmitter,\n NativeEventEmitter,\n EmitterSubscription,\n} from 'react-native';\n\nconst LINKING_ERROR =\n `The package '@trycourier/courier-react-native' doesn't seem to be linked. Make sure: \\n\\n${Platform.select(\n { ios: \"- You have run 'pod install'\\n\", default: '' }\n )}- You rebuilt the app after installing the package\\n` +\n `- You are not using Expo managed workflow\\n`;\n\nconst CourierReactNativeModules = NativeModules.CourierReactNative\n ? NativeModules.CourierReactNative\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\nconst CourierEventEmitter = new NativeEventEmitter(\n NativeModules.CourierReactNative\n);\n\nexport enum CourierProvider {\n FCM = 'firebase-fcm',\n APNS = 'apn',\n}\n\nclass Courier {\n readonly PUSH_NOTIFICATION_CLICKED = 'pushNotificationClicked';\n\n readonly PUSH_NOTIFICATION_DELIVERED = 'pushNotificationDelivered';\n\n public constructor() {\n // Sets the initial SDK values\n // Defaults to React Native level debugging\n // and will show all foreground notification styles in iOS\n this.setDefaults();\n }\n\n private async setDefaults() {\n try {\n await Promise.all([\n this.setIsDebugging(__DEV__),\n this.iOSForegroundPresentationOptions({\n options: ['sound', 'badge', 'list', 'banner'],\n }),\n ]);\n } catch (error) {\n console.log(error);\n }\n }\n\n private _isDebugging = false;\n\n private debugListener: EmitterSubscription | undefined;\n\n /**\n * Tells native Courier SDKs to show or hide logs.\n * Defaults to the React __DEV__ mode\n * @example Courier.setIsDebugging(true)\n */\n public async setIsDebugging(isDebugging: boolean): Promise<boolean> {\n // Remove the existing listener if needed\n this.debugListener?.remove();\n\n // Set a new listener\n // listener needs to be registered first to catch the event\n if (isDebugging) {\n this.debugListener = CourierEventEmitter.addListener(\n 'courierDebugEvent',\n (event) => {\n console.log('\\x1b[36m%s\\x1b[0m', 'COURIER', event);\n }\n );\n }\n\n this._isDebugging = await CourierReactNativeModules.setDebugMode(\n isDebugging\n );\n\n return this._isDebugging;\n }\n\n get isDebugging(): boolean {\n return this._isDebugging;\n }\n\n /**\n * Returns the current user id stored in local native storage\n * @example const userId = await Courier.userId\n */\n get userId(): Promise<string | undefined> {\n return CourierReactNativeModules.getUserId();\n }\n\n /**\n * Signs user in and persists signin in between sessions\n * using native level storage apis\n * \n * @example\n * ```\n *await Courier.signIn({\n accessToken: YOUR_COURIER_GENERATED_JWT,\n userId: YOUR_USER_ID,\n })\n * ```\n * Your access token should be generated using this endpoint\n * that is requested from your backend\n * https://www.courier.com/docs/reference/auth/issue-token/\n */\n public signIn({\n accessToken,\n userId,\n }: {\n accessToken: string;\n userId: string;\n }): Promise<void> {\n return CourierReactNativeModules.signIn(userId, accessToken);\n }\n\n /**\n * Logs user out of native level user storage.\n * This will clear the userId, accessToken, and apns / fcm tokens and\n * delete the matching devices apns / fcm tokens for the user in Courier token management\n * @example await Courier.signOut()\n */\n public signOut(): Promise<void> {\n return CourierReactNativeModules.signOut();\n }\n\n /**\n * Sets the current Apple Push Notification Service (APNS) token\n * using Courier token management apis\n * @example const apnsToken = await Courier.apnsToken\n */\n get apnsToken(): Promise<string | undefined> {\n if (Platform.OS !== 'ios') return Promise.resolve(undefined);\n return CourierReactNativeModules.getApnsToken();\n }\n\n /**\n * Sets the current Firebase Cloud Messaging (FCM) token\n * using Courier token management apis\n * @example const fcmToken = await Courier.fcmToken\n */\n get fcmToken(): Promise<string | undefined> {\n return CourierReactNativeModules.getFcmToken();\n }\n\n /**\n * Sets the current Firebase Cloud Messaging (FCM) token\n * using Courier token management apis\n * @example await setFcmToken('asdf...asdf')\n */\n public setFcmToken(token: string): Promise<void> {\n return CourierReactNativeModules.setFcmToken(token);\n }\n\n /**\n * Hits the Courier /send endpoint and sends a test push notification\n * @example\n * ```\n *const messageId = await sendPush({\n authKey: YOUR_AUTH_KEY_THAT_SHOULD_NOT_STAY_IN_YOUR_PRODUCTION_APP,\n userId: USER_ID,\n title: 'This is a title',\n body: 'This is a body',\n providers: [CourierProvider.APNS, CourierProvider.FCM],\n });\n * ```\n * @returns promise\n */\n public sendPush({\n authKey,\n userId,\n title,\n body,\n providers,\n }: {\n authKey: string;\n userId: string;\n title?: string;\n body?: string;\n providers: CourierProvider[];\n }): Promise<string> {\n return CourierReactNativeModules.sendPush(\n authKey,\n userId,\n title,\n body,\n providers\n );\n }\n\n /**\n * Gets notification permission status at a system level.\n * @example const permissionStatus = await Courier.getNotificationPermissionStatus()\n */\n get notificationPermissionStatus(): Promise<string> {\n return CourierReactNativeModules.getNotificationPermissionStatus();\n }\n\n /**\n * Requests notification permission status at a system level.\n * Returns the string associated with the permission status.\n * Will return the current status and will not present a popup\n * if the user has already been asked for permission.\n * @example const permissionStatus = await Courier.requestNotificationPermission()\n */\n public requestNotificationPermission(): Promise<string> {\n return CourierReactNativeModules.requestNotificationPermission();\n }\n\n /**\n * Sets the push notification presentation style when the app is in the foreground\n * This does not affect how the notification is shown when the app is killed or in the background states\n *\n * Defaults to sound, badge, list and/or banner.\n *\n * @example iOSForegroundPresentationOptions({options: ['sound']});\n */\n public iOSForegroundPresentationOptions({\n options,\n }: {\n options: ('sound' | 'badge' | 'list' | 'banner')[];\n }): Promise<void> {\n // Only works on iOS\n if (Platform.OS !== 'ios') return Promise.resolve();\n\n const normalizedParams = Array.from(new Set(options));\n return CourierReactNativeModules.iOSForegroundPresentationOptions({\n options: normalizedParams,\n });\n }\n\n /**\n * @example \n *```\n const unsubPushListeners = () => {\n return Courier.registerPushNotificationListeners<YOUR_NOTIFICATION_TYPE>({\n onPushNotificationClicked: (push) => {\n ...\n },\n onPushNotificationDelivered: (push) => {\n ...\n },\n })\n }\n\n // To unsubscribe the listeners\n unsubPushListeners()\n *```\n * @returns function that can be used to unsubscribe from registered listeners\n */\n public registerPushNotificationListeners({\n onPushNotificationClicked,\n onPushNotificationDelivered,\n }: {\n onPushNotificationClicked: (_push: any) => void;\n onPushNotificationDelivered: (_push: any) => void;\n }) {\n let notificationClickedListener: EmitterSubscription;\n let notificationDeliveredListener: EmitterSubscription;\n\n // Android\n if (Platform.OS === 'android') {\n notificationClickedListener = DeviceEventEmitter.addListener(\n this.PUSH_NOTIFICATION_CLICKED,\n (event: any) => {\n try {\n onPushNotificationClicked(JSON.parse(event));\n } catch (error) {\n console.log(error);\n }\n }\n );\n\n notificationDeliveredListener = DeviceEventEmitter.addListener(\n this.PUSH_NOTIFICATION_DELIVERED,\n (event: any) => {\n try {\n onPushNotificationDelivered(JSON.parse(event));\n } catch (error) {\n console.log(error);\n }\n }\n );\n }\n\n // iOS\n if (Platform.OS === 'ios') {\n notificationClickedListener = CourierEventEmitter.addListener(\n this.PUSH_NOTIFICATION_CLICKED,\n (event: any) => {\n try {\n onPushNotificationClicked(JSON.parse(event));\n } catch (error) {\n console.log(error);\n }\n }\n );\n\n notificationDeliveredListener = CourierEventEmitter.addListener(\n this.PUSH_NOTIFICATION_DELIVERED,\n (event: any) => {\n try {\n onPushNotificationDelivered(JSON.parse(event));\n } catch (error) {\n console.log(error);\n }\n }\n );\n }\n\n // When listener is registered\n // Attempt to fetch the last message that was clicked\n // This is needed for when the app is killed and the\n // user launched the app by clicking on a notifications\n CourierReactNativeModules.registerPushNotificationClickedOnKilledState();\n\n return () => {\n notificationClickedListener.remove();\n notificationDeliveredListener.remove();\n };\n }\n}\n\nexport default new Courier();\n"],"mappings":";;AAAA;;AACA;AACA,SACEA,aADF,EAEEC,QAFF,EAGEC,kBAHF,EAIEC,kBAJF,QAMO,cANP;AAQA,MAAMC,aAAa,GAChB,4FAA2FH,QAAQ,CAACI,MAAT,CAC1F;EAAEC,GAAG,EAAE,gCAAP;EAAyCC,OAAO,EAAE;AAAlD,CAD0F,CAE1F,sDAFF,GAGC,6CAJH;AAMA,MAAMC,yBAAyB,GAAGR,aAAa,CAACS,kBAAd,GAC9BT,aAAa,CAACS,kBADgB,GAE9B,IAAIC,KAAJ,CACE,EADF,EAEE;EACEC,GAAG,GAAG;IACJ,MAAM,IAAIC,KAAJ,CAAUR,aAAV,CAAN;EACD;;AAHH,CAFF,CAFJ;AAWA,MAAMS,mBAAmB,GAAG,IAAIV,kBAAJ,CAC1BH,aAAa,CAACS,kBADY,CAA5B;AAIA,WAAYK,eAAZ;;WAAYA,e;EAAAA,e;EAAAA,e;GAAAA,e,KAAAA,e;;AAKZ,MAAMC,OAAN,CAAc;EAKLC,WAAW,GAAG;IAAA,mDAJgB,y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AD,CAAzB;QACD,CAFD,CAEE,OAAOP,KAAP,EAAc;UACdC,OAAO,CAACC,GAAR,CAAYF,KAAZ;QACD;MACF,CAR2B,CAA9B;MAWAwC,6BAA6B,GAAGnD,mBAAmB,CAACiB,WAApB,CAC9B,KAAKsC,2BADyB,EAE7BrC,KAAD,IAAgB;QACd,IAAI;UACF+B,2BAA2B,CAACI,IAAI,CAACC,KAAL,CAAWpC,KAAX,CAAD,CAA3B;QACD,CAFD,CAEE,OAAOP,KAAP,EAAc;UACdC,OAAO,CAACC,GAAR,CAAYF,KAAZ;QACD;MACF,CAR6B,CAAhC;IAUD,CApDA,CAsDD;IACA;IACA;IACA;;;IACAhB,yBAAyB,CAAC6D,4CAA1B;IAEA,OAAO,MAAM;MACXN,2BAA2B,CAAClC,MAA5B;MACAmC,6BAA6B,CAACnC,MAA9B;IACD,CAHD;EAID;;AAzSW;;AA4Sd,eAAe,IAAId,OAAJ,EAAf"}
1
+ {"version":3,"names":["NativeModules","NativeEventEmitter","Platform","CourierInboxListener","CourierInboxView","LINKING_ERROR","select","ios","default","CourierReactNativeModules","CourierReactNativeModule","Proxy","get","Error","CourierEventEmitter","Courier","_isDebugging","constructor","setDefaults","shared","_sharedInstance","Promise","all","setIsDebugging","__DEV__","error","console","log","isDebugging","_this$debugListener","debugListener","remove","addListener","event","setDebugMode","userId","getUserId","signIn","props","accessToken","clientKey","readMessage","messageId","unreadMessage","readAllInboxMessages","addInboxListener","inboxListener","onInitialLoad","onError","onMessagesChanged","messages","unreadMessageCount","totalMessageCount","canPaginate","listenerId","removeInboxListener","refreshInbox"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SACEA,aAAa,EACbC,kBAAkB,EAElBC,QAAQ,QACH,cAAc;AAErB,SAASC,oBAAoB,QAAQ,+BAA+B;AAEpE,SAASC,gBAAgB,QAAQ,0BAA0B;AAE3D,MAAMC,aAAa,GAChB,2FAA0F,GAC3FH,QAAQ,CAACI,MAAM,CAAC;EAAEC,GA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B,CAACkB,WAAW,CAAC,kBAAkB,EAAE,MAAM;QACtFM,KAAK,CAACS,aAAa,CAAE,CAAC;MACxB,CAAC,CAAC;IACJ;IAEA,IAAIT,KAAK,CAACU,OAAO,EAAE;MACjBF,aAAa,CAACE,OAAO,GAAGlC,mBAAmB,CAACkB,WAAW,CAAC,YAAY,EAAEC,KAAK,IAAI;QAC7EK,KAAK,CAACU,OAAO,CAAEf,KAAK,CAAC;MACvB,CAAC,CAAC;IACJ;IAEA,IAAIK,KAAK,CAACW,iBAAiB,EAAE;MAC3BH,aAAa,CAACG,iBAAiB,GAAGnC,mBAAmB,CAACkB,WAAW,CAAC,sBAAsB,EAAEC,KAAK,IAAI;QACjGK,KAAK,CAACW,iBAAiB,CACrBhB,KAAK,CAACiB,QAAQ,EACdjB,KAAK,CAACkB,kBAAkB,EACxBlB,KAAK,CAACmB,iBAAiB,EACvBnB,KAAK,CAACoB,WACR,CAAC;MACH,CAAC,CAAC;IACJ;IAEAP,aAAa,CAACQ,UAAU,GAAG7C,yBAAyB,CAACoC,gBAAgB,CAAC,IAAI,CAAC;IAE3E,OAAOC,aAAa;EAEtB;;EAEA;AACF;AACA;AACA;AACA;EACSS,mBAAmBA,CAACjB,KAA6B,EAAU;IAChE,OAAO7B,yBAAyB,CAAC8C,mBAAmB,CAACjB,KAAK,CAACgB,UAAU,CAAC;EACxE;;EAEA;AACF;AACA;AACA;AACA;EACE,MAAaE,YAAYA,CAAA,EAAkB;IACzC,OAAO/C,yBAAyB,CAAC+C,YAAY,CAAC,CAAC;EACjD;AAEF;AAEA,eAAezC,OAAO"}
@@ -0,0 +1,18 @@
1
+ import Courier from "@trycourier/courier-react-native";
2
+ export class CourierInboxListener {
3
+ remove() {
4
+ var _this$onInitialLoad, _this$onError, _this$onMessagesChang;
5
+ // Remove the native inbox listener
6
+ if (this.listenerId) {
7
+ Courier.shared.removeInboxListener({
8
+ listenerId: this.listenerId
9
+ });
10
+ }
11
+
12
+ // Remove the emitters
13
+ (_this$onInitialLoad = this.onInitialLoad) === null || _this$onInitialLoad === void 0 ? void 0 : _this$onInitialLoad.remove();
14
+ (_this$onError = this.onError) === null || _this$onError === void 0 ? void 0 : _this$onError.remove();
15
+ (_this$onMessagesChang = this.onMessagesChanged) === null || _this$onMessagesChang === void 0 ? void 0 : _this$onMessagesChang.remove();
16
+ }
17
+ }
18
+ //# sourceMappingURL=CourierInboxListener.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Courier","CourierInboxListener","remove","_this$onInitialLoad","_this$onError","_this$onMessagesChang","listenerId","shared","removeInboxListener","onInitialLoad","onError","onMessagesChanged"],"sourceRoot":"../../../src","sources":["models/CourierInboxListener.tsx"],"mappings":"AACA,OAAOA,OAAO,MAAM,kCAAkC;AAEtD,OAAO,MAAMC,oBAAoB,CAAC;EAOzBC,MAAMA,CAAA,EAAG;IAAA,IAAAC,mBAAA,EAAAC,aAAA,EAAAC,qBAAA;IAEd;IACA,IAAI,IAAI,CAACC,UAAU,EAAE;MACnBN,OAAO,CAACO,MAAM,CAACC,mBAAmB,CAAC;QAAEF,UAAU,EAAE,IAAI,CAACA;MAAW,CAAC,CAAC;IACrE;;IAEA;IACA,CAAAH,mBAAA,OAAI,CAACM,aAAa,cAAAN,mBAAA,uBAAlBA,mBAAA,CAAoBD,MAAM,CAAC,CAAC;IAC5B,CAAAE,aAAA,OAAI,CAACM,OAAO,cAAAN,aAAA,uBAAZA,aAAA,CAAcF,MAAM,CAAC,CAAC;IACtB,CAAAG,qBAAA,OAAI,CAACM,iBAAiB,cAAAN,qBAAA,uBAAtBA,qBAAA,CAAwBH,MAAM,CAAC,CAAC;EAElC;AAEF"}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=CourierInboxTheme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["models/CourierInboxTheme.tsx"],"mappings":""}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=InboxAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["models/InboxAction.tsx"],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=InboxMessage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["models/InboxMessage.tsx"],"mappings":""}
@@ -0,0 +1,45 @@
1
+ import React from "react";
2
+ import { Platform, requireNativeComponent, UIManager } from "react-native";
3
+ const ComponentName = 'CourierReactNativeView';
4
+ const LINKING_ERROR = `The package '@trycourier/courier-react-native' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
5
+ ios: "- You have run 'pod install'\n",
6
+ default: ''
7
+ }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
8
+ const CourierInbox = UIManager.getViewManagerConfig(ComponentName) != null ? requireNativeComponent(ComponentName) : () => {
9
+ throw new Error(LINKING_ERROR);
10
+ };
11
+ export const CourierInboxView = props => {
12
+ const onClickInboxMessageAtIndex = event => {
13
+ // Parse the native event data
14
+ if (props.onClickInboxMessageAtIndex) {
15
+ const index = event.nativeEvent["index"];
16
+ const message = event.nativeEvent["message"];
17
+ props.onClickInboxMessageAtIndex(message, index);
18
+ }
19
+ };
20
+ const onClickInboxActionForMessageAtIndex = event => {
21
+ // Parse the native event data
22
+ if (props.onClickInboxActionForMessageAtIndex) {
23
+ const index = event.nativeEvent["index"];
24
+ const action = event.nativeEvent["action"];
25
+ const message = event.nativeEvent["message"];
26
+ props.onClickInboxActionForMessageAtIndex(action, message, index);
27
+ }
28
+ };
29
+ const onScrollInbox = event => {
30
+ // Parse the native event data
31
+ if (props.onScrollInbox) {
32
+ const contentOffset = event.nativeEvent["contentOffset"];
33
+ props.onScrollInbox(contentOffset["y"], contentOffset["x"]);
34
+ }
35
+ };
36
+ return /*#__PURE__*/React.createElement(CourierInbox, {
37
+ lightTheme: props.lightTheme,
38
+ darkTheme: props.darkTheme,
39
+ onClickInboxMessageAtIndex: onClickInboxMessageAtIndex,
40
+ onClickInboxActionForMessageAtIndex: onClickInboxActionForMessageAtIndex,
41
+ onScrollInbox: onScrollInbox,
42
+ style: props.style
43
+ });
44
+ };
45
+ //# sourceMappingURL=CourierInboxView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","Platform","requireNativeComponent","UIManager","ComponentName","LINKING_ERROR","select","ios","default","CourierInbox","getViewManagerConfig","Error","CourierInboxView","props","onClickInboxMessageAtIndex","event","index","nativeEvent","message","onClickInboxActionForMessageAtIndex","action","onScrollInbox","contentOffset","createElement","lightTheme","darkTheme","style"],"sourceRoot":"../../../src","sources":["views/CourierInboxView.tsx"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,QAAQ,EAAEC,sBAAsB,EAAEC,SAAS,QAAmB,cAAc;AAcrF,MAAMC,aAAa,GAAG,wBAAwB;AAE9C,MAAMC,aAAa,GAChB,2FAA0F,GAC3FJ,QAAQ,CAACK,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,YAAY,GAChBN,SAAS,CAACO,oBAAoB,CAACN,aAAa,CAAC,IAAI,IAAI,GACjDF,sBAAsB,CAAwBE,aAAa,CAAC,GAC5D,MAAM;EACJ,MAAM,IAAIO,KAAK,CAACN,aAAa,CAAC;AAChC,CAAC;AAEP,OAAO,MAAMO,gBAAgB,GAAIC,KAA4B,IAAK;EAEhE,MAAMC,0BAA0B,GAAIC,KAAU,IAAK;IAEjD;IACA,IAAIF,KAAK,CAACC,0BAA0B,EAAE;MAEpC,MAAME,KAAK,GAAGD,KAAK,CAACE,WAAW,CAAC,OAAO,CAAC;MACxC,MAAMC,OAAO,GAAGH,KAAK,CAACE,WAAW,CAAC,SAAS,CAAiB;MAE5DJ,KAAK,CAACC,0BAA0B,CAACI,OAAO,EAAEF,KAAK,CAAC;IAElD;EAEF,CAAC;EAED,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