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

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 +48 -0
  15. package/ios/{CourierReactNative.swift → CourierReactNativeModule.swift} +165 -45
  16. package/ios/CourierReactNativeViewManager.m +15 -0
  17. package/ios/CourierReactNativeViewManager.swift +348 -0
  18. package/lib/commonjs/index.js +68 -213
  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 +62 -212
  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 +34 -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 +188 -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
@@ -3,57 +3,45 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = exports.CourierProvider = void 0;
7
-
6
+ Object.defineProperty(exports, "CourierInboxView", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _CourierInboxView.CourierInboxView;
10
+ }
11
+ });
12
+ exports.default = void 0;
8
13
  var _reactNative = require("react-native");
9
-
10
- 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; }
11
-
12
- const LINKING_ERROR = `The package '@trycourier/courier-react-native' doesn't seem to be linked. Make sure: \n\n${_reactNative.Platform.select({
14
+ var _CourierInboxListener = require("./models/CourierInboxListener");
15
+ var _CourierInboxView = require("./views/CourierInboxView");
16
+ const LINKING_ERROR = `The package 'courier-react-native' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
13
17
  ios: "- You have run 'pod install'\n",
14
18
  default: ''
15
- })}- You rebuilt the app after installing the package\n` + `- You are not using Expo managed workflow\n`;
16
- const CourierReactNativeModules = _reactNative.NativeModules.CourierReactNative ? _reactNative.NativeModules.CourierReactNative : new Proxy({}, {
19
+ }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
20
+ const CourierReactNativeModules = _reactNative.NativeModules.CourierReactNativeModule ? _reactNative.NativeModules.CourierReactNativeModule : new Proxy({}, {
17
21
  get() {
18
22
  throw new Error(LINKING_ERROR);
19
23
  }
20
-
21
24
  });
22
- const CourierEventEmitter = new _reactNative.NativeEventEmitter(_reactNative.NativeModules.CourierReactNative);
23
- let CourierProvider;
24
- exports.CourierProvider = CourierProvider;
25
-
26
- (function (CourierProvider) {
27
- CourierProvider["FCM"] = "firebase-fcm";
28
- CourierProvider["APNS"] = "apn";
29
- })(CourierProvider || (exports.CourierProvider = CourierProvider = {}));
30
-
25
+ const CourierEventEmitter = new _reactNative.NativeEventEmitter(_reactNative.NativeModules.CourierReactNativeModule);
31
26
  class Courier {
32
27
  constructor() {
33
- _defineProperty(this, "PUSH_NOTIFICATION_CLICKED", 'pushNotificationClicked');
34
-
35
- _defineProperty(this, "PUSH_NOTIFICATION_DELIVERED", 'pushNotificationDelivered');
36
-
37
- _defineProperty(this, "_isDebugging", false);
38
-
39
- _defineProperty(this, "debugListener", void 0);
40
-
41
28
  // Sets the initial SDK values
42
29
  // Defaults to React Native level debugging
43
30
  // and will show all foreground notification styles in iOS
44
31
  this.setDefaults();
45
32
  }
46
-
47
33
  async setDefaults() {
48
34
  try {
49
- await Promise.all([this.setIsDebugging(__DEV__), this.iOSForegroundPresentationOptions({
50
- options: ['sound', 'badge', 'list', 'banner']
51
- })]);
35
+ await Promise.all([this.setIsDebugging(__DEV__)
36
+ // this.iOSForegroundPresentationOptions({
37
+ // options: ['sound', 'badge', 'list', 'banner'],
38
+ // }),
39
+ ]);
52
40
  } catch (error) {
53
41
  console.log(error);
54
42
  }
55
43
  }
56
-
44
+ _isDebugging = false;
57
45
  /**
58
46
  * Tells native Courier SDKs to show or hide logs.
59
47
  * Defaults to the React __DEV__ mode
@@ -61,33 +49,31 @@ class Courier {
61
49
  */
62
50
  async setIsDebugging(isDebugging) {
63
51
  var _this$debugListener;
64
-
65
52
  // Remove the existing listener if needed
66
- (_this$debugListener = this.debugListener) === null || _this$debugListener === void 0 ? void 0 : _this$debugListener.remove(); // Set a new listener
67
- // listener needs to be registered first to catch the event
53
+ (_this$debugListener = this.debugListener) === null || _this$debugListener === void 0 ? void 0 : _this$debugListener.remove();
68
54
 
55
+ // Set a new listener
56
+ // listener needs to be registered first to catch the event
69
57
  if (isDebugging) {
70
58
  this.debugListener = CourierEventEmitter.addListener('courierDebugEvent', event => {
71
59
  console.log('\x1b[36m%s\x1b[0m', 'COURIER', event);
72
60
  });
73
61
  }
74
-
75
62
  this._isDebugging = await CourierReactNativeModules.setDebugMode(isDebugging);
76
63
  return this._isDebugging;
77
64
  }
78
-
79
65
  get isDebugging() {
80
66
  return this._isDebugging;
81
67
  }
68
+
82
69
  /**
83
70
  * Returns the current user id stored in local native storage
84
71
  * @example const userId = await Courier.userId
85
72
  */
86
-
87
-
88
73
  get userId() {
89
74
  return CourierReactNativeModules.getUserId();
90
75
  }
76
+
91
77
  /**
92
78
  * Signs user in and persists signin in between sessions
93
79
  * using native level storage apis
@@ -96,6 +82,7 @@ class Courier {
96
82
  * ```
