@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
package/src/utils.tsx ADDED
@@ -0,0 +1,48 @@
1
+ import { EmitterSubscription, Platform, DeviceEventEmitter, NativeEventEmitter } from "react-native";
2
+
3
+ export namespace Events {
4
+
5
+ export namespace Log {
6
+ export const DEBUG_LOG = 'courierDebugEvent';
7
+ }
8
+
9
+ export namespace Push {
10
+ export const CLICKED = 'pushNotificationClicked';
11
+ export const DELIVERED = 'pushNotificationDelivered';
12
+ }
13
+
14
+ }
15
+
16
+ export namespace Utils {
17
+
18
+ /**
19
+ * Creates an event listener for the native function
20
+ * @param key Key for the listener
21
+ * @param callback Value returned for the listener callback
22
+ * @returns Subscription
23
+ */
24
+ export function addEventListener(key: string, emitter: NativeEventEmitter, callback: (value: any) => void): EmitterSubscription | undefined {
25
+
26
+ if (Platform.OS === 'android') {
27
+ return DeviceEventEmitter.addListener(key, (event: any) => callback(event));
28
+ }
29
+
30
+ if (Platform.OS === 'ios') {
31
+ return emitter.addListener(key, (event: any) => callback(event));
32
+ }
33
+
34
+ return undefined;
35
+
36
+ }
37
+
38
+ export function generateUUID(): string {
39
+ let uuid = '';
40
+ const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
41
+ const charactersLength = characters.length;
42
+ for (let i = 0; i < 16; i++) {
43
+ uuid += characters.charAt(Math.floor(Math.random() * charactersLength));
44
+ }
45
+ return uuid;
46
+ }
47
+
48
+ }