@trycourier/courier-react-native 3.2.2 → 4.1.0
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/README.md +14 -3
- 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/CourierReactNativeActivity.kt +4 -0
- package/android/src/main/java/com/courierreactnative/CourierReactNativePackage.kt +9 -3
- package/android/src/main/java/com/courierreactnative/CourierSharedModule.kt +312 -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 +21 -35
- package/ios/CourierReactNativeEventEmitter.swift +25 -0
- package/ios/CourierReactNativeModule.m +192 -23
- package/ios/CourierSharedModule.swift +412 -0
- package/ios/CourierSystemModule.swift +136 -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
package/lib/commonjs/index.js
CHANGED
|
@@ -3,18 +3,42 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
Object.defineProperty(exports, "BrandClient", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _BrandClient.BrandClient;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
6
12
|
Object.defineProperty(exports, "CourierAuthenticationListener", {
|
|
7
13
|
enumerable: true,
|
|
8
14
|
get: function () {
|
|
9
15
|
return _CourierAuthenticationListener.CourierAuthenticationListener;
|
|
10
16
|
}
|
|
11
17
|
});
|
|
18
|
+
Object.defineProperty(exports, "CourierBrandResponse", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _CourierBrand.CourierBrandResponse;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
12
24
|
Object.defineProperty(exports, "CourierButton", {
|
|
13
25
|
enumerable: true,
|
|
14
26
|
get: function () {
|
|
15
27
|
return _CourierButton.CourierButton;
|
|
16
28
|
}
|
|
17
29
|
});
|
|
30
|
+
Object.defineProperty(exports, "CourierClient", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _CourierClient.CourierClient;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "CourierDevice", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _CourierDevice.CourierDevice;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
18
42
|
Object.defineProperty(exports, "CourierFont", {
|
|
19
43
|
enumerable: true,
|
|
20
44
|
get: function () {
|
|
@@ -99,16 +123,28 @@ Object.defineProperty(exports, "CourierPushProvider", {
|
|
|
99
123
|
return _CourierPushProvider.CourierPushProvider;
|
|
100
124
|
}
|
|
101
125
|
});
|
|
126
|
+
Object.defineProperty(exports, "CourierTrackingEvent", {
|
|
127
|
+
enumerable: true,
|
|
128
|
+
get: function () {
|
|
129
|
+
return _CourierTrackingEvent.CourierTrackingEvent;
|
|
130
|
+
}
|
|
131
|
+
});
|
|
102
132
|
Object.defineProperty(exports, "CourierUserPreferencesChannel", {
|
|
103
133
|
enumerable: true,
|
|
104
134
|
get: function () {
|
|
105
|
-
return
|
|
135
|
+
return _CourierUserPreferences.CourierUserPreferencesChannel;
|
|
106
136
|
}
|
|
107
137
|
});
|
|
108
138
|
Object.defineProperty(exports, "CourierUserPreferencesStatus", {
|
|
109
139
|
enumerable: true,
|
|
110
140
|
get: function () {
|
|
111
|
-
return
|
|
141
|
+
return _CourierUserPreferences.CourierUserPreferencesStatus;
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
Object.defineProperty(exports, "CourierUserPreferencesTopic", {
|
|
145
|
+
enumerable: true,
|
|
146
|
+
get: function () {
|
|
147
|
+
return _CourierUserPreferences.CourierUserPreferencesTopic;
|
|
112
148
|
}
|
|
113
149
|
});
|
|
114
150
|
exports.default = void 0;
|
|
@@ -128,11 +164,17 @@ var _reactNative = require("react-native");
|
|
|
128
164
|
var _CourierInboxListener = require("./models/CourierInboxListener");
|
|
129
165
|
var _CourierPushListener = require("./models/CourierPushListener");
|
|
130
166
|
var _CourierAuthenticationListener = require("./models/CourierAuthenticationListener");
|
|
167
|
+
var _Modules = require("./Modules");
|
|
168
|
+
var _Broadcaster = _interopRequireDefault(require("./Broadcaster"));
|
|
169
|
+
var _CourierClient = require("./client/CourierClient");
|
|
131
170
|
var _utils = require("./utils");
|
|
171
|
+
var _BrandClient = require("./client/BrandClient");
|
|
172
|
+
var _CourierBrand = require("./models/CourierBrand");
|
|
173
|
+
var _CourierDevice = require("./models/CourierDevice");
|
|
132
174
|
var _CourierInboxView = require("./views/CourierInboxView");
|
|
133
175
|
var _CourierPreferencesView = require("./views/CourierPreferencesView");
|
|
134
|
-
var
|
|
135
|
-
var
|
|
176
|
+
var _CourierUserPreferences = require("./models/CourierUserPreferences");
|
|
177
|
+
var _CourierTrackingEvent = require("./models/CourierTrackingEvent");
|
|
136
178
|
var _CourierPushProvider = require("./models/CourierPushProvider");
|
|
137
179
|
var _CourierFont = require("./models/CourierFont");
|
|
138
180
|
var _CourierButton = require("./models/CourierButton");
|
|
@@ -141,29 +183,31 @@ var _iOS_CourierCell = require("./models/iOS_CourierCell");
|
|
|
141
183
|
var _iOS_CourierSheet = require("./models/iOS_CourierSheet");
|
|
142
184
|
var _CourierInboxTheme = require("./models/CourierInboxTheme");
|
|
143
185
|
var _CourierPreferencesTheme = require("./models/CourierPreferencesTheme");
|
|
186
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
144
187
|
// Imports
|
|
145
188
|
|
|
146
189
|
// Exports
|
|
147
190
|
|
|
148
|
-
const LINKING_ERROR = `The package '@trycourier/courier-react-native' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
|
|
149
|
-
ios: "- You have run 'pod install'\n",
|
|
150
|
-
default: ''
|
|
151
|
-
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
|
|
152
|
-
const CourierReactNativeModules = _reactNative.NativeModules.CourierReactNativeModule ? _reactNative.NativeModules.CourierReactNativeModule : new Proxy({}, {
|
|
153
|
-
get() {
|
|
154
|
-
throw new Error(LINKING_ERROR);
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
const CourierEventEmitter = new _reactNative.NativeEventEmitter(_reactNative.NativeModules.CourierReactNativeModule);
|
|
158
191
|
class Courier {
|
|
159
|
-
|
|
160
|
-
|
|
192
|
+
// Singleton
|
|
193
|
+
|
|
194
|
+
// Listeners
|
|
195
|
+
authenticationListeners = new Map();
|
|
161
196
|
inboxListeners = new Map();
|
|
197
|
+
pushListeners = new Map();
|
|
198
|
+
|
|
199
|
+
// Broadcasting
|
|
200
|
+
systemBroadcaster = new _Broadcaster.default(_Modules.Modules.System);
|
|
201
|
+
sharedBroadcaster = new _Broadcaster.default(_Modules.Modules.Shared);
|
|
162
202
|
constructor() {
|
|
163
203
|
// Sets the initial SDK values
|
|
164
|
-
//
|
|
165
|
-
|
|
166
|
-
|
|
204
|
+
// will show all foreground notification styles in iOS
|
|
205
|
+
Courier.setIOSForegroundPresentationOptions({
|
|
206
|
+
options: ['sound', 'badge', 'list', 'banner']
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
// Attach the push notification listeners
|
|
210
|
+
this.attachPushNotificationListeners();
|
|
167
211
|
}
|
|
168
212
|
|
|
169
213
|
// Returns the public shared instance
|
|
@@ -173,222 +217,408 @@ class Courier {
|
|
|
173
217
|
}
|
|
174
218
|
return this._sharedInstance;
|
|
175
219
|
}
|
|
176
|
-
async setDefaults() {
|
|
177
|
-
this.setIsDebugging(__DEV__);
|
|
178
|
-
this.iOSForegroundPresentationOptions({
|
|
179
|
-
options: ['sound', 'badge', 'list', 'banner']
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
220
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
*/
|
|
187
|
-
setIsDebugging(isDebugging) {
|
|
188
|
-
var _this$debugListener;
|
|
189
|
-
// Remove the existing listener if needed
|
|
190
|
-
(_this$debugListener = this.debugListener) === null || _this$debugListener === void 0 ? void 0 : _this$debugListener.remove();
|
|
221
|
+
// Debugging
|
|
222
|
+
|
|
223
|
+
isDebugging = __DEV__;
|
|
191
224
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
if (isDebugging) {
|
|
195
|
-
|
|
196
|
-
console.log('\x1b[36m%s\x1b[0m', 'COURIER', event);
|
|
197
|
-
});
|
|
225
|
+
// Show a log to the console
|
|
226
|
+
static log(message) {
|
|
227
|
+
if (Courier.shared.isDebugging) {
|
|
228
|
+
console.log(message);
|
|
198
229
|
}
|
|
199
|
-
CourierReactNativeModules.setDebugMode(isDebugging);
|
|
200
|
-
this._isDebugging = isDebugging;
|
|
201
|
-
return this._isDebugging;
|
|
202
230
|
}
|
|
203
231
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
232
|
+
// System (Static)
|
|
233
|
+
|
|
234
|
+
attachPushNotificationListeners() {
|
|
235
|
+
var _this$pushNotificatio, _this$pushNotificatio2;
|
|
236
|
+
// Remove existing listeners
|
|
237
|
+
// Only allows one subscription to be active
|
|
238
|
+
(_this$pushNotificatio = this.pushNotificationClickedEmitter) === null || _this$pushNotificatio === void 0 ? void 0 : _this$pushNotificatio.remove();
|
|
239
|
+
(_this$pushNotificatio2 = this.pushNotificationDeliveredEmitter) === null || _this$pushNotificatio2 === void 0 ? void 0 : _this$pushNotificatio2.remove();
|
|
240
|
+
|
|
241
|
+
// When a push notification is clicked
|
|
242
|
+
this.pushNotificationClickedEmitter = this.systemBroadcaster.addListener(_utils.Events.Push.CLICKED, event => {
|
|
243
|
+
try {
|
|
244
|
+
const message = JSON.parse(event);
|
|
245
|
+
this.pushListeners.forEach(listener => {
|
|
246
|
+
if (listener.onPushNotificationClicked) {
|
|
247
|
+
listener.onPushNotificationClicked(message);
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
} catch (error) {
|
|
251
|
+
Courier.log(`Error parsing push notification clicked event: ${error}`);
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
// When a push notification is delivered
|
|
256
|
+
this.pushNotificationDeliveredEmitter = this.systemBroadcaster.addListener(_utils.Events.Push.DELIVERED, event => {
|
|
257
|
+
try {
|
|
258
|
+
const message = JSON.parse(event);
|
|
259
|
+
this.pushListeners.forEach(listener => {
|
|
260
|
+
if (listener.onPushNotificationDelivered) {
|
|
261
|
+
listener.onPushNotificationDelivered(message);
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
} catch (error) {
|
|
265
|
+
Courier.log(`Error parsing push notification delivered event: ${error}`);
|
|
266
|
+
}
|
|
267
|
+
});
|
|
209
268
|
}
|
|
210
269
|
|
|
211
270
|
/**
|
|
212
|
-
* Sets the
|
|
271
|
+
* Sets the iOS foreground presentation options for push notifications.
|
|
272
|
+
* This method only works on iOS devices.
|
|
273
|
+
* @param props An object containing an array of iOSForegroundPresentationOptions.
|
|
274
|
+
* @returns A string indicating the result of the operation. Returns 'unsupported' on non-iOS platforms.
|
|
213
275
|
*/
|
|
214
|
-
|
|
276
|
+
static setIOSForegroundPresentationOptions(props) {
|
|
215
277
|
// Only works on iOS
|
|
216
278
|
if (_reactNative.Platform.OS !== 'ios') return 'unsupported';
|
|
217
279
|
const normalizedParams = Array.from(new Set(props.options));
|
|
218
|
-
return
|
|
280
|
+
return _Modules.Modules.System.setIOSForegroundPresentationOptions({
|
|
219
281
|
options: normalizedParams
|
|
220
282
|
});
|
|
221
283
|
}
|
|
222
284
|
|
|
223
285
|
/**
|
|
224
|
-
*
|
|
286
|
+
* Retrieves the current notification permission status.
|
|
287
|
+
* @returns A Promise that resolves to a string representing the current notification permission status.
|
|
225
288
|
*/
|
|
226
|
-
|
|
227
|
-
return
|
|
228
|
-
}
|
|
229
|
-
getTokenForProvider(props) {
|
|
230
|
-
return CourierReactNativeModules.getToken(props.provider);
|
|
289
|
+
static async getNotificationPermissionStatus() {
|
|
290
|
+
return await _Modules.Modules.System.getNotificationPermissionStatus();
|
|
231
291
|
}
|
|
232
292
|
|
|
233
293
|
/**
|
|
234
|
-
*
|
|
294
|
+
* Requests permission to send push notifications to the user.
|
|
295
|
+
* @returns A Promise that resolves to a string indicating the result of the permission request.
|
|
235
296
|
*/
|
|
236
|
-
|
|
237
|
-
return
|
|
238
|
-
}
|
|
239
|
-
setTokenForProvider(props) {
|
|
240
|
-
return CourierReactNativeModules.setToken(props.provider, props.token);
|
|
297
|
+
static async requestNotificationPermission() {
|
|
298
|
+
return await _Modules.Modules.System.requestNotificationPermission();
|
|
241
299
|
}
|
|
242
300
|
|
|
243
301
|
/**
|
|
244
|
-
*
|
|
245
|
-
*
|
|
302
|
+
* Opens the settings page for the current app.
|
|
303
|
+
* This can be used to direct users to enable notifications if they've previously denied permission.
|
|
246
304
|
*/
|
|
247
|
-
|
|
248
|
-
|
|
305
|
+
static openSettingsForApp() {
|
|
306
|
+
_Modules.Modules.System.openSettingsForApp();
|
|
249
307
|
}
|
|
250
308
|
|
|
251
|
-
|
|
252
|
-
* Requests notification permissions
|
|
253
|
-
* This will show a dialog asking the user for permission
|
|
254
|
-
* Only supported on iOS
|
|
255
|
-
*/
|
|
256
|
-
requestNotificationPermission() {
|
|
257
|
-
return CourierReactNativeModules.requestNotificationPermission();
|
|
258
|
-
}
|
|
309
|
+
// Client
|
|
259
310
|
|
|
260
311
|
/**
|
|
261
|
-
*
|
|
312
|
+
* Gets the current CourierClient instance.
|
|
313
|
+
* @returns {CourierClient | undefined} The current CourierClient instance, or undefined if not initialized.
|
|
262
314
|
*/
|
|
263
|
-
|
|
264
|
-
const
|
|
265
|
-
if (
|
|
266
|
-
|
|
267
|
-
try {
|
|
268
|
-
props.onPushNotificationClicked(JSON.parse(event));
|
|
269
|
-
} catch (error) {
|
|
270
|
-
console.log(error);
|
|
271
|
-
}
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
if (props.onPushNotificationDelivered) {
|
|
275
|
-
pushListener.onNotificationDeliveredListener = _utils.Utils.addEventListener(_utils.Events.Push.DELIVERED, CourierEventEmitter, event => {
|
|
276
|
-
try {
|
|
277
|
-
props.onPushNotificationDelivered(JSON.parse(event));
|
|
278
|
-
} catch (error) {
|
|
279
|
-
console.log(error);
|
|
280
|
-
}
|
|
281
|
-
});
|
|
315
|
+
get client() {
|
|
316
|
+
const client = _Modules.Modules.Shared.getClient() ?? undefined;
|
|
317
|
+
if (!client) {
|
|
318
|
+
return undefined;
|
|
282
319
|
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
320
|
+
const clientObj = JSON.parse(client);
|
|
321
|
+
return new _CourierClient.CourierClient({
|
|
322
|
+
userId: clientObj.userId,
|
|
323
|
+
showLogs: clientObj.showLogs,
|
|
324
|
+
jwt: clientObj.jwt,
|
|
325
|
+
clientKey: clientObj.clientKey,
|
|
326
|
+
connectionId: clientObj.connectionId,
|
|
327
|
+
tenantId: clientObj.tenantId
|
|
328
|
+
});
|
|
290
329
|
}
|
|
291
330
|
|
|
331
|
+
// Authentication
|
|
332
|
+
|
|
292
333
|
/**
|
|
293
|
-
* Gets the user
|
|
294
|
-
*
|
|
334
|
+
* Gets the current user ID.
|
|
335
|
+
* @returns {string | undefined} The current user ID, or undefined if not set.
|
|
295
336
|
*/
|
|
296
337
|
get userId() {
|
|
297
|
-
return
|
|
338
|
+
return _Modules.Modules.Shared.getUserId() ?? undefined;
|
|
298
339
|
}
|
|
299
340
|
|
|
300
341
|
/**
|
|
301
|
-
* Gets the tenant
|
|
342
|
+
* Gets the current tenant ID.
|
|
343
|
+
* @returns {string | undefined} The current tenant ID, or undefined if not set.
|
|
302
344
|
*/
|
|
303
345
|
get tenantId() {
|
|
304
|
-
return
|
|
346
|
+
return _Modules.Modules.Shared.getTenantId() ?? undefined;
|
|
305
347
|
}
|
|
306
348
|
|
|
307
349
|
/**
|
|
308
|
-
*
|
|
350
|
+
* Checks if a user is currently signed in.
|
|
351
|
+
* @returns {boolean} True if a user is signed in, false otherwise.
|
|
309
352
|
*/
|
|
310
|
-
|
|
311
|
-
|
|
353
|
+
get isUserSignedIn() {
|
|
354
|
+
const isSignedIn = _Modules.Modules.Shared.getIsUserSignedIn() ?? 'false';
|
|
355
|
+
return isSignedIn.toLowerCase() === 'true';
|
|
312
356
|
}
|
|
313
357
|
|
|
314
358
|
/**
|
|
315
|
-
*
|
|
359
|
+
* Signs out the current user.
|
|
360
|
+
* @returns {Promise<void>} A promise that resolves when the sign out process is complete.
|
|
316
361
|
*/
|
|
317
|
-
signOut() {
|
|
318
|
-
return
|
|
362
|
+
async signOut() {
|
|
363
|
+
return await _Modules.Modules.Shared.signOut();
|
|
319
364
|
}
|
|
320
365
|
|
|
321
366
|
/**
|
|
322
|
-
*
|
|
367
|
+
* Signs in a user with the provided credentials.
|
|
368
|
+
* @param {Object} props - The sign-in properties.
|
|
369
|
+
* @param {string} props.accessToken - The access token for authentication.
|
|
370
|
+
* @param {string} [props.clientKey] - The client key (optional).
|
|
371
|
+
* @param {string} props.userId - The user ID.
|
|
372
|
+
* @param {string} [props.tenantId] - The tenant ID (optional).
|
|
373
|
+
* @param {boolean} [props.showLogs] - Whether to show debug logs (defaults to __DEV__).
|
|
374
|
+
* @returns {Promise<void>} A promise that resolves when the sign-in process is complete.
|
|
323
375
|
*/
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
376
|
+
async signIn(props) {
|
|
377
|
+
this.isDebugging = props.showLogs ?? __DEV__;
|
|
378
|
+
return await _Modules.Modules.Shared.signIn(props.accessToken, props.clientKey ?? null, props.userId, props.tenantId ?? null, this.isDebugging);
|
|
379
|
+
}
|
|
327
380
|
|
|
328
|
-
|
|
329
|
-
|
|
381
|
+
/**
|
|
382
|
+
* Adds an authentication listener to monitor user changes.
|
|
383
|
+
* @param {Object} props - The listener properties.
|
|
384
|
+
* @param {function} props.onUserChanged - Callback function triggered when the user changes.
|
|
385
|
+
* @returns {CourierAuthenticationListener} The created authentication listener.
|
|
386
|
+
*/
|
|
387
|
+
addAuthenticationListener(props) {
|
|
388
|
+
// Create a listener
|
|
389
|
+
const listenerId = `authentication_${_utils.Utils.generateUUID()}`;
|
|
390
|
+
const id = _Modules.Modules.Shared.addAuthenticationListener(listenerId);
|
|
330
391
|
|
|
331
|
-
//
|
|
392
|
+
// Attach the listener
|
|
332
393
|
const listener = new _CourierAuthenticationListener.CourierAuthenticationListener(id);
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
listener.onUserChanged = _utils.Utils.addEventListener(authId, CourierEventEmitter, event => props.onUserChanged(event));
|
|
336
|
-
|
|
337
|
-
// Add listener to manager
|
|
338
|
-
this.authListeners.set(id, listener);
|
|
394
|
+
listener.onUserChanged = this.sharedBroadcaster.addListener(listenerId, event => props.onUserChanged(event));
|
|
395
|
+
this.authenticationListeners.set(id, listener);
|
|
339
396
|
return listener;
|
|
340
397
|
}
|
|
341
398
|
|
|
342
399
|
/**
|
|
343
|
-
* Removes
|
|
400
|
+
* Removes a specific authentication listener.
|
|
401
|
+
* @param {Object} props - The removal properties.
|
|
402
|
+
* @param {string} props.listenerId - The ID of the listener to remove.
|
|
403
|
+
* @returns {string} The ID of the removed listener.
|
|
344
404
|
*/
|
|
345
405
|
removeAuthenticationListener(props) {
|
|
346
406
|
// Remove the native listener
|
|
347
|
-
|
|
407
|
+
_Modules.Modules.Shared.removeAuthenticationListener(props.listenerId);
|
|
348
408
|
|
|
349
409
|
// Remove the listener
|
|
350
|
-
if (this.
|
|
410
|
+
if (this.authenticationListeners.has(props.listenerId)) {
|
|
351
411
|
var _listener$onUserChang;
|
|
352
|
-
|
|
353
|
-
const listener = this.authListeners.get(props.listenerId);
|
|
412
|
+
const listener = this.authenticationListeners.get(props.listenerId);
|
|
354
413
|
listener === null || listener === void 0 || (_listener$onUserChang = listener.onUserChanged) === null || _listener$onUserChang === void 0 ? void 0 : _listener$onUserChang.remove();
|
|
414
|
+
this.authenticationListeners.delete(props.listenerId);
|
|
415
|
+
}
|
|
416
|
+
return props.listenerId;
|
|
417
|
+
}
|
|
355
418
|
|
|
356
|
-
|
|
357
|
-
|
|
419
|
+
/**
|
|
420
|
+
* Removes all authentication listeners.
|
|
421
|
+
* This method clears all registered authentication listeners, both native and JavaScript.
|
|
422
|
+
*/
|
|
423
|
+
removeAllAuthenticationListeners() {
|
|
424
|
+
// Remove all native listeners
|
|
425
|
+
_Modules.Modules.Shared.removeAllAuthenticationListeners();
|
|
426
|
+
|
|
427
|
+
// Iterate through all authentication listeners
|
|
428
|
+
this.authenticationListeners.forEach(listener => {
|
|
429
|
+
var _listener$onUserChang2;
|
|
430
|
+
(_listener$onUserChang2 = listener.onUserChanged) === null || _listener$onUserChang2 === void 0 ? void 0 : _listener$onUserChang2.remove();
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
// Clear the map of authentication listeners
|
|
434
|
+
this.authenticationListeners.clear();
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
// Push
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Retrieves all push notification tokens.
|
|
441
|
+
* @returns {Promise<Map<string, string>>} A promise that resolves to a Map of provider keys to tokens.
|
|
442
|
+
*/
|
|
443
|
+
async getAllTokens() {
|
|
444
|
+
const tokensObject = await _Modules.Modules.Shared.getAllTokens();
|
|
445
|
+
const tokensMap = new Map();
|
|
446
|
+
for (const [key, value] of Object.entries(tokensObject)) {
|
|
447
|
+
tokensMap.set(key, value);
|
|
448
|
+
}
|
|
449
|
+
return tokensMap;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Retrieves the push notification token for a specific key.
|
|
454
|
+
* @param {Object} props - The properties object.
|
|
455
|
+
* @param {string} props.key - The key associated with the token.
|
|
456
|
+
* @returns {Promise<string | undefined>} A promise that resolves to the token or undefined if not found.
|
|
457
|
+
*/
|
|
458
|
+
async getToken(props) {
|
|
459
|
+
return await _Modules.Modules.Shared.getToken(props.key);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* Retrieves the push notification token for a specific provider.
|
|
464
|
+
* @param {Object} props - The properties object.
|
|
465
|
+
* @param {CourierPushProvider} props.provider - The push notification provider.
|
|
466
|
+
* @returns {Promise<string | undefined>} A promise that resolves to the token or undefined if not found.
|
|
467
|
+
*/
|
|
468
|
+
async getTokenForProvider(props) {
|
|
469
|
+
return await _Modules.Modules.Shared.getToken(props.provider);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* Sets the push notification token for a specific key.
|
|
474
|
+
* @param {Object} props - The properties object.
|
|
475
|
+
* @param {string} props.key - The key to associate with the token.
|
|
476
|
+
* @param {string} props.token - The push notification token.
|
|
477
|
+
* @returns {Promise<void>} A promise that resolves when the token is set.
|
|
478
|
+
*/
|
|
479
|
+
async setToken(props) {
|
|
480
|
+
return await _Modules.Modules.Shared.setToken(props.key, props.token);
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* Sets the push notification token for a specific provider.
|
|
485
|
+
* @param {Object} props - The properties object.
|
|
486
|
+
* @param {CourierPushProvider} props.provider - The push notification provider.
|
|
487
|
+
* @param {string} props.token - The push notification token.
|
|
488
|
+
* @returns {Promise<void>} A promise that resolves when the token is set.
|
|
489
|
+
*/
|
|
490
|
+
async setTokenForProvider(props) {
|
|
491
|
+
return await _Modules.Modules.Shared.setToken(props.provider, props.token);
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* Adds a push notification listener.
|
|
496
|
+
* @param {Object} props - The properties object.
|
|
497
|
+
* @param {function} [props.onPushNotificationClicked] - Callback function triggered when a push notification is clicked.
|
|
498
|
+
* @param {function} [props.onPushNotificationDelivered] - Callback function triggered when a push notification is delivered.
|
|
499
|
+
* @returns {CourierPushListener} The created push notification listener.
|
|
500
|
+
*/
|
|
501
|
+
addPushNotificationListener(props) {
|
|
502
|
+
const listenerId = `push_${_utils.Utils.generateUUID()}`;
|
|
503
|
+
const pushListener = new _CourierPushListener.CourierPushListener(listenerId, props.onPushNotificationClicked, props.onPushNotificationDelivered);
|
|
504
|
+
|
|
505
|
+
// Cache the listener
|
|
506
|
+
this.pushListeners.set(listenerId, pushListener);
|
|
507
|
+
|
|
508
|
+
// When listener is registered
|
|
509
|
+
// Attempt to fetch the last message that was clicked
|
|
510
|
+
// This is needed for when the app is killed and the
|
|
511
|
+
// user launched the app by clicking on a notifications
|
|
512
|
+
_Modules.Modules.System.registerPushNotificationClickedOnKilledState();
|
|
513
|
+
return pushListener;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* Removes a specific push notification listener.
|
|
518
|
+
* @param {Object} props - The properties object.
|
|
519
|
+
* @param {string} props.listenerId - The ID of the listener to remove.
|
|
520
|
+
* @returns {string} The ID of the removed listener.
|
|
521
|
+
*/
|
|
522
|
+
removePushNotificationListener(props) {
|
|
523
|
+
if (this.pushListeners.has(props.listenerId)) {
|
|
524
|
+
this.pushListeners.delete(props.listenerId);
|
|
358
525
|
}
|
|
359
526
|
return props.listenerId;
|
|
360
527
|
}
|
|
361
528
|
|
|
362
529
|
/**
|
|
363
|
-
*
|
|
530
|
+
* Removes all push notification listeners.
|
|
531
|
+
*/
|
|
532
|
+
removeAllPushNotificationListeners() {
|
|
533
|
+
this.pushListeners.forEach(listener => {
|
|
534
|
+
listener.remove();
|
|
535
|
+
});
|
|
536
|
+
this.pushListeners.clear();
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
// Inbox
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* Gets the current pagination limit for inbox messages.
|
|
543
|
+
* @returns {number} The current pagination limit.
|
|
544
|
+
*/
|
|
545
|
+
get inboxPaginationLimit() {
|
|
546
|
+
return _Modules.Modules.Shared.getInboxPaginationLimit();
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* Sets the pagination limit for inbox messages.
|
|
551
|
+
* @param {number} limit - The new pagination limit to set.
|
|
552
|
+
*/
|
|
553
|
+
set inboxPaginationLimit(limit) {
|
|
554
|
+
_Modules.Modules.Shared.setInboxPaginationLimit(limit);
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* Opens a specific message in the inbox.
|
|
559
|
+
* @param {Object} props - The properties object.
|
|
560
|
+
* @param {string} props.messageId - The ID of the message to open.
|
|
561
|
+
* @returns {Promise<void>} A promise that resolves when the message is opened.
|
|
562
|
+
*/
|
|
563
|
+
async openMessage(props) {
|
|
564
|
+
return await _Modules.Modules.Shared.openMessage(props.messageId);
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* Registers a click event for a specific message in the inbox.
|
|
569
|
+
* @param {Object} props - The properties object.
|
|
570
|
+
* @param {string} props.messageId - The ID of the message that was clicked.
|
|
571
|
+
* @returns {Promise<void>} A promise that resolves when the click is registered.
|
|
364
572
|
*/
|
|
365
|
-
clickMessage(props) {
|
|
366
|
-
return
|
|
573
|
+
async clickMessage(props) {
|
|
574
|
+
return await _Modules.Modules.Shared.clickMessage(props.messageId);
|
|
367
575
|
}
|
|
368
576
|
|
|
369
577
|
/**
|
|
370
|
-
*
|
|
578
|
+
* Marks a specific message as read in the inbox.
|
|
579
|
+
* @param {Object} props - The properties object.
|
|
580
|
+
* @param {string} props.messageId - The ID of the message to mark as read.
|
|
581
|
+
* @returns {Promise<void>} A promise that resolves when the message is marked as read.
|
|
371
582
|
*/
|
|
372
|
-
readMessage(props) {
|
|
373
|
-
return
|
|
583
|
+
async readMessage(props) {
|
|
584
|
+
return await _Modules.Modules.Shared.readMessage(props.messageId);
|
|
374
585
|
}
|
|
375
586
|
|
|
376
587
|
/**
|
|
377
|
-
*
|
|
588
|
+
* Marks a specific message as unread in the inbox.
|
|
589
|
+
* @param {Object} props - The properties object.
|
|
590
|
+
* @param {string} props.messageId - The ID of the message to mark as unread.
|
|
591
|
+
* @returns {Promise<void>} A promise that resolves when the message is marked as unread.
|
|
378
592
|
*/
|
|
379
|
-
unreadMessage(props) {
|
|
380
|
-
return
|
|
593
|
+
async unreadMessage(props) {
|
|
594
|
+
return await _Modules.Modules.Shared.unreadMessage(props.messageId);
|
|
381
595
|
}
|
|
382
596
|
|
|
383
597
|
/**
|
|
384
|
-
*
|
|
598
|
+
* Archives a specific message in the inbox.
|
|
599
|
+
* @param {Object} props - The properties object.
|
|
600
|
+
* @param {string} props.messageId - The ID of the message to archive.
|
|
601
|
+
* @returns {Promise<void>} A promise that resolves when the message is archived.
|
|
385
602
|
*/
|
|
386
|
-
|
|
387
|
-
return
|
|
603
|
+
async archiveMessage(props) {
|
|
604
|
+
return await _Modules.Modules.Shared.archiveMessage(props.messageId);
|
|
388
605
|
}
|
|
389
606
|
|
|
390
607
|
/**
|
|
391
|
-
*
|
|
608
|
+
* Marks all messages in the inbox as read.
|
|
609
|
+
* @returns {Promise<void>} A promise that resolves when all messages are marked as read.
|
|
610
|
+
*/
|
|
611
|
+
async readAllInboxMessages() {
|
|
612
|
+
return await _Modules.Modules.Shared.readAllInboxMessages();
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
/**
|
|
616
|
+
* Adds a listener for inbox changes.
|
|
617
|
+
* @param {Object} props - The properties object.
|
|
618
|
+
* @param {Function} [props.onInitialLoad] - Callback function called when the inbox is initially loaded.
|
|
619
|
+
* @param {Function} [props.onError] - Callback function called when an error occurs. Receives the error message as a parameter.
|
|
620
|
+
* @param {Function} [props.onMessagesChanged] - Callback function called when messages change. Receives updated messages, unread count, total count, and pagination status.
|
|
621
|
+
* @returns {CourierInboxListener} A listener object that can be used to remove the listener later.
|
|
392
622
|
*/
|
|
393
623
|
addInboxListener(props) {
|
|
394
624
|
const listenerIds = {
|
|
@@ -398,21 +628,31 @@ class Courier {
|
|
|
398
628
|
};
|
|
399
629
|
|
|
400
630
|
// Set the listener id
|
|
401
|
-
const id =
|
|
631
|
+
const id = _Modules.Modules.Shared.addInboxListener(listenerIds.loading, listenerIds.error, listenerIds.messages);
|
|
402
632
|
|
|
403
633
|
// Create the initial listeners
|
|
404
634
|
const listener = new _CourierInboxListener.CourierInboxListener(id);
|
|
405
|
-
listener.onInitialLoad =
|
|
635
|
+
listener.onInitialLoad = this.sharedBroadcaster.addListener(listenerIds.loading, _ => {
|
|
406
636
|
var _props$onInitialLoad;
|
|
407
637
|
(_props$onInitialLoad = props.onInitialLoad) === null || _props$onInitialLoad === void 0 ? void 0 : _props$onInitialLoad.call(props);
|
|
408
638
|
});
|
|
409
|
-
listener.onError =
|
|
639
|
+
listener.onError = this.sharedBroadcaster.addListener(listenerIds.error, event => {
|
|
410
640
|
var _props$onError;
|
|
411
641
|
(_props$onError = props.onError) === null || _props$onError === void 0 ? void 0 : _props$onError.call(props, event);
|
|
412
642
|
});
|
|
413
|
-
listener.onMessagesChanged =
|
|
643
|
+
listener.onMessagesChanged = this.sharedBroadcaster.addListener(listenerIds.messages, event => {
|
|
414
644
|
var _props$onMessagesChan;
|
|
415
|
-
|
|
645
|
+
// Convert JSON strings to InboxMessage objects
|
|
646
|
+
const convertedMessages = event.messages.map(jsonString => {
|
|
647
|
+
try {
|
|
648
|
+
const parsedMessage = JSON.parse(jsonString);
|
|
649
|
+
return parsedMessage;
|
|
650
|
+
} catch (error) {
|
|
651
|
+
Courier.log(`Error parsing message: ${error}`);
|
|
652
|
+
return null;
|
|
653
|
+
}
|
|
654
|
+
}).filter(message => message !== null);
|
|
655
|
+
(_props$onMessagesChan = props.onMessagesChanged) === null || _props$onMessagesChan === void 0 ? void 0 : _props$onMessagesChan.call(props, convertedMessages, event.unreadMessageCount, event.totalMessageCount, event.canPaginate);
|
|
416
656
|
});
|
|
417
657
|
|
|
418
658
|
// Add listener to manager
|
|
@@ -421,11 +661,14 @@ class Courier {
|
|
|
421
661
|
}
|
|
422
662
|
|
|
423
663
|
/**
|
|
424
|
-
* Removes
|
|
664
|
+
* Removes a specific inbox listener.
|
|
665
|
+
* @param {Object} props - The properties object.
|
|
666
|
+
* @param {string} props.listenerId - The ID of the listener to remove.
|
|
667
|
+
* @returns {string} The ID of the removed listener.
|
|
425
668
|
*/
|
|
426
669
|
removeInboxListener(props) {
|
|
427
670
|
// Call native code
|
|
428
|
-
|
|
671
|
+
_Modules.Modules.Shared.removeInboxListener(props.listenerId);
|
|
429
672
|
|
|
430
673
|
// Remove the listener
|
|
431
674
|
if (this.inboxListeners.has(props.listenerId)) {
|
|
@@ -443,49 +686,38 @@ class Courier {
|
|
|
443
686
|
}
|
|
444
687
|
|
|
445
688
|
/**
|
|
446
|
-
*
|
|
447
|
-
* Useful for pull to refresh
|
|
448
|
-
*/
|
|
449
|
-
async refreshInbox() {
|
|
450
|
-
return CourierReactNativeModules.refreshInbox();
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
/**
|
|
454
|
-
* Fetches the next page of inbox messages
|
|
455
|
-
* Returns the fetched inbox messages
|
|
456
|
-
*/
|
|
457
|
-
async fetchNextPageOfMessages() {
|
|
458
|
-
return CourierReactNativeModules.fetchNextPageOfMessages();
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
/**
|
|
462
|
-
* Sets the pagination limit
|
|
463
|
-
* Min = 1
|
|
464
|
-
* Max = 100
|
|
465
|
-
*/
|
|
466
|
-
setInboxPaginationLimit(props) {
|
|
467
|
-
CourierReactNativeModules.setInboxPaginationLimit(props.limit);
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
/**
|
|
471
|
-
* Get all available preferences
|
|
689
|
+
* Removes all inbox listeners.
|
|
472
690
|
*/
|
|
473
|
-
|
|
474
|
-
|
|
691
|
+
removeAllInboxListeners() {
|
|
692
|
+
// Call native code
|
|
693
|
+
_Modules.Modules.Shared.removeAllInboxListeners();
|
|
694
|
+
|
|
695
|
+
// Remove all items from inboxListeners
|
|
696
|
+
this.inboxListeners.forEach(listener => {
|
|
697
|
+
var _listener$onInitialLo2, _listener$onError2, _listener$onMessagesC2;
|
|
698
|
+
listener === null || listener === void 0 || (_listener$onInitialLo2 = listener.onInitialLoad) === null || _listener$onInitialLo2 === void 0 ? void 0 : _listener$onInitialLo2.remove();
|
|
699
|
+
listener === null || listener === void 0 || (_listener$onError2 = listener.onError) === null || _listener$onError2 === void 0 ? void 0 : _listener$onError2.remove();
|
|
700
|
+
listener === null || listener === void 0 || (_listener$onMessagesC2 = listener.onMessagesChanged) === null || _listener$onMessagesC2 === void 0 ? void 0 : _listener$onMessagesC2.remove();
|
|
701
|
+
});
|
|
702
|
+
this.inboxListeners.clear();
|
|
475
703
|
}
|
|
476
704
|
|
|
477
705
|
/**
|
|
478
|
-
*
|
|
706
|
+
* Refreshes the inbox.
|
|
707
|
+
* Useful for pull-to-refresh functionality.
|
|
708
|
+
* @returns {Promise<void>} A promise that resolves when the inbox is refreshed.
|
|
479
709
|
*/
|
|
480
|
-
async
|
|
481
|
-
return
|
|
710
|
+
async refreshInbox() {
|
|
711
|
+
return _Modules.Modules.Shared.refreshInbox();
|
|
482
712
|
}
|
|
483
713
|
|
|
484
714
|
/**
|
|
485
|
-
*
|
|
715
|
+
* Fetches the next page of inbox messages.
|
|
716
|
+
* @returns {Promise<InboxMessage[]>} A promise that resolves with an array of fetched inbox messages.
|
|
486
717
|
*/
|
|
487
|
-
async
|
|
488
|
-
|
|
718
|
+
async fetchNextPageOfMessages() {
|
|
719
|
+
const messages = await _Modules.Modules.Shared.fetchNextPageOfMessages();
|
|
720
|
+
return messages.map(message => JSON.parse(message));
|
|
489
721
|
}
|
|
490
722
|
}
|
|
491
723
|
var _default = Courier;
|