97
83
  *await Courier.signIn({
98
84
  accessToken: YOUR_COURIER_GENERATED_JWT,
85
+ clientKey: YOUR_CLIENT_KEY,
99
86
  userId: YOUR_USER_ID,
100
87
  })
101
88
  * ```
@@ -103,202 +90,70 @@ class Courier {
103
90
  * that is requested from your backend
104
91
  * https://www.courier.com/docs/reference/auth/issue-token/
105
92
  */
106
-
107
-
108
- signIn(_ref) {
109
- let {
110
- accessToken,
111
- userId
112
- } = _ref;
113
- return CourierReactNativeModules.signIn(userId, accessToken);
93
+ signIn(props) {
94
+ return CourierReactNativeModules.signIn(props.accessToken, props.clientKey ?? null, props.userId);
114
95
  }
115
- /**
116
- * Logs user out of native level user storage.
117
- * This will clear the userId, accessToken, and apns / fcm tokens and
118
- * delete the matching devices apns / fcm tokens for the user in Courier token management
119
- * @example await Courier.signOut()
120
- */
121
-
122
96
 
123
- signOut() {
124
- return CourierReactNativeModules.signOut();
125
- }
126
97
  /**
127
- * Sets the current Apple Push Notification Service (APNS) token
128
- * using Courier token management apis
129
- * @example const apnsToken = await Courier.apnsToken
98
+ * TODO
99
+ * @param props
100
+ * @returns
130
101
  */
131
-
132
-
133
- get apnsToken() {
134
- if (_reactNative.Platform.OS !== 'ios') return Promise.resolve(undefined);
135
- return CourierReactNativeModules.getApnsToken();
102
+ readMessage(props) {
103
+ return CourierReactNativeModules.readMessage(props.messageId);
136
104
  }
137
- /**
138
- * Sets the current Firebase Cloud Messaging (FCM) token
139
- * using Courier token management apis
140
- * @example const fcmToken = await Courier.fcmToken
141
- */
142
-
143
105
 
144
- get fcmToken() {
145
- return CourierReactNativeModules.getFcmToken();
146
- }
147
106
  /**
148
- * Sets the current Firebase Cloud Messaging (FCM) token
149
- * using Courier token management apis
150
- * @example await setFcmToken('asdf...asdf')
107
+ * TODO
108
+ * @param props
109
+ * @returns
151
110
  */
152
-
153
-
154
- setFcmToken(token) {
155
- return CourierReactNativeModules.setFcmToken(token);
111
+ unreadMessage(props) {
112
+ return CourierReactNativeModules.unreadMessage(props.messageId);
156
113
  }
157
- /**
158
- * Hits the Courier /send endpoint and sends a test push notification
159
- * @example
160
- * ```
161
- *const messageId = await sendPush({
162
- authKey: YOUR_AUTH_KEY_THAT_SHOULD_NOT_STAY_IN_YOUR_PRODUCTION_APP,
163
- userId: USER_ID,
164
- title: 'This is a title',
165
- body: 'This is a body',
166
- providers: [CourierProvider.APNS, CourierProvider.FCM],
167
- });
168
- * ```
169
- * @returns promise
170
- */
171
-
172
114
 
173
- sendPush(_ref2) {
174
- let {
175
- authKey,
176
- userId,
177
- title,
178
- body,
179
- providers
180
- } = _ref2;
181
- return CourierReactNativeModules.sendPush(authKey, userId, title, body, providers);
182
- }
183
115
  /**
184
- * Gets notification permission status at a system level.
185
- * @example const permissionStatus = await Courier.getNotificationPermissionStatus()
116
+ * TODO
117
+ * @param props
118
+ * @returns
186
119
  */
187
-
188
-
189
- get notificationPermissionStatus() {
190
- return CourierReactNativeModules.getNotificationPermissionStatus();
120
+ readAllInboxMessages() {
121
+ return CourierReactNativeModules.readAllInboxMessages();
191
122
  }
192
- /**
193
- * Requests notification permission status at a system level.
194
- * Returns the string associated with the permission status.
195
- * Will return the current status and will not present a popup
196
- * if the user has already been asked for permission.
197
- * @example const permissionStatus = await Courier.requestNotificationPermission()
198
- */
199
-
200
123
 
201
- requestNotificationPermission() {
202
- return CourierReactNativeModules.requestNotificationPermission();
203
- }
204
124
  /**
205
- * Sets the push notification presentation style when the app is in the foreground
206
- * This does not affect how the notification is shown when the app is killed or in the background states
207
- *
208
- * Defaults to sound, badge, list and/or banner.
209
- *
210
- * @example iOSForegroundPresentationOptions({options: ['sound']});
125
+ * TODO
126
+ * @param props
127
+ * @returns
211
128
  */
212
-
213
-
214
- iOSForegroundPresentationOptions(_ref3) {
215
- let {
216
- options
217
- } = _ref3;
218
- // Only works on iOS
219
- if (_reactNative.Platform.OS !== 'ios') return Promise.resolve();
220
- const normalizedParams = Array.from(new Set(options));
221
- return CourierReactNativeModules.iOSForegroundPresentationOptions({
222
- options: normalizedParams
223
- });
224
- }
225
- /**
226
- * @example
227
- *```
228
- const unsubPushListeners = () => {
229
- return Courier.registerPushNotificationListeners<YOUR_NOTIFICATION_TYPE>({
230
- onPushNotificationClicked: (push) => {
231
- ...
232
- },
233
- onPushNotificationDelivered: (push) => {
234
- ...
235
- },
236
- })
237
- }
238
- // To unsubscribe the listeners
239
- unsubPushListeners()
240
- *```
241
- * @returns function that can be used to unsubscribe from registered listeners
242
- */
243
-
244
-
245
- registerPushNotificationListeners(_ref4) {
246
- let {
247
- onPushNotificationClicked,
248
- onPushNotificationDelivered
249
- } = _ref4;
250
- let notificationClickedListener;
251
- let notificationDeliveredListener; // Android
252
-
253
- if (_reactNative.Platform.OS === 'android') {
254
- notificationClickedListener = _reactNative.DeviceEventEmitter.addListener(this.PUSH_NOTIFICATION_CLICKED, event => {
255
- try {
256
- onPushNotificationClicked(JSON.parse(event));
257
- } catch (error) {
258
- console.log(error);
259
- }
129
+ addInboxListener(props) {
130
+ // Create the initial listeners
131
+ const inboxListener = new _CourierInboxListener.CourierInboxListener();
132
+ if (props.onInitialLoad) {
133
+ inboxListener.onInitialLoad = CourierEventEmitter.addListener('inboxInitialLoad', () => {
134
+ props.onInitialLoad();
260
135
  });
261
- notificationDeliveredListener = _reactNative.DeviceEventEmitter.addListener(this.PUSH_NOTIFICATION_DELIVERED, event => {
262
- try {
263
- onPushNotificationDelivered(JSON.parse(event));
264
- } catch (error) {
265
- console.log(error);
266
- }
267
- });
268
- } // iOS
269
-
270
-
271
- if (_reactNative.Platform.OS === 'ios') {
272
- notificationClickedListener = CourierEventEmitter.addListener(this.PUSH_NOTIFICATION_CLICKED, event => {
273
- try {
274
- onPushNotificationClicked(JSON.parse(event));
275
- } catch (error) {
276
- console.log(error);
277
- }
136
+ }
137
+ if (props.onError) {
138
+ inboxListener.onError = CourierEventEmitter.addListener('inboxError', event => {
139
+ console.log(event);
140
+ props.onError();
278
141
  });
279
- notificationDeliveredListener = CourierEventEmitter.addListener(this.PUSH_NOTIFICATION_DELIVERED, event => {
280
- try {
281
- onPushNotificationDelivered(JSON.parse(event));
282
- } catch (error) {
283
- console.log(error);
284
- }
142
+ }
143
+ if (props.onMessagesChanged) {
144
+ inboxListener.onMessagesChanged = CourierEventEmitter.addListener('inboxMessagesChanged', event => {
145
+ console.log('onMessagesChanged');
146
+ console.log(event);
147
+ props.onMessagesChanged(event.messages);
285
148
  });
286
- } // When listener is registered
287
- // Attempt to fetch the last message that was clicked
288
- // This is needed for when the app is killed and the
289
- // user launched the app by clicking on a notifications
290
-
291
-
292
- CourierReactNativeModules.registerPushNotificationClickedOnKilledState();
293
- return () => {
294
- notificationClickedListener.remove();
295
- notificationDeliveredListener.remove();
296
- };
149
+ }
150
+ inboxListener.listenerId = CourierReactNativeModules.addInboxListener(null);
151
+ return inboxListener;
152
+ }
153
+ removeInboxListener(props) {
154
+ return CourierReactNativeModules.removeInboxListener(props.listenerId);
297
155
  }
298
-
299
156
  }
300
-
301
157
  var _default = new Courier();
302
-
303
158
  exports.default = _default;
304
159
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["LINKING_ERROR","Platform","select","ios","default","CourierReactNativeModules","NativeModules","CourierReactNative","Proxy","get","Error","CourierEventEmitter","NativeEventEmitter","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","DeviceEventEmitter","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":";;;;;;;AAEA;;;;AAQA,MAAMA,aAAa,GAChB,4FAA2FC,qBAAA,CAASC,MAAT,CAC1F;EAAEC,GAAG,EAAE,gCAAP;EAAyCC,OAAO,EAAE;AAAlD,CAD0F,CAE1F,sDAFF,GAGC,6CAJH;AAMA,MAAMC,yBAAyB,GAAGC,0BAAA,CAAcC,kBAAd,GAC9BD,0BAAA,CAAcC,kBADgB,GAE9B,IAAIC,KAAJ,CACE,EADF,EAEE;EACEC,GAAG,GAAG;IACJ,MAAM,IAAIC,KAAJ,CAAUV,aAAV,CAAN;EACD;;AAHH,CAFF,CAFJ;AAWA,MAAMW,mBAAmB,GAAG,IAAIC,+BAAJ,CAC1BN,0BAAA,CAAcC,kBADY,CAA5B;IAIYM,e;;;WAAAA,e;EAAAA,e;EAAAA,e;GAAAA,e,+BAAAA,e;;AAKZ,MAAMC,OAAN,CAAc;EAKLC,WAAW,GAAG;IAAA,m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,KAAX,CAAD,CAAzB;QACD,CAFD,CAEE,OAAOP,KAAP,EAAc;UACdC,OAAO,CAACC,GAAR,CAAYF,KAAZ;QACD;MACF,CAR2B,CAA9B;MAWAwC,6BAA6B,GAAGpD,mBAAmB,CAACkB,WAApB,CAC9B,KAAKuC,2BADyB,EAE7BtC,KAAD,IAAgB;QACd,IAAI;UACF+B,2BAA2B,CAACK,IAAI,CAACC,KAAL,CAAWrC,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;;;IACAlB,yBAAyB,CAACgE,4CAA1B;IAEA,OAAO,MAAM;MACXP,2BAA2B,CAAClC,MAA5B;MACAmC,6BAA6B,CAACnC,MAA9B;IACD,CAHD;EAID;;AAzSW;;eA4SC,IAAId,OAAJ,E"}
1
+ {"version":3,"names":["_reactNative","require","_CourierInboxListener","_CourierInboxView","LINKING_ERROR","Platform","select","ios","default","CourierReactNativeModules","NativeModules","CourierReactNativeModule","Proxy","get","Error","CourierEventEmitter","NativeEventEmitter","Courier","constructor","setDefaults","Promise","all","setIsDebugging","__DEV__","error","console","log","_isDebugging","isDebugging","_this$debugListener","debugListener","remove","addListener","event","setDebugMode","userId","getUserId","signIn","props","accessToken","clientKey","readMessage","messageId","unreadMessage","readAllInboxMessages","addInboxListener","inboxListener","CourierInboxListener","onInitialLoad","onError","onMessagesChanged","messages","listenerId","removeInboxListener","_default","exports"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAMA,IAAAC,qBAAA,GAAAD,OAAA;AAGA,IAAAE,iBAAA,GAAAF,OAAA;AAEA,MAAMG,aAAa,GAChB,+EAA8E,GAC/EC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AA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AI;QAC7ER,OAAO,CAACC,GAAG,CAACO,KAAK,CAAC;QAClBK,KAAK,CAACW,OAAO,CAAE,CAAC;MAClB,CAAC,CAAC;IACJ;IAEA,IAAIX,KAAK,CAACY,iBAAiB,EAAE;MAC3BJ,aAAa,CAACI,iBAAiB,GAAGnC,mBAAmB,CAACiB,WAAW,CAAC,sBAAsB,EAAEC,KAAK,IAAI;QACjGR,OAAO,CAACC,GAAG,CAAC,mBAAmB,CAAC;QAChCD,OAAO,CAACC,GAAG,CAACO,KAAK,CAAC;QAClBK,KAAK,CAACY,iBAAiB,CACrBjB,KAAK,CAACkB,QACR,CAAC;MACH,CAAC,CAAC;IACJ;IAEAL,aAAa,CAACM,UAAU,GAAG3C,yBAAyB,CAACoC,gBAAgB,CAAC,IAAI,CAAC;IAE3E,OAAOC,aAAa;EAEtB;EAEOO,mBAAmBA,CAACf,KAA6B,EAAU;IAChE,OAAO7B,yBAAyB,CAAC4C,mBAAmB,CAACf,KAAK,CAACc,UAAU,CAAC;EACxE;AAEF;AAAC,IAAAE,QAAA,GAEc,IAAIrC,OAAO,CAAC,CAAC;AAAAsC,OAAA,CAAA/C,OAAA,GAAA8C,QAAA"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.CourierInboxListener = void 0;
7
+ var _courierReactNative = _interopRequireDefault(require("courier-react-native"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ class CourierInboxListener {
10
+ remove() {
11
+ var _this$onInitialLoad, _this$onError, _this$onMessagesChang;
12
+ // Remove the native inbox listener
13
+ if (this.listenerId) {
14
+ _courierReactNative.default.removeInboxListener({
15
+ listenerId: this.listenerId
16
+ });
17
+ }
18
+
19
+ // Remove the emitters
20
+ (_this$onInitialLoad = this.onInitialLoad) === null || _this$onInitialLoad === void 0 ? void 0 : _this$onInitialLoad.remove();
21
+ (_this$onError = this.onError) === null || _this$onError === void 0 ? void 0 : _this$onError.remove();
22
+ (_this$onMessagesChang = this.onMessagesChanged) === null || _this$onMessagesChang === void 0 ? void 0 : _this$onMessagesChang.remove();
23
+ }
24
+ }
25
+ exports.CourierInboxListener = CourierInboxListener;
26
+ //# sourceMappingURL=CourierInboxListener.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_courierReactNative","_interopRequireDefault","require","obj","__esModule","default","CourierInboxListener","remove","_this$onInitialLoad","_this$onError","_this$onMessagesChang","listenerId","Courier","removeInboxListener","onInitialLoad","onError","onMessagesChanged","exports"],"sourceRoot":"../../../src","sources":["models/CourierInboxListener.tsx"],"mappings":";;;;;;AACA,IAAAA,mBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA2C,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEpC,MAAMG,oBAAoB,CAAC;EAOzBC,MAAMA,CAAA,EAAG;IAAA,IAAAC,mBAAA,EAAAC,aAAA,EAAAC,qBAAA;IAEd;IACA,IAAI,IAAI,CAACC,UAAU,EAAE;MACnBC,2BAAO,CAACC,mBAAmB,CAAC;QAAEF,UAAU,EAAE,IAAI,CAACA;MAAW,CAAC,CAAC;IAC9D;;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;AAACU,OAAA,CAAAX,oBAAA,GAAAA,oBAAA"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=CourierInboxTheme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["models/CourierInboxTheme.tsx"],"mappings":""}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=InboxAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["models/InboxAction.tsx"],"mappings":""}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=InboxMessage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["models/InboxMessage.tsx"],"mappings":""}
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.CourierInboxView = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _reactNative = require("react-native");
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ const ComponentName = 'CourierReactNativeView';
11
+ const LINKING_ERROR = `The package 'courier-react-native' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
12
+ ios: "- You have run 'pod install'\n",
13
+ default: ''
14
+ }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
15
+ const CourierInbox = _reactNative.UIManager.getViewManagerConfig(ComponentName) != null ? (0, _reactNative.requireNativeComponent)(ComponentName) : () => {
16
+ throw new Error(LINKING_ERROR);
17
+ };
18
+ const CourierInboxView = props => {
19
+ const onClickInboxMessageAtIndex = event => {
20
+ // Parse the native event data
21
+ if (props.onClickInboxMessageAtIndex) {
22
+ const index = event.nativeEvent["index"];
23
+ const message = event.nativeEvent["message"];
24
+ props.onClickInboxMessageAtIndex(message, index);
25
+ }
26
+ };
27
+ const onClickInboxActionForMessageAtIndex = event => {
28
+ // Parse the native event data
29
+ if (props.onClickInboxActionForMessageAtIndex) {
30
+ const index = event.nativeEvent["index"];
31
+ const action = event.nativeEvent["action"];
32
+ const message = event.nativeEvent["message"];
33
+ props.onClickInboxActionForMessageAtIndex(action, message, index);
34
+ }
35
+ };
36
+ const onScrollInbox = event => {
37
+ // Parse the native event data
38
+ if (props.onScrollInbox) {
39
+ const contentOffset = event.nativeEvent["contentOffset"];
40
+ props.onScrollInbox(contentOffset["y"], contentOffset["x"]);
41
+ }
42
+ };
43
+ return /*#__PURE__*/_react.default.createElement(CourierInbox, {
44
+ lightTheme: props.lightTheme,
45
+ darkTheme: props.darkTheme,
46
+ onClickInboxMessageAtIndex: onClickInboxMessageAtIndex,
47
+ onClickInboxActionForMessageAtIndex: onClickInboxActionForMessageAtIndex,
48
+ onScrollInbox: onScrollInbox,
49
+ style: props.style
50
+ });
51
+ };
52
+ exports.CourierInboxView = CourierInboxView;
53
+ //# sourceMappingURL=CourierInboxView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","obj","__esModule","default","ComponentName","LINKING_ERROR","Platform","select","ios","CourierInbox","UIManager","getViewManagerConfig","requireNativeComponent","Error","CourierInboxView","props","onClickInboxMessageAtIndex","event","index","nativeEvent","message","onClickInboxActionForMessageAtIndex","action","onScrollInbox","contentOffset","createElement","lightTheme","darkTheme","style","exports"],"sourceRoot":"../../../src","sources":["views/CourierInboxView.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAAsF,SAAAD,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AActF,MAAMG,aAAa,GAAG,wBAAwB;AAE9C,MAAMC,aAAa,GAChB,+EAA8E,GAC/EC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEL,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMM,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