@trycourier/courier-react-native 3.2.1 → 4.0.4
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.
- package/android/build.gradle +4 -1
- package/android/src/main/java/com/courierreactnative/CourierClientModule.kt +441 -0
- package/android/src/main/java/com/courierreactnative/CourierInboxViewManager.kt +2 -2
- package/android/src/main/java/com/courierreactnative/CourierReactNativePackage.kt +9 -3
- package/android/src/main/java/com/courierreactnative/CourierSharedModule.kt +321 -0
- package/android/src/main/java/com/courierreactnative/CourierSystemModule.kt +91 -0
- package/android/src/main/java/com/courierreactnative/ReactNativeModule.kt +36 -0
- package/android/src/main/java/com/courierreactnative/{Extensions.kt → Utils.kt} +5 -5
- package/courier-react-native.podspec +1 -1
- package/ios/CourierClientModule.swift +450 -0
- package/ios/CourierInboxReactNativeManager.swift +17 -9
- package/ios/CourierReactNativeDelegate.m +18 -35
- package/ios/CourierReactNativeEventEmitter.swift +25 -0
- package/ios/CourierReactNativeModule.m +192 -23
- package/ios/CourierSharedModule.swift +425 -0
- package/ios/CourierSystemModule.swift +147 -0
- package/ios/Utils.swift +103 -115
- package/lib/commonjs/Broadcaster.js +30 -0
- package/lib/commonjs/Broadcaster.js.map +1 -0
- package/lib/commonjs/Modules.js +25 -0
- package/lib/commonjs/Modules.js.map +1 -0
- package/lib/commonjs/client/BrandClient.js +25 -0
- package/lib/commonjs/client/BrandClient.js.map +1 -0
- package/lib/commonjs/client/ClientModule.js +21 -0
- package/lib/commonjs/client/ClientModule.js.map +1 -0
- package/lib/commonjs/client/CourierClient.js +33 -0
- package/lib/commonjs/client/CourierClient.js.map +1 -0
- package/lib/commonjs/client/InboxClient.js +116 -0
- package/lib/commonjs/client/InboxClient.js.map +1 -0
- package/lib/commonjs/client/PreferenceClient.js +73 -0
- package/lib/commonjs/client/PreferenceClient.js.map +1 -0
- package/lib/commonjs/client/TokenClient.js +36 -0
- package/lib/commonjs/client/TokenClient.js.map +1 -0
- package/lib/commonjs/client/TrackingClient.js +25 -0
- package/lib/commonjs/client/TrackingClient.js.map +1 -0
- package/lib/commonjs/index.js +418 -186
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/Android_CourierSheet.js.map +1 -1
- package/lib/commonjs/models/CourierAuthenticationListener.js.map +1 -1
- package/lib/commonjs/models/CourierBrand.js +2 -0
- package/lib/commonjs/models/{CourierUserPreferencesTopic.js.map → CourierBrand.js.map} +1 -1
- package/lib/commonjs/models/CourierButton.js.map +1 -1
- package/lib/commonjs/models/CourierDevice.js +2 -0
- package/lib/commonjs/models/CourierDevice.js.map +1 -0
- package/lib/commonjs/models/CourierFont.js.map +1 -1
- package/lib/commonjs/models/CourierInboxListener.js +2 -2
- package/lib/commonjs/models/CourierInboxListener.js.map +1 -1
- package/lib/commonjs/models/{CourierUserPreferencesTopic.js → CourierInboxMessages.js} +1 -1
- package/lib/commonjs/models/CourierInboxMessages.js.map +1 -0
- package/lib/commonjs/models/CourierInboxTheme.js.map +1 -1
- package/lib/commonjs/models/CourierInfoViewStyle.js.map +1 -1
- package/lib/commonjs/models/CourierPaging.js.map +1 -1
- package/lib/commonjs/models/CourierPreferencesTheme.js.map +1 -1
- package/lib/commonjs/models/CourierPushListener.js +7 -3
- package/lib/commonjs/models/CourierPushListener.js.map +1 -1
- package/lib/commonjs/models/CourierPushProvider.js.map +1 -1
- package/lib/commonjs/models/CourierTrackingEvent.js +16 -0
- package/lib/commonjs/models/CourierTrackingEvent.js.map +1 -0
- package/lib/commonjs/models/CourierUserPreferences.js +54 -0
- package/lib/commonjs/models/CourierUserPreferences.js.map +1 -1
- package/lib/commonjs/models/InboxAction.js.map +1 -1
- package/lib/commonjs/models/InboxMessage.js.map +1 -1
- package/lib/commonjs/models/iOS_CourierCell.js.map +1 -1
- package/lib/commonjs/models/iOS_CourierSheet.js.map +1 -1
- package/lib/commonjs/utils.js +9 -17
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/commonjs/views/CourierInboxView.js +3 -3
- package/lib/commonjs/views/CourierInboxView.js.map +1 -1
- package/lib/commonjs/views/CourierPreferencesView.js.map +1 -1
- package/lib/module/Broadcaster.js +23 -0
- package/lib/module/Broadcaster.js.map +1 -0
- package/lib/module/Modules.js +18 -0
- package/lib/module/Modules.js.map +1 -0
- package/lib/module/client/BrandClient.js +18 -0
- package/lib/module/client/BrandClient.js.map +1 -0
- package/lib/module/client/ClientModule.js +14 -0
- package/lib/module/client/ClientModule.js.map +1 -0
- package/lib/module/client/CourierClient.js +26 -0
- package/lib/module/client/CourierClient.js.map +1 -0
- package/lib/module/client/InboxClient.js +109 -0
- package/lib/module/client/InboxClient.js.map +1 -0
- package/lib/module/client/PreferenceClient.js +66 -0
- package/lib/module/client/PreferenceClient.js.map +1 -0
- package/lib/module/client/TokenClient.js +29 -0
- package/lib/module/client/TokenClient.js.map +1 -0
- package/lib/module/client/TrackingClient.js +18 -0
- package/lib/module/client/TrackingClient.js.map +1 -0
- package/lib/module/index.js +383 -185
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/Android_CourierSheet.js.map +1 -1
- package/lib/module/models/CourierAuthenticationListener.js.map +1 -1
- package/lib/module/models/CourierBrand.js +2 -0
- package/lib/module/models/{CourierUserPreferencesTopic.js.map → CourierBrand.js.map} +1 -1
- package/lib/module/models/CourierButton.js.map +1 -1
- package/lib/module/models/CourierDevice.js +2 -0
- package/lib/module/models/CourierDevice.js.map +1 -0
- package/lib/module/models/CourierFont.js.map +1 -1
- package/lib/module/models/CourierInboxListener.js +1 -1
- package/lib/module/models/CourierInboxListener.js.map +1 -1
- package/lib/module/models/CourierInboxMessages.js +2 -0
- package/lib/module/models/CourierInboxMessages.js.map +1 -0
- package/lib/module/models/CourierInboxTheme.js.map +1 -1
- package/lib/module/models/CourierInfoViewStyle.js.map +1 -1
- package/lib/module/models/CourierPaging.js.map +1 -1
- package/lib/module/models/CourierPreferencesTheme.js.map +1 -1
- package/lib/module/models/CourierPushListener.js +7 -3
- package/lib/module/models/CourierPushListener.js.map +1 -1
- package/lib/module/models/CourierPushProvider.js.map +1 -1
- package/lib/module/models/CourierTrackingEvent.js +9 -0
- package/lib/module/models/CourierTrackingEvent.js.map +1 -0
- package/lib/module/models/CourierUserPreferences.js +53 -1
- package/lib/module/models/CourierUserPreferences.js.map +1 -1
- package/lib/module/models/InboxAction.js.map +1 -1
- package/lib/module/models/InboxMessage.js.map +1 -1
- package/lib/module/models/iOS_CourierCell.js.map +1 -1
- package/lib/module/models/iOS_CourierSheet.js.map +1 -1
- package/lib/module/utils.js +7 -16
- package/lib/module/utils.js.map +1 -1
- package/lib/module/views/CourierInboxView.js +3 -3
- package/lib/module/views/CourierInboxView.js.map +1 -1
- package/lib/module/views/CourierPreferencesView.js.map +1 -1
- package/lib/typescript/src/Broadcaster.d.ts +14 -0
- package/lib/typescript/src/Broadcaster.d.ts.map +1 -0
- package/lib/typescript/src/Modules.d.ts +8 -0
- package/lib/typescript/src/Modules.d.ts.map +1 -0
- package/lib/typescript/src/client/BrandClient.d.ts +15 -0
- package/lib/typescript/src/client/BrandClient.d.ts.map +1 -0
- package/lib/typescript/src/client/ClientModule.d.ts +8 -0
- package/lib/typescript/src/client/ClientModule.d.ts.map +1 -0
- package/lib/typescript/src/client/CourierClient.d.ts +31 -0
- package/lib/typescript/src/client/CourierClient.d.ts.map +1 -0
- package/lib/typescript/src/client/InboxClient.d.ts +94 -0
- package/lib/typescript/src/client/InboxClient.d.ts.map +1 -0
- package/lib/typescript/src/client/PreferenceClient.d.ts +39 -0
- package/lib/typescript/src/client/PreferenceClient.d.ts.map +1 -0
- package/lib/typescript/src/client/TokenClient.d.ts +28 -0
- package/lib/typescript/src/client/TokenClient.d.ts.map +1 -0
- package/lib/typescript/src/client/TrackingClient.d.ts +17 -0
- package/lib/typescript/src/client/TrackingClient.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +300 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/models/Android_CourierSheet.d.ts.map +1 -0
- package/lib/typescript/src/models/CourierAuthenticationListener.d.ts.map +1 -0
- package/lib/typescript/src/models/CourierBrand.d.ts +20 -0
- package/lib/typescript/src/models/CourierBrand.d.ts.map +1 -0
- package/lib/typescript/src/models/CourierButton.d.ts.map +1 -0
- package/lib/typescript/src/models/CourierDevice.d.ts +9 -0
- package/lib/typescript/src/models/CourierDevice.d.ts.map +1 -0
- package/lib/typescript/src/models/CourierFont.d.ts.map +1 -0
- package/lib/typescript/src/models/CourierInboxListener.d.ts.map +1 -0
- package/lib/typescript/src/models/CourierInboxMessages.d.ts +23 -0
- package/lib/typescript/src/models/CourierInboxMessages.d.ts.map +1 -0
- package/lib/typescript/src/models/CourierInboxTheme.d.ts.map +1 -0
- package/lib/typescript/src/models/CourierInfoViewStyle.d.ts.map +1 -0
- package/lib/typescript/src/models/CourierPaging.d.ts.map +1 -0
- package/lib/typescript/src/models/CourierPreferencesTheme.d.ts.map +1 -0
- package/lib/typescript/src/models/CourierPushListener.d.ts +8 -0
- package/lib/typescript/src/models/CourierPushListener.d.ts.map +1 -0
- package/lib/typescript/src/models/CourierPushProvider.d.ts.map +1 -0
- package/lib/typescript/src/models/CourierTrackingEvent.d.ts +8 -0
- package/lib/typescript/src/models/CourierTrackingEvent.d.ts.map +1 -0
- package/lib/typescript/src/models/CourierUserPreferences.d.ts +35 -0
- package/lib/typescript/src/models/CourierUserPreferences.d.ts.map +1 -0
- package/lib/typescript/src/models/InboxAction.d.ts.map +1 -0
- package/lib/typescript/src/models/InboxMessage.d.ts.map +1 -0
- package/lib/typescript/src/models/iOS_CourierCell.d.ts.map +1 -0
- package/lib/typescript/src/models/iOS_CourierSheet.d.ts.map +1 -0
- package/lib/typescript/src/utils.d.ts +14 -0
- package/lib/typescript/src/utils.d.ts.map +1 -0
- package/lib/typescript/src/views/CourierInboxView.d.ts.map +1 -0
- package/lib/typescript/src/views/CourierPreferencesView.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/Broadcaster.tsx +32 -0
- package/src/Modules.tsx +28 -0
- package/src/client/BrandClient.tsx +23 -0
- package/src/client/ClientModule.tsx +21 -0
- package/src/client/CourierClient.tsx +49 -0
- package/src/client/InboxClient.tsx +114 -0
- package/src/client/PreferenceClient.tsx +77 -0
- package/src/client/TokenClient.tsx +34 -0
- package/src/client/TrackingClient.tsx +23 -0
- package/src/index.tsx +398 -205
- package/src/models/CourierBrand.tsx +24 -0
- package/src/models/CourierDevice.tsx +8 -0
- package/src/models/CourierInboxListener.tsx +1 -1
- package/src/models/CourierInboxMessages.tsx +28 -0
- package/src/models/CourierPushListener.tsx +11 -6
- package/src/models/CourierTrackingEvent.tsx +7 -0
- package/src/models/CourierUserPreferences.tsx +70 -3
- package/src/utils.tsx +7 -23
- package/src/views/CourierInboxView.tsx +3 -3
- package/android/src/main/java/com/courierreactnative/CourierReactNativeModule.kt +0 -393
- package/ios/CourierReactNativeModule.swift +0 -524
- package/lib/commonjs/models/CourierUserPreferencesChannel.js +0 -17
- package/lib/commonjs/models/CourierUserPreferencesChannel.js.map +0 -1
- package/lib/commonjs/models/CourierUserPreferencesStatus.js +0 -15
- package/lib/commonjs/models/CourierUserPreferencesStatus.js.map +0 -1
- package/lib/module/models/CourierUserPreferencesChannel.js +0 -10
- package/lib/module/models/CourierUserPreferencesChannel.js.map +0 -1
- package/lib/module/models/CourierUserPreferencesStatus.js +0 -8
- package/lib/module/models/CourierUserPreferencesStatus.js.map +0 -1
- package/lib/module/models/CourierUserPreferencesTopic.js +0 -2
- package/lib/typescript/index.d.ts +0 -199
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/models/Android_CourierSheet.d.ts.map +0 -1
- package/lib/typescript/models/CourierAuthenticationListener.d.ts.map +0 -1
- package/lib/typescript/models/CourierButton.d.ts.map +0 -1
- package/lib/typescript/models/CourierFont.d.ts.map +0 -1
- package/lib/typescript/models/CourierInboxListener.d.ts.map +0 -1
- package/lib/typescript/models/CourierInboxTheme.d.ts.map +0 -1
- package/lib/typescript/models/CourierInfoViewStyle.d.ts.map +0 -1
- package/lib/typescript/models/CourierPaging.d.ts.map +0 -1
- package/lib/typescript/models/CourierPreferencesTheme.d.ts.map +0 -1
- package/lib/typescript/models/CourierPushListener.d.ts +0 -7
- package/lib/typescript/models/CourierPushListener.d.ts.map +0 -1
- package/lib/typescript/models/CourierPushProvider.d.ts.map +0 -1
- package/lib/typescript/models/CourierUserPreferences.d.ts +0 -7
- package/lib/typescript/models/CourierUserPreferences.d.ts.map +0 -1
- package/lib/typescript/models/CourierUserPreferencesChannel.d.ts +0 -9
- package/lib/typescript/models/CourierUserPreferencesChannel.d.ts.map +0 -1
- package/lib/typescript/models/CourierUserPreferencesStatus.d.ts +0 -7
- package/lib/typescript/models/CourierUserPreferencesStatus.d.ts.map +0 -1
- package/lib/typescript/models/CourierUserPreferencesTopic.d.ts +0 -13
- package/lib/typescript/models/CourierUserPreferencesTopic.d.ts.map +0 -1
- package/lib/typescript/models/InboxAction.d.ts.map +0 -1
- package/lib/typescript/models/InboxMessage.d.ts.map +0 -1
- package/lib/typescript/models/iOS_CourierCell.d.ts.map +0 -1
- package/lib/typescript/models/iOS_CourierSheet.d.ts.map +0 -1
- package/lib/typescript/utils.d.ts +0 -21
- package/lib/typescript/utils.d.ts.map +0 -1
- package/lib/typescript/views/CourierInboxView.d.ts.map +0 -1
- package/lib/typescript/views/CourierPreferencesView.d.ts.map +0 -1
- package/src/models/CourierUserPreferencesChannel.tsx +0 -8
- package/src/models/CourierUserPreferencesStatus.tsx +0 -6
- package/src/models/CourierUserPreferencesTopic.tsx +0 -13
- /package/lib/typescript/{models → src/models}/Android_CourierSheet.d.ts +0 -0
- /package/lib/typescript/{models → src/models}/CourierAuthenticationListener.d.ts +0 -0
- /package/lib/typescript/{models → src/models}/CourierButton.d.ts +0 -0
- /package/lib/typescript/{models → src/models}/CourierFont.d.ts +0 -0
- /package/lib/typescript/{models → src/models}/CourierInboxListener.d.ts +0 -0
- /package/lib/typescript/{models → src/models}/CourierInboxTheme.d.ts +0 -0
- /package/lib/typescript/{models → src/models}/CourierInfoViewStyle.d.ts +0 -0
- /package/lib/typescript/{models → src/models}/CourierPaging.d.ts +0 -0
- /package/lib/typescript/{models → src/models}/CourierPreferencesTheme.d.ts +0 -0
- /package/lib/typescript/{models → src/models}/CourierPushProvider.d.ts +0 -0
- /package/lib/typescript/{models → src/models}/InboxAction.d.ts +0 -0
- /package/lib/typescript/{models → src/models}/InboxMessage.d.ts +0 -0
- /package/lib/typescript/{models → src/models}/iOS_CourierCell.d.ts +0 -0
- /package/lib/typescript/{models → src/models}/iOS_CourierSheet.d.ts +0 -0
- /package/lib/typescript/{views → src/views}/CourierInboxView.d.ts +0 -0
- /package/lib/typescript/{views → src/views}/CourierPreferencesView.d.ts +0 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface CourierBrandResponse {
|
|
2
|
+
data?: CourierBrandData
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export interface CourierBrandData {
|
|
6
|
+
brand?: CourierBrand
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface CourierBrand {
|
|
10
|
+
settings?: CourierBrandSettings
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface CourierBrandSettings {
|
|
14
|
+
inapp?: CourierBrandInApp
|
|
15
|
+
colors?: CourierBrandColors
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface CourierBrandInApp {
|
|
19
|
+
disableCourierFooter?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface CourierBrandColors {
|
|
23
|
+
primary?: string;
|
|
24
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { InboxMessage } from "./InboxMessage";
|
|
2
|
+
|
|
3
|
+
export interface CourierGetInboxMessagesResponse {
|
|
4
|
+
data?: GetInboxMessagesData;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface GetInboxMessagesData {
|
|
8
|
+
count?: number;
|
|
9
|
+
messages?: GetInboxMessagesNodes;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface GetInboxMessagesNodes {
|
|
13
|
+
pageInfo?: GetInboxMessagesPageInfo;
|
|
14
|
+
nodes?: InboxMessage[];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface GetInboxMessagesPageInfo {
|
|
18
|
+
startCursor?: string;
|
|
19
|
+
hasNextPage?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface CourierGetInboxMessageResponse {
|
|
23
|
+
data?: GetInboxMessageData;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface GetInboxMessageData {
|
|
27
|
+
message: InboxMessage;
|
|
28
|
+
}
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import { EmitterSubscription } from "react-native";
|
|
2
|
-
|
|
3
1
|
export class CourierPushListener {
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
public
|
|
3
|
+
readonly listenerId: string
|
|
4
|
+
public onPushNotificationClicked?: (push: any) => void
|
|
5
|
+
public onPushNotificationDelivered?: (push: any) => void
|
|
6
|
+
|
|
7
|
+
constructor(id: string, onPushNotificationClicked?: (push: any) => void, onPushNotificationDelivered?: (push: any) => void) {
|
|
8
|
+
this.listenerId = id;
|
|
9
|
+
this.onPushNotificationClicked = onPushNotificationClicked;
|
|
10
|
+
this.onPushNotificationDelivered = onPushNotificationDelivered;
|
|
11
|
+
}
|
|
7
12
|
|
|
8
13
|
public remove() {
|
|
9
|
-
this.
|
|
10
|
-
this.
|
|
14
|
+
this.onPushNotificationClicked = undefined;
|
|
15
|
+
this.onPushNotificationDelivered = undefined;
|
|
11
16
|
}
|
|
12
17
|
|
|
13
18
|
}
|
|
@@ -1,7 +1,74 @@
|
|
|
1
1
|
import { CourierPaging } from "./CourierPaging";
|
|
2
|
-
import { CourierUserPreferencesTopic } from "./CourierUserPreferencesTopic";
|
|
3
2
|
|
|
4
3
|
export interface CourierUserPreferences {
|
|
5
|
-
items
|
|
6
|
-
paging
|
|
4
|
+
items: CourierUserPreferencesTopic[];
|
|
5
|
+
paging: CourierPaging;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface CourierUserPreferencesTopic {
|
|
9
|
+
defaultStatus: CourierUserPreferencesStatus;
|
|
10
|
+
hasCustomRouting: boolean;
|
|
11
|
+
customRouting: CourierUserPreferencesChannel[];
|
|
12
|
+
status: CourierUserPreferencesStatus;
|
|
13
|
+
topicId: string;
|
|
14
|
+
topicName: string;
|
|
15
|
+
sectionName: string;
|
|
16
|
+
sectionId: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface GetCourierUserPreferencesTopic {
|
|
20
|
+
topic: CourierUserPreferencesTopic;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Additional interfaces for CourierUserPreferencesStatus and CourierUserPreferencesChannel would be needed based on their definitions
|
|
24
|
+
export enum CourierUserPreferencesStatus {
|
|
25
|
+
OptedIn = "OPTED_IN",
|
|
26
|
+
OptedOut = "OPTED_OUT",
|
|
27
|
+
Required = "REQUIRED",
|
|
28
|
+
Unknown = "UNKNOWN",
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Function to get the title of the enum value
|
|
32
|
+
export function getCourierUserPreferencesStatusTitle(status: CourierUserPreferencesStatus): string {
|
|
33
|
+
switch (status) {
|
|
34
|
+
case CourierUserPreferencesStatus.OptedIn:
|
|
35
|
+
return "Opted In";
|
|
36
|
+
case CourierUserPreferencesStatus.OptedOut:
|
|
37
|
+
return "Opted Out";
|
|
38
|
+
case CourierUserPreferencesStatus.Required:
|
|
39
|
+
return "Required";
|
|
40
|
+
case CourierUserPreferencesStatus.Unknown:
|
|
41
|
+
return "Unknown";
|
|
42
|
+
default:
|
|
43
|
+
return "Unknown";
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export enum CourierUserPreferencesChannel {
|
|
48
|
+
DirectMessage = "direct_message",
|
|
49
|
+
Email = "email",
|
|
50
|
+
Push = "push",
|
|
51
|
+
Sms = "sms",
|
|
52
|
+
Webhook = "webhook",
|
|
53
|
+
Unknown = "unknown",
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Function to get the title of the enum value
|
|
57
|
+
export function getCourierUserPreferencesChannelTitle(channel: CourierUserPreferencesChannel): string {
|
|
58
|
+
switch (channel) {
|
|
59
|
+
case CourierUserPreferencesChannel.DirectMessage:
|
|
60
|
+
return "In App Messages";
|
|
61
|
+
case CourierUserPreferencesChannel.Email:
|
|
62
|
+
return "Emails";
|
|
63
|
+
case CourierUserPreferencesChannel.Push:
|
|
64
|
+
return "Push Notifications";
|
|
65
|
+
case CourierUserPreferencesChannel.Sms:
|
|
66
|
+
return "Text Messages";
|
|
67
|
+
case CourierUserPreferencesChannel.Webhook:
|
|
68
|
+
return "Webhooks";
|
|
69
|
+
case CourierUserPreferencesChannel.Unknown:
|
|
70
|
+
return "Unknown";
|
|
71
|
+
default:
|
|
72
|
+
return "Unknown";
|
|
73
|
+
}
|
|
7
74
|
}
|
package/src/utils.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import packageJson from '../package.json';
|
|
2
2
|
|
|
3
3
|
export namespace Events {
|
|
4
4
|
|
|
@@ -13,29 +13,9 @@ export namespace Events {
|
|
|
13
13
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export
|
|
16
|
+
export class Utils {
|
|
17
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 {
|
|
18
|
+
static generateUUID(): string {
|
|
39
19
|
let uuid = '';
|
|
40
20
|
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
41
21
|
const charactersLength = characters.length;
|
|
@@ -45,4 +25,8 @@ export namespace Utils {
|
|
|
45
25
|
return uuid;
|
|
46
26
|
}
|
|
47
27
|
|
|
28
|
+
static getPackageVersion(): string {
|
|
29
|
+
return packageJson.version;
|
|
30
|
+
}
|
|
31
|
+
|
|
48
32
|
}
|
|
@@ -62,7 +62,7 @@ export const CourierInboxView = (props: CourierInboxViewProps) => {
|
|
|
62
62
|
if (props.onClickInboxMessageAtIndex) {
|
|
63
63
|
|
|
64
64
|
const index = event["index"];
|
|
65
|
-
const message = event["message"] as InboxMessage;
|
|
65
|
+
const message = JSON.parse(event["message"]) as InboxMessage;
|
|
66
66
|
|
|
67
67
|
props.onClickInboxMessageAtIndex(message, index);
|
|
68
68
|
|
|
@@ -86,8 +86,8 @@ export const CourierInboxView = (props: CourierInboxViewProps) => {
|
|
|
86
86
|
if (props.onClickInboxActionForMessageAtIndex) {
|
|
87
87
|
|
|
88
88
|
const index = event["index"];
|
|
89
|
-
const action = event["action"] as InboxAction;
|
|
90
|
-
const message = event["message"] as InboxMessage;
|
|
89
|
+
const action = JSON.parse(event["action"]) as InboxAction;
|
|
90
|
+
const message = JSON.parse(event["message"]) as InboxMessage;
|
|
91
91
|
|
|
92
92
|
props.onClickInboxActionForMessageAtIndex(action, message, index);
|
|
93
93
|
|
|
@@ -1,393 +0,0 @@
|
|
|
1
|
-
package com.courierreactnative
|
|
2
|
-
|
|
3
|
-
import android.content.Intent
|
|
4
|
-
import com.courier.android.Courier
|
|
5
|
-
import com.courier.android.models.CourierAgent
|
|
6
|
-
import com.courier.android.models.CourierAuthenticationListener
|
|
7
|
-
import com.courier.android.models.CourierInboxListener
|
|
8
|
-
import com.courier.android.models.CourierPreferenceChannel
|
|
9
|
-
import com.courier.android.models.CourierPreferenceStatus
|
|
10
|
-
import com.courier.android.models.InboxMessage
|
|
11
|
-
import com.courier.android.models.remove
|
|
12
|
-
import com.courier.android.modules.addAuthenticationListener
|
|
13
|
-
import com.courier.android.modules.addInboxListener
|
|
14
|
-
import com.courier.android.modules.clickMessage
|
|
15
|
-
import com.courier.android.modules.fetchNextPageOfMessages
|
|
16
|
-
import com.courier.android.modules.getToken
|
|
17
|
-
import com.courier.android.modules.getUserPreferenceTopic
|
|
18
|
-
import com.courier.android.modules.getUserPreferences
|
|
19
|
-
import com.courier.android.modules.inboxPaginationLimit
|
|
20
|
-
import com.courier.android.modules.isDebugging
|
|
21
|
-
import com.courier.android.modules.isPushPermissionGranted
|
|
22
|
-
import com.courier.android.modules.logListener
|
|
23
|
-
import com.courier.android.modules.putUserPreferenceTopic
|
|
24
|
-
import com.courier.android.modules.readAllInboxMessages
|
|
25
|
-
import com.courier.android.modules.readMessage
|
|
26
|
-
import com.courier.android.modules.refreshInbox
|
|
27
|
-
import com.courier.android.modules.requestNotificationPermission
|
|
28
|
-
import com.courier.android.modules.setToken
|
|
29
|
-
import com.courier.android.modules.signIn
|
|
30
|
-
import com.courier.android.modules.signOut
|
|
31
|
-
import com.courier.android.modules.tenantId
|
|
32
|
-
import com.courier.android.modules.unreadMessage
|
|
33
|
-
import com.courier.android.modules.userId
|
|
34
|
-
import com.courier.android.utils.pushNotification
|
|
35
|
-
import com.courier.android.utils.trackPushNotificationClick
|
|
36
|
-
import com.facebook.react.ReactActivity
|
|
37
|
-
import com.facebook.react.bridge.Arguments
|
|
38
|
-
import com.facebook.react.bridge.Promise
|
|
39
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
40
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
41
|
-
import com.facebook.react.bridge.ReactMethod
|
|
42
|
-
import com.facebook.react.bridge.ReadableArray
|
|
43
|
-
import com.google.firebase.messaging.RemoteMessage
|
|
44
|
-
import org.json.JSONObject
|
|
45
|
-
import java.util.UUID
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
class CourierReactNativeModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
|
|
49
|
-
|
|
50
|
-
override fun getName() = "CourierReactNativeModule"
|
|
51
|
-
private val reactActivity: ReactActivity? get() = currentActivity as? ReactActivity
|
|
52
|
-
|
|
53
|
-
// Listeners
|
|
54
|
-
private var authListeners = mutableMapOf<String, CourierAuthenticationListener>()
|
|
55
|
-
private var inboxListeners = mutableMapOf<String, CourierInboxListener>()
|
|
56
|
-
|
|
57
|
-
init {
|
|
58
|
-
|
|
59
|
-
// User Agent is used to ensure we know the SDK
|
|
60
|
-
// the requests come from
|
|
61
|
-
Courier.USER_AGENT = CourierAgent.REACT_NATIVE_ANDROID
|
|
62
|
-
|
|
63
|
-
// Attach the log listener
|
|
64
|
-
Courier.shared.logListener = { data ->
|
|
65
|
-
reactContext.sendEvent(CourierEvents.Log.DEBUG_LOG, data)
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
@ReactMethod
|
|
71
|
-
fun addListener(type: String?) {
|
|
72
|
-
// Keep: Required for RN built in Event Emitter Calls.
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
@ReactMethod
|
|
76
|
-
fun removeListeners(type: Int?) {
|
|
77
|
-
// Keep: Required for RN built in Event Emitter Calls.
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
81
|
-
fun setDebugMode(isDebugging: Boolean): Boolean {
|
|
82
|
-
Courier.shared.isDebugging = isDebugging
|
|
83
|
-
return Courier.shared.isDebugging
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
@ReactMethod
|
|
87
|
-
fun registerPushNotificationClickedOnKilledState() {
|
|
88
|
-
reactActivity?.let { activity ->
|
|
89
|
-
checkIntentForPushNotificationClick(activity.intent)
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
private fun checkIntentForPushNotificationClick(intent: Intent?) {
|
|
94
|
-
intent?.trackPushNotificationClick { message ->
|
|
95
|
-
postPushNotificationClicked(message)
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
private fun postPushNotificationClicked(message: RemoteMessage) {
|
|
100
|
-
reactApplicationContext.sendEvent(
|
|
101
|
-
eventName = CourierEvents.Push.CLICKED_EVENT,
|
|
102
|
-
value = JSONObject(message.pushNotification).toString()
|
|
103
|
-
)
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
@ReactMethod
|
|
107
|
-
fun requestNotificationPermission(promise: Promise) {
|
|
108
|
-
|
|
109
|
-
reactActivity?.let { activity ->
|
|
110
|
-
Courier.shared.requestNotificationPermission(activity)
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
promise.resolve("unknown")
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
@ReactMethod
|
|
118
|
-
fun getNotificationPermissionStatus(promise: Promise) {
|
|
119
|
-
|
|
120
|
-
reactActivity?.let { context ->
|
|
121
|
-
|
|
122
|
-
val isGranted = Courier.shared.isPushPermissionGranted(context)
|
|
123
|
-
val status = if (isGranted) "authorized" else "denied"
|
|
124
|
-
promise.resolve(status)
|
|
125
|
-
return
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
promise.resolve("unknown")
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
@ReactMethod
|
|
134
|
-
fun signIn(accessToken: String, clientKey: String?, userId: String, tenantId: String?, promise: Promise) {
|
|
135
|
-
Courier.shared.signIn(
|
|
136
|
-
accessToken = accessToken,
|
|
137
|
-
clientKey = clientKey,
|
|
138
|
-
userId = userId,
|
|
139
|
-
tenantId = tenantId,
|
|
140
|
-
onSuccess = {
|
|
141
|
-
promise.resolve(null)
|
|
142
|
-
},
|
|
143
|
-
onFailure = { e ->
|
|
144
|
-
promise.reject(CourierEvents.COURIER_ERROR_TAG, e)
|
|
145
|
-
}
|
|
146
|
-
)
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
@ReactMethod
|
|
150
|
-
fun signOut(promise: Promise) {
|
|
151
|
-
Courier.shared.signOut(
|
|
152
|
-
onSuccess = {
|
|
153
|
-
promise.resolve(null)
|
|
154
|
-
},
|
|
155
|
-
onFailure = { e ->
|
|
156
|
-
promise.reject(CourierEvents.COURIER_ERROR_TAG, e)
|
|
157
|
-
}
|
|
158
|
-
)
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
162
|
-
fun getUserId(): String? {
|
|
163
|
-
return Courier.shared.userId
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
167
|
-
fun getTenantId(): String? {
|
|
168
|
-
return Courier.shared.tenantId
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
172
|
-
fun addAuthenticationListener(authId: String): String {
|
|
173
|
-
|
|
174
|
-
// Create the listener
|
|
175
|
-
val listener = Courier.shared.addAuthenticationListener { userId ->
|
|
176
|
-
|
|
177
|
-
reactApplicationContext.sendEvent(
|
|
178
|
-
eventName = authId,
|
|
179
|
-
value = userId
|
|
180
|
-
)
|
|
181
|
-
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// Add the listener to the map
|
|
185
|
-
val id = UUID.randomUUID().toString()
|
|
186
|
-
authListeners[id] = listener
|
|
187
|
-
|
|
188
|
-
return id
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
193
|
-
fun removeAuthenticationListener(listenerId: String): String {
|
|
194
|
-
|
|
195
|
-
// Get the listener
|
|
196
|
-
val listener = authListeners[listenerId]
|
|
197
|
-
|
|
198
|
-
// Remove the listener
|
|
199
|
-
listener?.remove()
|
|
200
|
-
|
|
201
|
-
// Remove the listener
|
|
202
|
-
authListeners.remove(listenerId)
|
|
203
|
-
|
|
204
|
-
return listenerId
|
|
205
|
-
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
@ReactMethod
|
|
209
|
-
fun getToken(key: String, promise: Promise) {
|
|
210
|
-
val token = Courier.shared.getToken(key)
|
|
211
|
-
promise.resolve(token)
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
@ReactMethod
|
|
215
|
-
fun setToken(key: String, token: String, promise: Promise) {
|
|
216
|
-
Courier.shared.setToken(
|
|
217
|
-
provider = key,
|
|
218
|
-
token = token,
|
|
219
|
-
onSuccess = {
|
|
220
|
-
promise.resolve(null)
|
|
221
|
-
},
|
|
222
|
-
onFailure = { e ->
|
|
223
|
-
promise.reject(CourierEvents.COURIER_ERROR_TAG, e)
|
|
224
|
-
}
|
|
225
|
-
)
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
229
|
-
fun clickMessage(messageId: String): String {
|
|
230
|
-
Courier.shared.clickMessage(messageId, onFailure = null)
|
|
231
|
-
return messageId
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
235
|
-
fun readMessage(messageId: String): String {
|
|
236
|
-
Courier.shared.readMessage(messageId, onFailure = null)
|
|
237
|
-
return messageId
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
241
|
-
fun unreadMessage(messageId: String): String {
|
|
242
|
-
Courier.shared.unreadMessage(messageId, onFailure = null)
|
|
243
|
-
return messageId
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
@ReactMethod
|
|
247
|
-
fun readAllInboxMessages(promise: Promise) {
|
|
248
|
-
Courier.shared.readAllInboxMessages(
|
|
249
|
-
onSuccess = {
|
|
250
|
-
promise.resolve(null)
|
|
251
|
-
},
|
|
252
|
-
onFailure = { e ->
|
|
253
|
-
promise.reject(CourierEvents.COURIER_ERROR_TAG, e)
|
|
254
|
-
}
|
|
255
|
-
)
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
259
|
-
fun addInboxListener(loadingId: String, errorId: String, messagesId: String): String {
|
|
260
|
-
|
|
261
|
-
val listener = Courier.shared.addInboxListener(
|
|
262
|
-
onInitialLoad = {
|
|
263
|
-
|
|
264
|
-
reactApplicationContext.sendEvent(
|
|
265
|
-
eventName = loadingId,
|
|
266
|
-
value = null
|
|
267
|
-
)
|
|
268
|
-
|
|
269
|
-
},
|
|
270
|
-
onError = { e ->
|
|
271
|
-
|
|
272
|
-
reactApplicationContext.sendEvent(
|
|
273
|
-
eventName = errorId,
|
|
274
|
-
value = e.message ?: "Courier Inbox Error"
|
|
275
|
-
)
|
|
276
|
-
|
|
277
|
-
},
|
|
278
|
-
onMessagesChanged = { messages: List<InboxMessage>, unreadMessageCount: Int, totalMessageCount: Int, canPaginate: Boolean ->
|
|
279
|
-
|
|
280
|
-
val json = Arguments.createMap()
|
|
281
|
-
json.putArray("messages", messages.toList().toWritableArray())
|
|
282
|
-
json.putInt("unreadMessageCount", unreadMessageCount)
|
|
283
|
-
json.putInt("totalMessageCount", totalMessageCount)
|
|
284
|
-
json.putBoolean("canPaginate", canPaginate)
|
|
285
|
-
|
|
286
|
-
reactApplicationContext.sendEvent(
|
|
287
|
-
eventName = messagesId,
|
|
288
|
-
value = json
|
|
289
|
-
)
|
|
290
|
-
|
|
291
|
-
}
|
|
292
|
-
)
|
|
293
|
-
|
|
294
|
-
// Add listener
|
|
295
|
-
val id = UUID.randomUUID().toString()
|
|
296
|
-
inboxListeners[id] = listener
|
|
297
|
-
|
|
298
|
-
return id
|
|
299
|
-
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
303
|
-
fun removeInboxListener(listenerId: String): String {
|
|
304
|
-
|
|
305
|
-
// Get the listener
|
|
306
|
-
val listener = inboxListeners[listenerId]
|
|
307
|
-
|
|
308
|
-
// Remove the listener
|
|
309
|
-
listener?.remove()
|
|
310
|
-
|
|
311
|
-
// Remove the listener
|
|
312
|
-
inboxListeners.remove(listenerId)
|
|
313
|
-
|
|
314
|
-
return listenerId
|
|
315
|
-
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
@ReactMethod
|
|
319
|
-
fun refreshInbox(promise: Promise) {
|
|
320
|
-
Courier.shared.refreshInbox {
|
|
321
|
-
promise.resolve(null)
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
@ReactMethod
|
|
326
|
-
fun fetchNextPageOfMessages(promise: Promise) {
|
|
327
|
-
Courier.shared.fetchNextPageOfMessages(
|
|
328
|
-
onSuccess = { messages ->
|
|
329
|
-
promise.resolve(messages.toWritableArray())
|
|
330
|
-
},
|
|
331
|
-
onFailure = { e ->
|
|
332
|
-
promise.reject(CourierEvents.COURIER_ERROR_TAG, e)
|
|
333
|
-
}
|
|
334
|
-
)
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
338
|
-
fun setInboxPaginationLimit(limit: Double): String {
|
|
339
|
-
Courier.shared.inboxPaginationLimit = limit.toInt()
|
|
340
|
-
return Courier.shared.inboxPaginationLimit.toString()
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
@ReactMethod
|
|
344
|
-
fun getUserPreferences(paginationCursor: String, promise: Promise) {
|
|
345
|
-
|
|
346
|
-
val cursor = if (paginationCursor != "") paginationCursor else null
|
|
347
|
-
|
|
348
|
-
Courier.shared.getUserPreferences(
|
|
349
|
-
paginationCursor = cursor,
|
|
350
|
-
onSuccess = { preferences ->
|
|
351
|
-
promise.resolve(preferences.toWritableMap())
|
|
352
|
-
},
|
|
353
|
-
onFailure = { e ->
|
|
354
|
-
promise.reject(CourierEvents.COURIER_ERROR_TAG, e)
|
|
355
|
-
}
|
|
356
|
-
)
|
|
357
|
-
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
@ReactMethod
|
|
361
|
-
fun getUserPreferencesTopic(topicId: String, promise: Promise) {
|
|
362
|
-
Courier.shared.getUserPreferenceTopic(
|
|
363
|
-
topicId = topicId,
|
|
364
|
-
onSuccess = { topic ->
|
|
365
|
-
promise.resolve(topic.toWritableMap())
|
|
366
|
-
},
|
|
367
|
-
onFailure = { e ->
|
|
368
|
-
promise.reject(CourierEvents.COURIER_ERROR_TAG, e)
|
|
369
|
-
}
|
|
370
|
-
)
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
@ReactMethod
|
|
374
|
-
fun putUserPreferencesTopic(topicId: String, status: String, hasCustomRouting: Boolean, customRouting: ReadableArray, promise: Promise) {
|
|
375
|
-
|
|
376
|
-
val routing = customRouting.toArrayList().map { CourierPreferenceChannel.fromString(it as String) }
|
|
377
|
-
|
|
378
|
-
Courier.shared.putUserPreferenceTopic(
|
|
379
|
-
topicId = topicId,
|
|
380
|
-
status = CourierPreferenceStatus.fromString(status),
|
|
381
|
-
hasCustomRouting = hasCustomRouting,
|
|
382
|
-
customRouting = routing,
|
|
383
|
-
onSuccess = {
|
|
384
|
-
promise.resolve(null)
|
|
385
|
-
},
|
|
386
|
-
onFailure = { e ->
|
|
387
|
-
promise.reject(CourierEvents.COURIER_ERROR_TAG, e)
|
|
388
|
-
}
|
|
389
|
-
)
|
|
390
|
-
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
}
|