@trycourier/courier-react-native 2.3.2 → 2.4.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 (35) hide show
  1. package/android/src/main/java/com/courierreactnative/CourierEvents.kt +0 -10
  2. package/android/src/main/java/com/courierreactnative/CourierReactNativeModule.kt +35 -42
  3. package/ios/CourierAuthenticationListenerWrapper.swift +14 -0
  4. package/ios/CourierInboxListenerWrapper.swift +24 -0
  5. package/ios/CourierReactNativeModule.m +4 -2
  6. package/ios/CourierReactNativeModule.swift +71 -69
  7. package/lib/commonjs/index.js +82 -80
  8. package/lib/commonjs/index.js.map +1 -1
  9. package/lib/commonjs/models/CourierAuthenticationListener.js +9 -5
  10. package/lib/commonjs/models/CourierAuthenticationListener.js.map +1 -1
  11. package/lib/commonjs/models/CourierInboxListener.js +3 -6
  12. package/lib/commonjs/models/CourierInboxListener.js.map +1 -1
  13. package/lib/commonjs/utils.js +45 -0
  14. package/lib/commonjs/utils.js.map +1 -0
  15. package/lib/module/index.js +84 -81
  16. package/lib/module/index.js.map +1 -1
  17. package/lib/module/models/CourierAuthenticationListener.js +9 -5
  18. package/lib/module/models/CourierAuthenticationListener.js.map +1 -1
  19. package/lib/module/models/CourierInboxListener.js +3 -6
  20. package/lib/module/models/CourierInboxListener.js.map +1 -1
  21. package/lib/module/utils.js +37 -0
  22. package/lib/module/utils.js.map +1 -0
  23. package/lib/typescript/index.d.ts +1 -6
  24. package/lib/typescript/index.d.ts.map +1 -1
  25. package/lib/typescript/models/CourierAuthenticationListener.d.ts +2 -1
  26. package/lib/typescript/models/CourierAuthenticationListener.d.ts.map +1 -1
  27. package/lib/typescript/models/CourierInboxListener.d.ts +4 -4
  28. package/lib/typescript/models/CourierInboxListener.d.ts.map +1 -1
  29. package/lib/typescript/utils.d.ts +21 -0
  30. package/lib/typescript/utils.d.ts.map +1 -0
  31. package/package.json +1 -1
  32. package/src/index.tsx +100 -99
  33. package/src/models/CourierAuthenticationListener.tsx +8 -4
  34. package/src/models/CourierInboxListener.tsx +5 -10
  35. package/src/utils.tsx +48 -0
@@ -92,6 +92,7 @@ var _reactNative = require("react-native");
92
92
  var _CourierInboxListener = require("./models/CourierInboxListener");
93
93
  var _CourierPushListener = require("./models/CourierPushListener");
94
94
  var _CourierAuthenticationListener = require("./models/CourierAuthenticationListener");
95
+ var _utils = require("./utils");
95
96
  var _CourierInboxView = require("./views/CourierInboxView");
96
97
  var _CourierUserPreferencesChannel = require("./models/CourierUserPreferencesChannel");
97
98
  var _CourierUserPreferencesStatus = require("./models/CourierUserPreferencesStatus");
@@ -112,18 +113,14 @@ const CourierReactNativeModules = _reactNative.NativeModules.CourierReactNativeM
112
113
  });
113
114
  const CourierEventEmitter = new _reactNative.NativeEventEmitter(_reactNative.NativeModules.CourierReactNativeModule);
114
115
  class Courier {
115
- PUSH_NOTIFICATION_CLICKED = 'pushNotificationClicked';
116
- PUSH_NOTIFICATION_DELIVERED = 'pushNotificationDelivered';
117
116
  _isDebugging = false;
117
+ authListeners = new Map();
118
118
  inboxListeners = new Map();
119
119
  constructor() {
120
120
  // Sets the initial SDK values
121
121
  // Defaults to React Native level debugging
122
122
  // and will show all foreground notification styles in iOS
123
123
  this.setDefaults();
124
-
125
- // Register for inbox listener changes
126
- this.registerInboxListenerEvents();
127
124
  }
128
125
 
129
126
  // Returns the public shared instance
@@ -152,7 +149,7 @@ class Courier {
152
149
  // Set a new listener
153
150
  // listener needs to be registered first to catch the event
154
151
  if (isDebugging) {
155
- this.debugListener = CourierEventEmitter.addListener('courierDebugEvent', event => {
152
+ this.debugListener = CourierEventEmitter.addListener(_utils.Events.Log.DEBUG_LOG, event => {
156
153
  console.log('\x1b[36m%s\x1b[0m', 'COURIER', event);
157
154
  });
158
155
  }
@@ -168,30 +165,6 @@ class Courier {
168
165
  return this._isDebugging;
169
166
  }
170
167
 
171
- /**
172
- * Register inbox listener events
173
- */
174
- registerInboxListenerEvents() {
175
- CourierEventEmitter.addListener('inboxInitialLoad', () => {
176
- this.inboxListeners.forEach((value, _) => {
177
- var _value$onInitialLoad;
178
- (_value$onInitialLoad = value.onInitialLoad) === null || _value$onInitialLoad === void 0 ? void 0 : _value$onInitialLoad.call(value);
179
- });
180
- });
181
- CourierEventEmitter.addListener('inboxError', event => {
182
- this.inboxListeners.forEach((value, _) => {
183
- var _value$onError;
184
- (_value$onError = value.onError) === null || _value$onError === void 0 ? void 0 : _value$onError.call(value, event);
185
- });
186
- });
187
- CourierEventEmitter.addListener('inboxMessagesChanged', event => {
188
- this.inboxListeners.forEach((value, _) => {
189
- var _value$onMessagesChan;
190
- (_value$onMessagesChan = value.onMessagesChanged) === null || _value$onMessagesChan === void 0 ? void 0 : _value$onMessagesChan.call(value, event.messages, event.unreadMessageCount, event.totalMessageCount, event.canPaginate);
191
- });
192
- });
193
- }
194
-
195
168
  /**
196
169
  * Sets the notification presentation options for iOS
197
170
  */
@@ -246,45 +219,23 @@ class Courier {
246
219
  */
247
220
  addPushNotificationListener(props) {
248
221
  const pushListener = new _CourierPushListener.CourierPushListener();
249
- if (_reactNative.Platform.OS === 'android') {
250
- if (props.onPushNotificationClicked) {
251
- pushListener.onNotificationClickedListener = _reactNative.DeviceEventEmitter.addListener(this.PUSH_NOTIFICATION_CLICKED, event => {
252
- try {
253
- props.onPushNotificationClicked(JSON.parse(event));
254
- } catch (error) {
255
- console.log(error);
256
- }
257
- });
258
- }
259
- if (props.onPushNotificationDelivered) {
260
- pushListener.onNotificationDeliveredListener = _reactNative.DeviceEventEmitter.addListener(this.PUSH_NOTIFICATION_DELIVERED, event => {
261
- try {
262
- props.onPushNotificationDelivered(JSON.parse(event));
263
- } catch (error) {
264
- console.log(error);
265
- }
266
- });
267
- }
222
+ if (props.onPushNotificationClicked) {
223
+ pushListener.onNotificationClickedListener = _utils.Utils.addEventListener(_utils.Events.Push.CLICKED, CourierEventEmitter, event => {
224
+ try {
225
+ props.onPushNotificationClicked(JSON.parse(event));
226
+ } catch (error) {
227
+ console.log(error);
228
+ }
229
+ });
268
230
  }
269
- if (_reactNative.Platform.OS === 'ios') {
270
- if (props.onPushNotificationClicked) {
271
- pushListener.onNotificationClickedListener = CourierEventEmitter.addListener(this.PUSH_NOTIFICATION_CLICKED, event => {
272
- try {
273
- props.onPushNotificationClicked(JSON.parse(event));
274
- } catch (error) {
275
- console.log(error);
276
- }
277
- });
278
- }
279
- if (props.onPushNotificationDelivered) {
280
- pushListener.onNotificationDeliveredListener = CourierEventEmitter.addListener(this.PUSH_NOTIFICATION_DELIVERED, event => {
281
- try {
282
- props.onPushNotificationDelivered(JSON.parse(event));
283
- } catch (error) {
284
- console.log(error);
285
- }
286
- });
287
- }
231
+ if (props.onPushNotificationDelivered) {
232
+ pushListener.onNotificationDeliveredListener = _utils.Utils.addEventListener(_utils.Events.Push.DELIVERED, CourierEventEmitter, event => {
233
+ try {
234
+ props.onPushNotificationDelivered(JSON.parse(event));
235
+ } catch (error) {
236
+ console.log(error);
237
+ }
238
+ });
288
239
  }
289
240
 
290
241
  // When listener is registered
@@ -321,19 +272,41 @@ class Courier {
321
272
  * Listens to authentication changes for the current user
322
273
  */
323
274
  addAuthenticationListener(props) {
324
- const authListener = new _CourierAuthenticationListener.CourierAuthenticationListener();
325
- authListener.onUserChanged = CourierEventEmitter.addListener('courierAuthUserChanged', event => {
326
- props.onUserChanged(event);
327
- });
328
- authListener.listenerId = CourierReactNativeModules.addAuthenticationListener();
329
- return authListener;
275
+ // Event listener id
276
+ const authId = _utils.Utils.generateUUID();
277
+
278
+ // Get the id
279
+ const id = CourierReactNativeModules.addAuthenticationListener(authId);
280
+
281
+ // Create the listener
282
+ const listener = new _CourierAuthenticationListener.CourierAuthenticationListener(id);
283
+
284
+ // Add the event listener
285
+ listener.onUserChanged = _utils.Utils.addEventListener(authId, CourierEventEmitter, event => props.onUserChanged(event));
286
+
287
+ // Add listener to manager
288
+ this.authListeners.set(id, listener);
289
+ return listener;
330
290
  }
331
291
 
332
292
  /**
333
293
  * Removes an authentication listener
334
294
  */
335
295
  removeAuthenticationListener(props) {
336
- return CourierReactNativeModules.removeAuthenticationListener(props.listenerId);
296
+ // Remove the native listener
297
+ CourierReactNativeModules.removeAuthenticationListener(props.listenerId);
298
+
299
+ // Remove the listener
300
+ if (this.authListeners.has(props.listenerId)) {
301
+ var _listener$onUserChang;
302
+ // Get the listener
303
+ const listener = this.authListeners.get(props.listenerId);
304
+ listener === null || listener === void 0 || (_listener$onUserChang = listener.onUserChanged) === null || _listener$onUserChang === void 0 ? void 0 : _listener$onUserChang.remove();
305
+
306
+ // Remove the listener
307
+ this.authListeners.delete(props.listenerId);
308
+ }
309
+ return props.listenerId;
337
310
  }
338
311
 
339
312
  /**
@@ -368,14 +341,35 @@ class Courier {
368
341
  * Listens to changes for the inbox itself
369
342
  */
370
343
  addInboxListener(props) {
344
+ const listenerIds = {
345
+ loading: _utils.Utils.generateUUID(),
346
+ error: _utils.Utils.generateUUID(),
347
+ messages: _utils.Utils.generateUUID()
348
+ };
349
+
371
350
  // Set the listener id
372
- const id = CourierReactNativeModules.addInboxListener();
351
+ const id = CourierReactNativeModules.addInboxListener(listenerIds.loading, listenerIds.error, listenerIds.messages);
373
352
 
374
353
  // Create the initial listeners
375
354
  const listener = new _CourierInboxListener.CourierInboxListener(id);
376
- listener.onInitialLoad = props.onInitialLoad;
377
- listener.onError = props.onError;
378
- listener.onMessagesChanged = props.onMessagesChanged;
355
+ if (props.onInitialLoad) {
356
+ listener.onInitialLoad = _utils.Utils.addEventListener(listenerIds.loading, CourierEventEmitter, _ => {
357
+ var _props$onInitialLoad;
358
+ (_props$onInitialLoad = props.onInitialLoad) === null || _props$onInitialLoad === void 0 ? void 0 : _props$onInitialLoad.call(props);
359
+ });
360
+ }
361
+ if (props.onError) {
362
+ listener.onError = _utils.Utils.addEventListener(listenerIds.error, CourierEventEmitter, event => {
363
+ var _props$onError;
364
+ (_props$onError = props.onError) === null || _props$onError === void 0 ? void 0 : _props$onError.call(props, event);
365
+ });
366
+ }
367
+ if (props.onMessagesChanged) {
368
+ listener.onMessagesChanged = _utils.Utils.addEventListener(listenerIds.messages, CourierEventEmitter, event => {
369
+ var _props$onMessagesChan;
370
+ (_props$onMessagesChan = props.onMessagesChanged) === null || _props$onMessagesChan === void 0 ? void 0 : _props$onMessagesChan.call(props, event.messages, event.unreadMessageCount, event.totalMessageCount, event.canPaginate);
371
+ });
372
+ }
379
373
 
380
374
  // Add listener to manager
381
375
  this.inboxListeners.set(id, listener);
@@ -389,8 +383,16 @@ class Courier {
389
383
  // Call native code
390
384
  CourierReactNativeModules.removeInboxListener(props.listenerId);
391
385
 
392
- // Remove the js listener
386
+ // Remove the listener
393
387
  if (this.inboxListeners.has(props.listenerId)) {
388
+ var _listener$onInitialLo, _listener$onError, _listener$onMessagesC;
389
+ // Remove emitters
390
+ const listener = this.inboxListeners.get(props.listenerId);
391
+ listener === null || listener === void 0 || (_listener$onInitialLo = listener.onInitialLoad) === null || _listener$onInitialLo === void 0 ? void 0 : _listener$onInitialLo.remove();
392
+ listener === null || listener === void 0 || (_listener$onError = listener.onError) === null || _listener$onError === void 0 ? void 0 : _listener$onError.remove();
393
+ listener === null || listener === void 0 || (_listener$onMessagesC = listener.onMessagesChanged) === null || _listener$onMessagesC === void 0 ? void 0 : _listener$onMessagesC.remove();
394
+
395
+ // Remove the listener
394
396
  this.inboxListeners.delete(props.listenerId);
395
397
  }
396
398
  return props.listenerId;
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","_CourierInboxListener","_CourierPushListener","_CourierAuthenticationListener","_CourierInboxView","_CourierUserPreferencesChannel","_CourierUserPreferencesStatus","_CourierPushProvider","_CourierInboxTheme","LINKING_ERROR","Platform","select","ios","default","CourierReactNativeModules","NativeModules","CourierReactNativeModule","Proxy","get","Error","CourierEventEmitter","NativeEventEmitter","Courier","PUSH_NOTIFICATION_CLICKED","PUSH_NOTIFICATION_DELIVERED","_isDebugging","inboxListeners","Map","constructor","setDefaults","registerInboxListenerEvents","shared","_sharedInstance","setIsDebugging","__DEV__","iOSForegroundPresentationOptions","options","isDebugging","_this$debugListener","debugListener","remove","addListener","event","console","log","setDebugMode","forEach","value","_","_value$onInitialLoad","onInitialLoad","call","_value$onError","onError","_value$onMessagesChan","onMessagesChanged","messages","unreadMessageCount","totalMessageCount","canPaginate","props","OS","normalizedParams","Array","from","Set","getToken","key","getTokenForProvider","provider","setToken","token","setTokenForProvider","getNotificationPermissionStatus","requestNotificationPermission","addPushNotificationListener","pushListener","CourierPushListener","onPushNotificationClicked","onNotificationClickedListener","DeviceEventEmitter","JSON","parse","error","onPushNotificationDelivered","onNotificationDeliveredListener","registerPushNotificationClickedOnKilledState","userId","getUserId","undefined","signIn","accessToken","clientKey","signOut","addAuthenticationListener","authListener","CourierAuthenticationListener","onUserChanged","listenerId","removeAuthenticationListener","clickMessage","messageId","readMessage","unreadMessage","readAllInboxMessages","addInboxListener","id","listener","CourierInboxListener","set","removeInboxListener","has","delete","refreshInbox","fetchNextPageOfMessages","setInboxPaginationLimit","limit","getUserPreferences","paginationCursor","getUserPreferencesTopic","topicId","putUserPreferencesTopic","status","hasCustomRouting","customRouting","_default","exports"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AASA,IAAAC,qBAAA,GAAAD,OAAA;AACA,IAAAE,oBAAA,GAAAF,OAAA;AACA,IAAAG,8BAAA,GAAAH,OAAA;AASA,IAAAI,iBAAA,GAAAJ,OAAA;AAIA,IAAAK,8BAAA,GAAAL,OAAA;AACA,IAAAM,6BAAA,GAAAN,OAAA;AACA,IAAAO,oBAAA,GAAAP,OAAA;AACA,IAAAQ,kBAAA,GAAAR,OAAA;AAnBA;;AAWA;;AAWA,MAAMS,aAAa,GAChB,2FAA0F,GAC3FC,qBAAQ,CAACC,MAAM,CAAC;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AE/D,KAAK,CAACgE,aAAa,CAAC;EACpI;AAEF;AAAC,IAAAC,QAAA,GAEcvG,OAAO;AAAAwG,OAAA,CAAAjH,OAAA,GAAAgH,QAAA"}
1
+ {"version":3,"names":["_reactNative","require","_CourierInboxListener","_CourierPushListener","_CourierAuthenticationListener","_utils","_CourierInboxView","_CourierUserPreferencesChannel","_CourierUserPreferencesStatus","_CourierPushProvider","_CourierInboxTheme","LINKING_ERROR","Platform","select","ios","default","CourierReactNativeModules","NativeModules","CourierReactNativeModule","Proxy","get","Error","CourierEventEmitter","NativeEventEmitter","Courier","_isDebugging","authListeners","Map","inboxListeners","constructor","setDefaults","shared","_sharedInstance","setIsDebugging","__DEV__","iOSForegroundPresentationOptions","options","isDebugging","_this$debugListener","debugListener","remove","addListener","Events","Log","DEBUG_LOG","event","console","log","setDebugMode","props","OS","normalizedParams","Array","from","Set","getToken","key","getTokenForProvider","provider","setToken","token","setTokenForProvider","getNotificationPermissionStatus","requestNotificationPermission","addPushNotificationListener","pushListener","CourierPushListener","onPushNotificationClicked","onNotificationClickedListener","Utils","addEventListener","Push","CLICKED","JSON","parse","error","onPushNotificationDelivered","onNotificationDeliveredListener","DELIVERED","registerPushNotificationClickedOnKilledState","userId","getUserId","undefined","signIn","accessToken","clientKey","signOut","addAuthenticationListener","authId","generateUUID","id","listener","CourierAuthenticationListener","onUserChanged","set","removeAuthenticationListener","listenerId","has","_listener$onUserChang","delete","clickMessage","messageId","readMessage","unreadMessage","readAllInboxMessages","addInboxListener","listenerIds","loading","messages","CourierInboxListener","onInitialLoad","_","_props$onInitialLoad","call","onError","_props$onError","onMessagesChanged","_props$onMessagesChan","unreadMessageCount","totalMessageCount","canPaginate","removeInboxListener","_listener$onInitialLo","_listener$onError","_listener$onMessagesC","refreshInbox","fetchNextPageOfMessages","setInboxPaginationLimit","limit","getUserPreferences","paginationCursor","getUserPreferencesTopic","topicId","putUserPreferencesTopic","status","hasCustomRouting","customRouting","_default","exports"],"sourceRoot":"../../src","s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BAAA,CAA6BpF,MAAM,CAAC,CAAC;;MAErC;MACA,IAAI,CAACZ,cAAc,CAACuE,MAAM,CAAClD,KAAK,CAAC+C,UAAU,CAAC;IAE9C;IAEA,OAAO/C,KAAK,CAAC+C,UAAU;EAEzB;;EAEA;AACF;AACA;AACA;EACE,MAAa6B,YAAYA,CAAA,EAAkB;IACzC,OAAO7G,yBAAyB,CAAC6G,YAAY,CAAC,CAAC;EACjD;;EAEA;AACF;AACA;AACA;EACE,MAAaC,uBAAuBA,CAAA,EAA4B;IAC9D,OAAO9G,yBAAyB,CAAC8G,uBAAuB,CAAC,CAAC;EAC5D;;EAEA;AACF;AACA;AACA;AACA;EACSC,uBAAuBA,CAAC9E,KAAwB,EAAQ;IAC7DjC,yBAAyB,CAAC+G,uBAAuB,CAAC9E,KAAK,CAAC+E,KAAK,CAAC;EAChE;;EAEA;AACF;AACA;EACE,MAAaC,kBAAkBA,CAAChF,KAAoC,EAAmC;IACrG,OAAOjC,yBAAyB,CAACiH,kBAAkB,CAAC,CAAAhF,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEiF,gBAAgB,KAAI,EAAE,CAAC;EACpF;;EAEA;AACF;AACA;EACE,MAAaC,uBAAuBA,CAAClF,KAA0B,EAAwC;IACrG,OAAOjC,yBAAyB,CAACmH,uBAAuB,CAAClF,KAAK,CAACmF,OAAO,CAAC;EACzE;;EAEA;AACF;AACA;EACE,MAAaC,uBAAuBA,CAACpF,KAA2I,EAAiB;IAC/L,OAAOjC,yBAAyB,CAACqH,uBAAuB,CAACpF,KAAK,CAACmF,OAAO,EAAEnF,KAAK,CAACqF,MAAM,EAAErF,KAAK,CAACsF,gBAAgB,EAAEtF,KAAK,CAACuF,aAAa,CAAC;EACpI;AAEF;AAAC,IAAAC,QAAA,GAEcjH,OAAO;AAAAkH,OAAA,CAAA3H,OAAA,GAAA0H,QAAA"}
@@ -7,13 +7,17 @@ exports.CourierAuthenticationListener = void 0;
7
7
  var _ = _interopRequireDefault(require(".."));
8
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
9
  class CourierAuthenticationListener {
10
+ constructor(id) {
11
+ this.listenerId = id;
12
+ }
10
13
  remove() {
11
14
  var _this$onUserChanged;
12
- if (this.listenerId) {
13
- _.default.shared.removeInboxListener({
14
- listenerId: this.listenerId
15
- });
16
- }
15
+ // Remove the native inbox listener
16
+ _.default.shared.removeInboxListener({
17
+ listenerId: this.listenerId
18
+ });
19
+
20
+ // Remove the emitter
17
21
  (_this$onUserChanged = this.onUserChanged) === null || _this$onUserChanged === void 0 ? void 0 : _this$onUserChanged.remove();
18
22
  }
19
23
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_","_interopRequireDefault","require","obj","__esModule","default","CourierAuthenticationListener","remove","_this$onUserChanged","listenerId","Courier","shared","removeInboxListener","onUserChanged","exports"],"sourceRoot":"../../../src","sources":["models/CourierAuthenticationListener.tsx"],"mappings":";;;;;;AACA,IAAAA,CAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAyB,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAElB,MAAMG,6BAA6B,CAAC;EAKlCC,MAAMA,CAAA,EAAG;IAAA,IAAAC,mBAAA;IAEd,IAAI,IAAI,CAACC,UAAU,EAAE;MACnBC,SAAO,CAACC,MAAM,CAACC,mBAAmB,CAAC;QAAEH,UAAU,EAAE,IAAI,CAACA;MAAW,CAAC,CAAC;IACrE;IAEA,CAAAD,mBAAA,OAAI,CAACK,aAAa,cAAAL,mBAAA,uBAAlBA,mBAAA,CAAoBD,MAAM,CAAC,CAAC;EAE9B;AAEF;AAACO,OAAA,CAAAR,6BAAA,GAAAA,6BAAA"}
1
+ {"version":3,"names":["_","_interopRequireDefault","require","obj","__esModule","default","CourierAuthenticationListener","constructor","id","listenerId","remove","_this$onUserChanged","Courier","shared","removeInboxListener","onUserChanged","exports"],"sourceRoot":"../../../src","sources":["models/CourierAuthenticationListener.tsx"],"mappings":";;;;;;AACA,IAAAA,CAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAyB,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAElB,MAAMG,6BAA6B,CAAC;EAKzCC,WAAWA,CAACC,EAAU,EAAE;IACtB,IAAI,CAACC,UAAU,GAAGD,EAAE;EACtB;EAEOE,MAAMA,CAAA,EAAG;IAAA,IAAAC,mBAAA;IAEd;IACAC,SAAO,CAACC,MAAM,CAACC,mBAAmB,CAAC;MAAEL,UAAU,EAAE,IAAI,CAACA;IAAW,CAAC,CAAC;;IAEnE;IACA,CAAAE,mBAAA,OAAI,CAACI,aAAa,cAAAJ,mBAAA,uBAAlBA,mBAAA,CAAoBD,MAAM,CAAC,CAAC;EAE9B;AAEF;AAACM,OAAA,CAAAV,6BAAA,GAAAA,6BAAA"}
@@ -11,12 +11,9 @@ class CourierInboxListener {
11
11
  this.listenerId = id;
12
12
  }
13
13
  remove() {
14
- // Remove the native inbox listener
15
- if (this.listenerId) {
16
- _courierReactNative.default.shared.removeInboxListener({
17
- listenerId: this.listenerId
18
- });
19
- }
14
+ _courierReactNative.default.shared.removeInboxListener({
15
+ listenerId: this.listenerId
16
+ });
20
17
  }
21
18
  }
22
19
  exports.CourierInboxListener = CourierInboxListener;
@@ -1 +1 @@
1
- {"version":3,"names":["_courierReactNative","_interopRequireDefault","require","obj","__esModule","default","CourierInboxListener","constructor","id","listenerId","remove","Courier","shared","removeInboxListener","exports"],"sourceRoot":"../../../src","sources":["models/CourierInboxListener.tsx"],"mappings":";;;;;;AAAA,IAAAA,mBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAuD,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAGhD,MAAMG,oBAAoB,CAAC;EAOhCC,WAAWA,CAACC,EAAU,EAAE;IACtB,IAAI,CAACC,UAAU,GAAGD,EAAE;EACtB;EAEOE,MAAMA,CAAA,EAAG;IAEd;IACA,IAAI,IAAI,CAACD,UAAU,EAAE;MACnBE,2BAAO,CAACC,MAAM,CAACC,mBAAmB,CAAC;QAAEJ,UAAU,EAAE,IAAI,CAACA;MAAW,CAAC,CAAC;IACrE;EAEF;AAEF;AAACK,OAAA,CAAAR,oBAAA,GAAAA,oBAAA"}
1
+ {"version":3,"names":["_courierReactNative","_interopRequireDefault","require","obj","__esModule","default","CourierInboxListener","constructor","id","listenerId","remove","Courier","shared","removeInboxListener","exports"],"sourceRoot":"../../../src","sources":["models/CourierInboxListener.tsx"],"mappings":";;;;;;AAAA,IAAAA,mBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAuD,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAGhD,MAAMG,oBAAoB,CAAC;EAOhCC,WAAWA,CAACC,EAAU,EAAE;IACtB,IAAI,CAACC,UAAU,GAAGD,EAAE;EACtB;EAEOE,MAAMA,CAAA,EAAG;IACdC,2BAAO,CAACC,MAAM,CAACC,mBAAmB,CAAC;MAAEJ,UAAU,EAAE,IAAI,CAACA;IAAW,CAAC,CAAC;EACrE;AAEF;AAACK,OAAA,CAAAR,oBAAA,GAAAA,oBAAA"}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Utils = exports.Events = void 0;
7
+ var _reactNative = require("react-native");
8
+ let Events;
9
+ exports.Events = Events;
10
+ (function (_Events) {
11
+ let Log;
12
+ (function (_Log) {
13
+ const DEBUG_LOG = _Log.DEBUG_LOG = 'courierDebugEvent';
14
+ })(Log || (Log = _Events.Log || (_Events.Log = {})));
15
+ let Push;
16
+ (function (_Push) {
17
+ const CLICKED = _Push.CLICKED = 'pushNotificationClicked';
18
+ const DELIVERED = _Push.DELIVERED = 'pushNotificationDelivered';
19
+ })(Push || (Push = _Events.Push || (_Events.Push = {})));
20
+ })(Events || (exports.Events = Events = {}));
21
+ let Utils;
22
+ exports.Utils = Utils;
23
+ (function (_Utils) {
24
+ function addEventListener(key, emitter, callback) {
25
+ if (_reactNative.Platform.OS === 'android') {
26
+ return _reactNative.DeviceEventEmitter.addListener(key, event => callback(event));
27
+ }
28
+ if (_reactNative.Platform.OS === 'ios') {
29
+ return emitter.addListener(key, event => callback(event));
30
+ }
31
+ return undefined;
32
+ }
33
+ _Utils.addEventListener = addEventListener;
34
+ function generateUUID() {
35
+ let uuid = '';
36
+ const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
37
+ const charactersLength = characters.length;
38
+ for (let i = 0; i < 16; i++) {
39
+ uuid += characters.charAt(Math.floor(Math.random() * charactersLength));
40
+ }
41
+ return uuid;
42
+ }
43
+ _Utils.generateUUID = generateUUID;
44
+ })(Utils || (exports.Utils = Utils = {}));
45
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNative","require","Events","exports","_Events","Log","_Log","DEBUG_LOG","Push","_Push","CLICKED","DELIVERED","Utils","_Utils","addEventListener","key","emitter","callback","Platform","OS","DeviceEventEmitter","addListener","event","undefined","generateUUID","uuid","characters","charactersLength","length","i","charAt","Math","floor","random"],"sourceRoot":"../../src","sources":["utils.tsx"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAAqG,IAEpFC,MAAM;AAAAC,OAAA,CAAAD,MAAA,GAAAA,MAAA;AAAA,WAAAE,OAAA;EAAA,IAAAC,GAAA;EAAA,WAAAC,IAAA;IAGZ,MAAMC,SAAS,GAAAD,IAAA,CAAAC,SAAA,GAAG,mBAAmB;EAAC,GAD9BF,GAAG,KAAHA,GAAG,GAAAD,OAAA,CAA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;IACA,OAAOF,IAAI;EACb;EAACZ,MAAA,CAAAW,YAAA,GAAAA,YAAA;AAAA,GA9BcZ,KAAK,KAAAT,OAAA,CAAAS,KAAA,GAALA,KAAK"}
@@ -1,9 +1,11 @@
1
- import { NativeModules, NativeEventEmitter, Platform, DeviceEventEmitter } from 'react-native';
1
+ import { Platform, NativeModules, NativeEventEmitter } from 'react-native';
2
2
 
3
3
  // Imports
4
4
  import { CourierInboxListener } from './models/CourierInboxListener';
5
5
  import { CourierPushListener } from './models/CourierPushListener';
6
6
  import { CourierAuthenticationListener } from './models/CourierAuthenticationListener';
7
+ import { Events, Utils } from './utils';
8
+
7
9
  // Exports
8
10
  export { CourierInboxView } from './views/CourierInboxView';
9
11
  export { CourierInboxListener } from './models/CourierInboxListener';
@@ -24,18 +26,14 @@ const CourierReactNativeModules = NativeModules.CourierReactNativeModule ? Nativ
24
26
  });
25
27
  const CourierEventEmitter = new NativeEventEmitter(NativeModules.CourierReactNativeModule);
26
28
  class Courier {
27
- PUSH_NOTIFICATION_CLICKED = 'pushNotificationClicked';
28
- PUSH_NOTIFICATION_DELIVERED = 'pushNotificationDelivered';
29
29
  _isDebugging = false;
30
+ authListeners = new Map();
30
31
  inboxListeners = new Map();
31
32
  constructor() {
32
33
  // Sets the initial SDK values
33
34
  // Defaults to React Native level debugging
34
35
  // and will show all foreground notification styles in iOS
35
36
  this.setDefaults();
36
-
37
- // Register for inbox listener changes
38
- this.registerInboxListenerEvents();
39
37
  }
40
38
 
41
39
  // Returns the public shared instance
@@ -64,7 +62,7 @@ class Courier {
64
62
  // Set a new listener
65
63
  // listener needs to be registered first to catch the event
66
64
  if (isDebugging) {
67
- this.debugListener = CourierEventEmitter.addListener('courierDebugEvent', event => {
65
+ this.debugListener = CourierEventEmitter.addListener(Events.Log.DEBUG_LOG, event => {
68
66
  console.log('\x1b[36m%s\x1b[0m', 'COURIER', event);
69
67
  });
70
68
  }
@@ -80,30 +78,6 @@ class Courier {
80
78
  return this._isDebugging;
81
79
  }
82
80
 
83
- /**
84
- * Register inbox listener events
85
- */
86
- registerInboxListenerEvents() {
87
- CourierEventEmitter.addListener('inboxInitialLoad', () => {
88
- this.inboxListeners.forEach((value, _) => {
89
- var _value$onInitialLoad;
90
- (_value$onInitialLoad = value.onInitialLoad) === null || _value$onInitialLoad === void 0 ? void 0 : _value$onInitialLoad.call(value);
91
- });
92
- });
93
- CourierEventEmitter.addListener('inboxError', event => {
94
- this.inboxListeners.forEach((value, _) => {
95
- var _value$onError;
96
- (_value$onError = value.onError) === null || _value$onError === void 0 ? void 0 : _value$onError.call(value, event);
97
- });
98
- });
99
- CourierEventEmitter.addListener('inboxMessagesChanged', event => {
100
- this.inboxListeners.forEach((value, _) => {
101
- var _value$onMessagesChan;
102
- (_value$onMessagesChan = value.onMessagesChanged) === null || _value$onMessagesChan === void 0 ? void 0 : _value$onMessagesChan.call(value, event.messages, event.unreadMessageCount, event.totalMessageCount, event.canPaginate);
103
- });
104
- });
105
- }
106
-
107
81
  /**
108
82
  * Sets the notification presentation options for iOS
109
83
  */
@@ -158,45 +132,23 @@ class Courier {
158
132
  */
159
133
  addPushNotificationListener(props) {
160
134
  const pushListener = new CourierPushListener();
161
- if (Platform.OS === 'android') {
162
- if (props.onPushNotificationClicked) {
163
- pushListener.onNotificationClickedListener = DeviceEventEmitter.addListener(this.PUSH_NOTIFICATION_CLICKED, event => {
164
- try {
165
- props.onPushNotificationClicked(JSON.parse(event));
166
- } catch (error) {
167
- console.log(error);
168
- }
169
- });
170
- }
171
- if (props.onPushNotificationDelivered) {
172
- pushListener.onNotificationDeliveredListener = DeviceEventEmitter.addListener(this.PUSH_NOTIFICATION_DELIVERED, event => {
173
- try {
174
- props.onPushNotificationDelivered(JSON.parse(event));
175
- } catch (error) {
176
- console.log(error);
177
- }
178
- });
179
- }
135
+ if (props.onPushNotificationClicked) {
136
+ pushListener.onNotificationClickedListener = Utils.addEventListener(Events.Push.CLICKED, CourierEventEmitter, event => {
137
+ try {
138
+ props.onPushNotificationClicked(JSON.parse(event));
139
+ } catch (error) {
140
+ console.log(error);
141
+ }
142
+ });
180
143
  }
181
- if (Platform.OS === 'ios') {
182
- if (props.onPushNotificationClicked) {
183
- pushListener.onNotificationClickedListener = CourierEventEmitter.addListener(this.PUSH_NOTIFICATION_CLICKED, event => {
184
- try {
185
- props.onPushNotificationClicked(JSON.parse(event));
186
- } catch (error) {
187
- console.log(error);
188
- }
189
- });
190
- }
191
- if (props.onPushNotificationDelivered) {
192
- pushListener.onNotificationDeliveredListener = CourierEventEmitter.addListener(this.PUSH_NOTIFICATION_DELIVERED, event => {
193
- try {
194
- props.onPushNotificationDelivered(JSON.parse(event));
195
- } catch (error) {
196
- console.log(error);
197
- }
198
- });
199
- }
144
+ if (props.onPushNotificationDelivered) {
145
+ pushListener.onNotificationDeliveredListener = Utils.addEventListener(Events.Push.DELIVERED, CourierEventEmitter, event => {
146
+ try {
147
+ props.onPushNotificationDelivered(JSON.parse(event));
148
+ } catch (error) {
149
+ console.log(error);
150
+ }
151
+ });
200
152
  }
201
153
 
202
154
  // When listener is registered
@@ -233,19 +185,41 @@ class Courier {
233
185
  * Listens to authentication changes for the current user
234
186
  */
235
187
  addAuthenticationListener(props) {
236
- const authListener = new CourierAuthenticationListener();
237
- authListener.onUserChanged = CourierEventEmitter.addListener('courierAuthUserChanged', event => {
238
- props.onUserChanged(event);
239
- });
240
- authListener.listenerId = CourierReactNativeModules.addAuthenticationListener();
241
- return authListener;
188
+ // Event listener id
189
+ const authId = Utils.generateUUID();
190
+
191
+ // Get the id
192
+ const id = CourierReactNativeModules.addAuthenticationListener(authId);
193
+
194
+ // Create the listener
195
+ const listener = new CourierAuthenticationListener(id);
196
+
197
+ // Add the event listener
198
+ listener.onUserChanged = Utils.addEventListener(authId, CourierEventEmitter, event => props.onUserChanged(event));
199
+
200
+ // Add listener to manager
201
+ this.authListeners.set(id, listener);
202
+ return listener;
242
203
  }
243
204
 
244
205
  /**
245
206
  * Removes an authentication listener
246
207
  */
247
208
  removeAuthenticationListener(props) {
248
- return CourierReactNativeModules.removeAuthenticationListener(props.listenerId);
209
+ // Remove the native listener
210
+ CourierReactNativeModules.removeAuthenticationListener(props.listenerId);
211
+
212
+ // Remove the listener
213
+ if (this.authListeners.has(props.listenerId)) {
214
+ var _listener$onUserChang;
215
+ // Get the listener
216
+ const listener = this.authListeners.get(props.listenerId);
217
+ listener === null || listener === void 0 || (_listener$onUserChang = listener.onUserChanged) === null || _listener$onUserChang === void 0 ? void 0 : _listener$onUserChang.remove();
218
+
219
+ // Remove the listener
220
+ this.authListeners.delete(props.listenerId);
221
+ }
222
+ return props.listenerId;
249
223
  }
250
224
 
251
225
  /**
@@ -280,14 +254,35 @@ class Courier {
280
254
  * Listens to changes for the inbox itself
281
255
  */
282
256
  addInboxListener(props) {
257
+ const listenerIds = {
258
+ loading: Utils.generateUUID(),
259
+ error: Utils.generateUUID(),
260
+ messages: Utils.generateUUID()
261
+ };
262
+
283
263
  // Set the listener id
284
- const id = CourierReactNativeModules.addInboxListener();
264
+ const id = CourierReactNativeModules.addInboxListener(listenerIds.loading, listenerIds.error, listenerIds.messages);
285
265
 
286
266
  // Create the initial listeners
287
267
  const listener = new CourierInboxListener(id);
288
- listener.onInitialLoad = props.onInitialLoad;
289
- listener.onError = props.onError;
290
- listener.onMessagesChanged = props.onMessagesChanged;
268
+ if (props.onInitialLoad) {
269
+ listener.onInitialLoad = Utils.addEventListener(listenerIds.loading, CourierEventEmitter, _ => {
270
+ var _props$onInitialLoad;
271
+ (_props$onInitialLoad = props.onInitialLoad) === null || _props$onInitialLoad === void 0 ? void 0 : _props$onInitialLoad.call(props);
272
+ });
273
+ }
274
+ if (props.onError) {
275
+ listener.onError = Utils.addEventListener(listenerIds.error, CourierEventEmitter, event => {
276
+ var _props$onError;
277
+ (_props$onError = props.onError) === null || _props$onError === void 0 ? void 0 : _props$onError.call(props, event);
278
+ });
279
+ }
280
+ if (props.onMessagesChanged) {
281
+ listener.onMessagesChanged = Utils.addEventListener(listenerIds.messages, CourierEventEmitter, event => {
282
+ var _props$onMessagesChan;
283
+ (_props$onMessagesChan = props.onMessagesChanged) === null || _props$onMessagesChan === void 0 ? void 0 : _props$onMessagesChan.call(props, event.messages, event.unreadMessageCount, event.totalMessageCount, event.canPaginate);
284
+ });
285
+ }
291
286
 
292
287
  // Add listener to manager
293
288
  this.inboxListeners.set(id, listener);
@@ -301,8 +296,16 @@ class Courier {
301
296
  // Call native code
302
297
  CourierReactNativeModules.removeInboxListener(props.listenerId);
303
298
 
304
- // Remove the js listener
299
+ // Remove the listener
305
300
  if (this.inboxListeners.has(props.listenerId)) {
301
+ var _listener$onInitialLo, _listener$onError, _listener$onMessagesC;
302
+ // Remove emitters
303
+ const listener = this.inboxListeners.get(props.listenerId);
304
+ listener === null || listener === void 0 || (_listener$onInitialLo = listener.onInitialLoad) === null || _listener$onInitialLo === void 0 ? void 0 : _listener$onInitialLo.remove();
305
+ listener === null || listener === void 0 || (_listener$onError = listener.onError) === null || _listener$onError === void 0 ? void 0 : _listener$onError.remove();
306
+ listener === null || listener === void 0 || (_listener$onMessagesC = listener.onMessagesChanged) === null || _listener$onMessagesC === void 0 ? void 0 : _listener$onMessagesC.remove();
307
+
308
+ // Remove the listener
306
309
  this.inboxListeners.delete(props.listenerId);
307
310
  }
308
311
  return props.listenerId;