@trycourier/courier-react-native 2.0.0-beta9 → 2.0.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 +190 -15
- package/android/src/main/java/com/courierreactnative/CourierReactNativeModule.kt +8 -18
- package/lib/commonjs/index.js +39 -75
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +39 -75
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/index.d.ts +30 -73
- package/lib/typescript/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/index.tsx +44 -75
package/README.md
CHANGED
|
@@ -1,31 +1,206 @@
|
|
|
1
|
-
|
|
1
|
+
<img width="1040" alt="banner-react-native" src="https://github.com/trycourier/courier-react-native/assets/6370613/2970316d-fdb2-4491-8578-cf4aec1bcfe6">
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
 
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
# Requirements & Support
|
|
6
|
+
|
|
7
|
+
 
|
|
8
|
+
|
|
9
|
+
<table>
|
|
10
|
+
<thead>
|
|
11
|
+
<tr>
|
|
12
|
+
<th width="920px" align="left">Requirements</th>
|
|
13
|
+
<th width="120px" align="center"></th>
|
|
14
|
+
</tr>
|
|
15
|
+
</thead>
|
|
16
|
+
<tbody>
|
|
17
|
+
<tr width="600px">
|
|
18
|
+
<td align="left">Courier Account</td>
|
|
19
|
+
<td align="center">
|
|
20
|
+
<a href="https://app.courier.com/channels/courier">
|
|
21
|
+
<code>Sign Up</code>
|
|
22
|
+
</a>
|
|
23
|
+
</td>
|
|
24
|
+
</tr>
|
|
25
|
+
<tr width="600px">
|
|
26
|
+
<td align="left">Minimum iOS SDK Version</td>
|
|
27
|
+
<td align="center">
|
|
28
|
+
<code>13.0</code>
|
|
29
|
+
</td>
|
|
30
|
+
</tr>
|
|
31
|
+
<tr width="600px">
|
|
32
|
+
<td align="left">Minimum Android SDK Version</td>
|
|
33
|
+
<td align="center">
|
|
34
|
+
<code>23</code>
|
|
35
|
+
</td>
|
|
36
|
+
</tr>
|
|
37
|
+
</tbody>
|
|
38
|
+
</table>
|
|
39
|
+
|
|
40
|
+
 
|
|
41
|
+
|
|
42
|
+
# Installation
|
|
43
|
+
|
|
44
|
+
## Using `npm`
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
npm install @trycourier/courier-react-native
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Using `yarn`
|
|
51
|
+
|
|
52
|
+
```sh
|
|
53
|
+
yarn add @trycourier/courier-react-native
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
 
|
|
57
|
+
|
|
58
|
+
## iOS
|
|
59
|
+
|
|
60
|
+
### 1. Support iOS 13.0+ in your Project
|
|
61
|
+
|
|
62
|
+
<img width="737" alt="Screenshot 2023-09-26 at 2 16 51 PM" src="https://github.com/trycourier/courier-react-native/assets/6370613/6bf98576-9b26-4b5e-8add-7289531e6431">
|
|
63
|
+
|
|
64
|
+
### 2. Support iOS 13+ in your Podfile
|
|
65
|
+
|
|
66
|
+
```sh
|
|
67
|
+
# Resolve react_native_pods.rb with node to allow for hoisting
|
|
68
|
+
require Pod::Executable.execute_command('node', ['-p'..
|
|
69
|
+
|
|
70
|
+
# Courier React Native requires iOS 13+
|
|
71
|
+
platform :ios, '13.0' // Add this line
|
|
72
|
+
prepare_react_native_project!
|
|
73
|
+
|
|
74
|
+
..
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### 3. Install the Cocoapods
|
|
78
|
+
|
|
79
|
+
From the root of your React Native project run
|
|
6
80
|
|
|
7
81
|
```sh
|
|
8
|
-
|
|
82
|
+
cd ios && pod install
|
|
9
83
|
```
|
|
10
84
|
|
|
11
|
-
|
|
85
|
+
 
|
|
86
|
+
|
|
87
|
+
## Android
|
|
88
|
+
|
|
89
|
+
### 1. Add the Jitpack repository
|
|
90
|
+
|
|
91
|
+
In your `android/build.gradle` make sure your build and repository values are as follows
|
|
92
|
+
|
|
93
|
+
```gradle
|
|
94
|
+
buildscript {
|
|
12
95
|
|
|
13
|
-
|
|
14
|
-
import { CourierReactNativeView } from "courier-react-native";
|
|
96
|
+
ext {
|
|
15
97
|
|
|
16
|
-
//
|
|
98
|
+
// Double check these values
|
|
99
|
+
buildToolsVersion = "32.0.0"
|
|
100
|
+
minSdkVersion = 23
|
|
101
|
+
compileSdkVersion = 32
|
|
102
|
+
targetSdkVersion = 32
|
|
103
|
+
..
|
|
104
|
+
}
|
|
17
105
|
|
|
18
|
-
|
|
106
|
+
repositories {
|
|
107
|
+
google()
|
|
108
|
+
mavenCentral()
|
|
109
|
+
maven { url 'https://www.jitpack.io' } // THIS LINE
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
..
|
|
113
|
+
|
|
114
|
+
}
|
|
19
115
|
```
|
|
20
116
|
|
|
21
|
-
|
|
117
|
+
### 2. Run Gradle Sync
|
|
118
|
+
|
|
119
|
+
 
|
|
120
|
+
|
|
121
|
+
# Getting Started
|
|
122
|
+
|
|
123
|
+
These are all the available features of the SDK.
|
|
124
|
+
|
|
125
|
+
<table>
|
|
126
|
+
<thead>
|
|
127
|
+
<tr>
|
|
128
|
+
<th width="25px"></th>
|
|
129
|
+
<th width="250px" align="left">Feature</th>
|
|
130
|
+
<th width="725px" align="left">Description</th>
|
|
131
|
+
</tr>
|
|
132
|
+
</thead>
|
|
133
|
+
<tbody>
|
|
134
|
+
<tr width="600px">
|
|
135
|
+
<td align="center">
|
|
136
|
+
1
|
|
137
|
+
</td>
|
|
138
|
+
<td align="left">
|
|
139
|
+
<a href="https://github.com/trycourier/courier-react-native/blob/feature/courier-inbox/Docs/Authentication.md">
|
|
140
|
+
<code>Authentication</code>
|
|
141
|
+
</a>
|
|
142
|
+
</td>
|
|
143
|
+
<td align="left">
|
|
144
|
+
Manages user credentials between app sessions. Required if you would like to use <a href="https://github.com/trycourier/courier-react-native/blob/feature/courier-inbox/Docs/Inbox.md"><code>Courier Inbox</code></a> and <a href="https://github.com/trycourier/courier-react-native/blob/feature/courier-inbox/Docs/PushNotifications.md"><code>Push Notifications</code></a>.
|
|
145
|
+
</td>
|
|
146
|
+
</tr>
|
|
147
|
+
<tr width="600px">
|
|
148
|
+
<td align="center">
|
|
149
|
+
2
|
|
150
|
+
</td>
|
|
151
|
+
<td align="left">
|
|
152
|
+
<a href="https://github.com/trycourier/courier-react-native/blob/feature/courier-inbox/Docs/Inbox.md">
|
|
153
|
+
<code>Courier Inbox</code>
|
|
154
|
+
</a>
|
|
155
|
+
</td>
|
|
156
|
+
<td align="left">
|
|
157
|
+
An in-app notification center you can use to notify your users. Comes with a prebuilt UI and also supports fully custom UIs.
|
|
158
|
+
</td>
|
|
159
|
+
</tr>
|
|
160
|
+
<tr width="600px">
|
|
161
|
+
<td align="center">
|
|
162
|
+
3
|
|
163
|
+
</td>
|
|
164
|
+
<td align="left">
|
|
165
|
+
<a href="https://github.com/trycourier/courier-react-native/blob/feature/courier-inbox/Docs/PushNotifications.md">
|
|
166
|
+
<code>Push Notifications</code>
|
|
167
|
+
</a>
|
|
168
|
+
</td>
|
|
169
|
+
<td align="left">
|
|
170
|
+
Automatically manages push notification device tokens and gives convenient functions for handling push notification receiving and clicking.
|
|
171
|
+
</td>
|
|
172
|
+
</tr>
|
|
173
|
+
</tbody>
|
|
174
|
+
</table>
|
|
175
|
+
|
|
176
|
+
 
|
|
177
|
+
|
|
178
|
+
# Example Projects
|
|
179
|
+
|
|
180
|
+
Starter projects using this SDK.
|
|
22
181
|
|
|
23
|
-
|
|
182
|
+
<table>
|
|
183
|
+
<thead>
|
|
184
|
+
<tr>
|
|
185
|
+
<th width="1000px" align="left">Project Link</th>
|
|
186
|
+
</tr>
|
|
187
|
+
</thead>
|
|
188
|
+
<tbody>
|
|
189
|
+
<tr width="1000px">
|
|
190
|
+
<td align="left">
|
|
191
|
+
<a href="https://github.com/trycourier/courier-react-native/tree/feature/courier-inbox/example">
|
|
192
|
+
<code>Example</code>
|
|
193
|
+
</a>
|
|
194
|
+
</td>
|
|
195
|
+
</tr>
|
|
196
|
+
</tbody>
|
|
197
|
+
</table>
|
|
24
198
|
|
|
25
|
-
|
|
199
|
+
 
|
|
26
200
|
|
|
27
|
-
|
|
201
|
+
# **Share feedback with Courier**
|
|
28
202
|
|
|
29
|
-
|
|
203
|
+
We are building the best SDKs for handling notifications! Have an idea or feedback about our SDKs? Here are some links to contact us:
|
|
30
204
|
|
|
31
|
-
|
|
205
|
+
- [Courier Feedback](https://feedback.courier.com/)
|
|
206
|
+
- [Courier React Native Issues](https://github.com/trycourier/courier-react-native/issues)
|
|
@@ -4,7 +4,9 @@ import android.content.Intent
|
|
|
4
4
|
import com.courier.android.Courier
|
|
5
5
|
import com.courier.android.models.*
|
|
6
6
|
import com.courier.android.modules.*
|
|
7
|
+
import com.courier.android.utils.isPushPermissionGranted
|
|
7
8
|
import com.courier.android.utils.pushNotification
|
|
9
|
+
import com.courier.android.utils.requestNotificationPermission
|
|
8
10
|
import com.courier.android.utils.trackPushNotificationClick
|
|
9
11
|
import com.facebook.react.ReactActivity
|
|
10
12
|
import com.facebook.react.bridge.*
|
|
@@ -70,28 +72,16 @@ class CourierReactNativeModule(reactContext: ReactApplicationContext) : ReactCon
|
|
|
70
72
|
)
|
|
71
73
|
}
|
|
72
74
|
|
|
73
|
-
@ReactMethod
|
|
75
|
+
@ReactMethod // TODO: Update in the future
|
|
74
76
|
fun requestNotificationPermission(promise: Promise) {
|
|
75
|
-
|
|
76
|
-
// reactActivity?.requestNotificationPermission { isGranted ->
|
|
77
|
-
//// val status = if (isGranted) NotificationPermissionStatus.AUTHORIZED else NotificationPermissionStatus.DENIED
|
|
78
|
-
//// promise.resolve(status.value)
|
|
79
|
-
// }
|
|
80
|
-
// } catch (e: Exception) {
|
|
81
|
-
// promise.reject(CourierEvents.COURIER_ERROR_TAG, e)
|
|
82
|
-
// }
|
|
77
|
+
reactActivity?.requestNotificationPermission()
|
|
83
78
|
}
|
|
84
79
|
|
|
85
|
-
@ReactMethod
|
|
80
|
+
@ReactMethod // TODO: Update in the future
|
|
86
81
|
fun getNotificationPermissionStatus(promise: Promise) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
// promise.resolve(status.value)
|
|
91
|
-
// }
|
|
92
|
-
// } catch (e: Exception) {
|
|
93
|
-
// promise.reject(COURIER_ERROR_TAG, e)
|
|
94
|
-
// }
|
|
82
|
+
val granted = reactActivity?.isPushPermissionGranted
|
|
83
|
+
val status = if (granted == true) "authorized" else "denied"
|
|
84
|
+
promise.resolve(status)
|
|
95
85
|
}
|
|
96
86
|
|
|
97
87
|
@ReactMethod
|
package/lib/commonjs/index.js
CHANGED
|
@@ -100,7 +100,6 @@ class Courier {
|
|
|
100
100
|
/**
|
|
101
101
|
* Tells native Courier SDKs to show or hide logs.
|
|
102
102
|
* Defaults to the React __DEV__ mode
|
|
103
|
-
* @example Courier.setIsDebugging(true)
|
|
104
103
|
*/
|
|
105
104
|
setIsDebugging(isDebugging) {
|
|
106
105
|
var _this$debugListener;
|
|
@@ -118,14 +117,16 @@ class Courier {
|
|
|
118
117
|
this._isDebugging = isDebugging;
|
|
119
118
|
return this._isDebugging;
|
|
120
119
|
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Returns the status of debugging
|
|
123
|
+
*/
|
|
121
124
|
get isDebugging() {
|
|
122
125
|
return this._isDebugging;
|
|
123
126
|
}
|
|
124
127
|
|
|
125
128
|
/**
|
|
126
|
-
*
|
|
127
|
-
* @param props
|
|
128
|
-
* @returns
|
|
129
|
+
* Sets the notification presentation options for iOS
|
|
129
130
|
*/
|
|
130
131
|
iOSForegroundPresentationOptions(props) {
|
|
131
132
|
// Only works on iOS
|
|
@@ -137,9 +138,7 @@ class Courier {
|
|
|
137
138
|
}
|
|
138
139
|
|
|
139
140
|
/**
|
|
140
|
-
*
|
|
141
|
-
* using Courier token management apis
|
|
142
|
-
* @example const apnsToken = await Courier.apnsToken
|
|
141
|
+
* Gets the apns token being used
|
|
143
142
|
*/
|
|
144
143
|
get apnsToken() {
|
|
145
144
|
if (_reactNative.Platform.OS !== 'ios') return undefined;
|
|
@@ -147,47 +146,45 @@ class Courier {
|
|
|
147
146
|
}
|
|
148
147
|
|
|
149
148
|
/**
|
|
150
|
-
*
|
|
151
|
-
* using Courier token management apis
|
|
152
|
-
* @example const fcmToken = await Courier.fcmToken
|
|
149
|
+
* Gets the fcm token being used
|
|
153
150
|
*/
|
|
154
151
|
get fcmToken() {
|
|
155
152
|
return CourierReactNativeModules.getFcmToken();
|
|
156
153
|
}
|
|
157
154
|
|
|
158
155
|
/**
|
|
159
|
-
* Sets the
|
|
160
|
-
* using Courier token management apis
|
|
161
|
-
* @example await setFcmToken('asdf...asdf')
|
|
156
|
+
* Sets the fcm token to be used by Courier
|
|
162
157
|
*/
|
|
163
158
|
setFcmToken(props) {
|
|
164
159
|
return CourierReactNativeModules.setFcmToken(props.token);
|
|
165
160
|
}
|
|
166
161
|
|
|
167
162
|
/**
|
|
168
|
-
*
|
|
169
|
-
*
|
|
163
|
+
* Returns the notification permission status
|
|
164
|
+
* Only supported on iOS
|
|
170
165
|
*/
|
|
171
166
|
getNotificationPermissionStatus() {
|
|
172
|
-
|
|
167
|
+
if (_reactNative.Platform.OS === 'ios') {
|
|
168
|
+
return CourierReactNativeModules.getNotificationPermissionStatus();
|
|
169
|
+
}
|
|
170
|
+
return Promise.reject('unknown');
|
|
173
171
|
}
|
|
174
172
|
|
|
175
173
|
/**
|
|
176
|
-
* Requests notification
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
* if the user has already been asked for permission.
|
|
180
|
-
* @example const permissionStatus = await Courier.requestNotificationPermission()
|
|
174
|
+
* Requests notification permissions
|
|
175
|
+
* This will show a dialog asking the user for permission
|
|
176
|
+
* Only supported on iOS
|
|
181
177
|
*/
|
|
182
178
|
requestNotificationPermission() {
|
|
183
|
-
|
|
179
|
+
if (_reactNative.Platform.OS === 'ios') {
|
|
180
|
+
return CourierReactNativeModules.requestNotificationPermission();
|
|
181
|
+
}
|
|
182
|
+
return Promise.reject('unknown');
|
|
184
183
|
}
|
|
185
184
|
|
|
186
185
|
/**
|
|
187
|
-
*
|
|
188
|
-
|
|
189
|
-
* @returns function that can be used to unsubscribe from registered listeners
|
|
190
|
-
*/
|
|
186
|
+
* Listens to push notification clicked and delivered messages
|
|
187
|
+
*/
|
|
191
188
|
addPushNotificationListener(props) {
|
|
192
189
|
const pushListener = new _CourierPushListener.CourierPushListener();
|
|
193
190
|
if (_reactNative.Platform.OS === 'android') {
|
|
@@ -240,46 +237,29 @@ class Courier {
|
|
|
240
237
|
}
|
|
241
238
|
|
|
242
239
|
/**
|
|
243
|
-
*
|
|
244
|
-
*
|
|
240
|
+
* Gets the user id that is currently being used
|
|
241
|
+
* This is the user id associated with the http requests the sdk does
|
|
245
242
|
*/
|
|
246
243
|
get userId() {
|
|
247
244
|
return CourierReactNativeModules.getUserId() ?? undefined;
|
|
248
245
|
}
|
|
249
246
|
|
|
250
247
|
/**
|
|
251
|
-
*
|
|
252
|
-
* using native level storage apis
|
|
253
|
-
*
|
|
254
|
-
* @example
|
|
255
|
-
* ```
|
|
256
|
-
*await Courier.signIn({
|
|
257
|
-
accessToken: YOUR_COURIER_GENERATED_JWT,
|
|
258
|
-
clientKey: YOUR_CLIENT_KEY,
|
|
259
|
-
userId: YOUR_USER_ID,
|
|
260
|
-
})
|
|
261
|
-
* ```
|
|
262
|
-
* Your access token should be generated using this endpoint
|
|
263
|
-
* that is requested from your backend
|
|
264
|
-
* https://www.courier.com/docs/reference/auth/issue-token/
|
|
248
|
+
* Registers the auth token, client key and user id the sdk should use for requests
|
|
265
249
|
*/
|
|
266
250
|
signIn(props) {
|
|
267
251
|
return CourierReactNativeModules.signIn(props.accessToken, props.clientKey ?? null, props.userId);
|
|
268
252
|
}
|
|
269
253
|
|
|
270
254
|
/**
|
|
271
|
-
*
|
|
272
|
-
* @param props
|
|
273
|
-
* @returns
|
|
255
|
+
* Removes the current user and credentials from the sdk
|
|
274
256
|
*/
|
|
275
257
|
signOut() {
|
|
276
258
|
return CourierReactNativeModules.signOut();
|
|
277
259
|
}
|
|
278
260
|
|
|
279
261
|
/**
|
|
280
|
-
*
|
|
281
|
-
* @param props
|
|
282
|
-
* @returns
|
|
262
|
+
* Listens to authentication changes for the current user
|
|
283
263
|
*/
|
|
284
264
|
addAuthenticationListener(props) {
|
|
285
265
|
const authListener = new _CourierAuthenticationListener.CourierAuthenticationListener();
|
|
@@ -291,45 +271,35 @@ class Courier {
|
|
|
291
271
|
}
|
|
292
272
|
|
|
293
273
|
/**
|
|
294
|
-
*
|
|
295
|
-
* @param props
|
|
296
|
-
* @returns
|
|
274
|
+
* Removes an authentication listener
|
|
297
275
|
*/
|
|
298
276
|
removeAuthenticationListener(props) {
|
|
299
277
|
return CourierReactNativeModules.removeAuthenticationListener(props.listenerId);
|
|
300
278
|
}
|
|
301
279
|
|
|
302
280
|
/**
|
|
303
|
-
*
|
|
304
|
-
* @param props
|
|
305
|
-
* @returns
|
|
281
|
+
* Reads an inbox message
|
|
306
282
|
*/
|
|
307
283
|
readMessage(props) {
|
|
308
284
|
return CourierReactNativeModules.readMessage(props.messageId);
|
|
309
285
|
}
|
|
310
286
|
|
|
311
287
|
/**
|
|
312
|
-
*
|
|
313
|
-
* @param props
|
|
314
|
-
* @returns
|
|
288
|
+
* Unreads an inbox message
|
|
315
289
|
*/
|
|
316
290
|
unreadMessage(props) {
|
|
317
291
|
return CourierReactNativeModules.unreadMessage(props.messageId);
|
|
318
292
|
}
|
|
319
293
|
|
|
320
294
|
/**
|
|
321
|
-
*
|
|
322
|
-
* @param props
|
|
323
|
-
* @returns
|
|
295
|
+
* Reads all the inbox messages
|
|
324
296
|
*/
|
|
325
297
|
readAllInboxMessages() {
|
|
326
298
|
return CourierReactNativeModules.readAllInboxMessages();
|
|
327
299
|
}
|
|
328
300
|
|
|
329
301
|
/**
|
|
330
|
-
*
|
|
331
|
-
* @param props
|
|
332
|
-
* @returns
|
|
302
|
+
* Listens to changes for the inbox itself
|
|
333
303
|
*/
|
|
334
304
|
addInboxListener(props) {
|
|
335
305
|
// Create the initial listeners
|
|
@@ -354,38 +324,32 @@ class Courier {
|
|
|
354
324
|
}
|
|
355
325
|
|
|
356
326
|
/**
|
|
357
|
-
*
|
|
358
|
-
* @param props
|
|
359
|
-
* @returns
|
|
327
|
+
* Removes an inbox listener
|
|
360
328
|
*/
|
|
361
329
|
removeInboxListener(props) {
|
|
362
330
|
return CourierReactNativeModules.removeInboxListener(props.listenerId);
|
|
363
331
|
}
|
|
364
332
|
|
|
365
333
|
/**
|
|
366
|
-
*
|
|
367
|
-
*
|
|
368
|
-
* @returns
|
|
334
|
+
* Refreshes the inbox
|
|
335
|
+
* Useful for pull to refresh
|
|
369
336
|
*/
|
|
370
337
|
async refreshInbox() {
|
|
371
338
|
return CourierReactNativeModules.refreshInbox();
|
|
372
339
|
}
|
|
373
340
|
|
|
374
341
|
/**
|
|
375
|
-
*
|
|
376
|
-
*
|
|
377
|
-
* @returns
|
|
342
|
+
* Fetches the next page of inbox messages
|
|
343
|
+
* Returns the fetched inbox messages
|
|
378
344
|
*/
|
|
379
345
|
async fetchNextPageOfMessages() {
|
|
380
346
|
return CourierReactNativeModules.fetchNextPageOfMessages();
|
|
381
347
|
}
|
|
382
348
|
|
|
383
349
|
/**
|
|
384
|
-
*
|
|
350
|
+
* Sets the pagination limit
|
|
385
351
|
* Min = 1
|
|
386
352
|
* Max = 100
|
|
387
|
-
* @param props
|
|
388
|
-
* @returns
|
|
389
353
|
*/
|
|
390
354
|
setInboxPaginationLimit(props) {
|
|
391
355
|
CourierReactNativeModules.setInboxPaginationLimit(props.limit);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_CourierInboxListener","_CourierPushListener","_CourierAuthenticationListener","_CourierInboxView","_CourierProvider","LINKING_ERROR","Platform","select","ios","default","CourierReactNativeModules","NativeModules","CourierReactNativeModule","Proxy","get","Error","CourierEventEmitter","NativeEventEmitter","Courier","PUSH_NOTIFICATION_CLICKED","PUSH_NOTIFICATION_DELIVERED","_isDebugging","constructor","setDefaults","shared","_sharedInstance","setIsDebugging","__DEV__","iOSForegroundPresentationOptions","options","isDebugging","_this$debugListener","debugListener","remove","addListener","event","console","log","setDebugMode","props","OS","normalizedParams","Array","from","Set","apnsToken","undefined","getApnsToken","fcmToken","getFcmToken","setFcmToken","token","getNotificationPermissionStatus","requestNotificationPermission","addPushNotificationListener","pushListener","CourierPushListener","onPushNotificationClicked","onNotificationClickedListener","DeviceEventEmitter","JSON","parse","error","onPushNotificationDelivered","onNotificationDeliveredListener","registerPushNotificationClickedOnKilledState","userId","getUserId","signIn","accessToken","clientKey","signOut","addAuthenticationListener","authListener","CourierAuthenticationListener","onUserChanged","listenerId","removeAuthenticationListener","readMessage","messageId","unreadMessage","readAllInboxMessages","addInboxListener","inboxListener","CourierInboxListener","onInitialLoad","onError","onMessagesChanged","messages","unreadMessageCount","totalMessageCount","canPaginate","removeInboxListener","refreshInbox","fetchNextPageOfMessages","setInboxPaginationLimit","limit","_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;AAIA,IAAAI,iBAAA,GAAAJ,OAAA;AACA,IAAAK,gBAAA,GAAAL,OAAA;AARA;;AAMA;;AAQA,MAAMM,aAAa,GAChB,2FAA0F,GAC3FC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,yBAAyB,GAAGC,0BAAa,CAACC,wBAAwB,GACpED,0BAAa,CAACC,wBAAwB,GACtC,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACV,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAEL,MAAMW,mBAAmB,GAAG,IAAIC,+BAAkB,CAChDN,0BAAa,CAACC,wBAChB,CAAC;AAED,MAAMM,OAAO,CAAC;EAEHC,yBAAyB,GAAG,yBAAyB;EACrDC,2BAA2B,GAAG,2BAA2B;EAG1DC,YAAY,GAAG,KAAK;EAGrBC,WAAWA,CAAA,EAAG;IAEnB;IACA;IACA;IACA,IAAI,CAACC,WAAW,CAAC,CAAC;EACpB;;EAEA;EACA,WAAkBC,MAAMA,CAAA,EAAY;IAElC,IAAI,CAAC,IAAI,CAACC,eAAe,EAAE;MACzB,IAAI,CAACA,eAAe,GAAG,IAAIP,OAAO,CAAC,CAAC;IACtC;IAEA,OAAO,IAAI,CAACO,eAAe;EAE7B;EAEA,MAAcF,WAAWA,CAAA,EAAG;IAC1B,IAAI,CAACG,cAAc,CAACC,OAAO,CAAC;IAC5B,IAAI,CAACC,gCAAgC,CAAC;MAAEC,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ;IAAE,CAAC,CAAC;EAC1F;;EAEA;AACF;AACA;AACA;
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_CourierInboxListener","_CourierPushListener","_CourierAuthenticationListener","_CourierInboxView","_CourierProvider","LINKING_ERROR","Platform","select","ios","default","CourierReactNativeModules","NativeModules","CourierReactNativeModule","Proxy","get","Error","CourierEventEmitter","NativeEventEmitter","Courier","PUSH_NOTIFICATION_CLICKED","PUSH_NOTIFICATION_DELIVERED","_isDebugging","constructor","setDefaults","shared","_sharedInstance","setIsDebugging","__DEV__","iOSForegroundPresentationOptions","options","isDebugging","_this$debugListener","debugListener","remove","addListener","event","console","log","setDebugMode","props","OS","normalizedParams","Array","from","Set","apnsToken","undefined","getApnsToken","fcmToken","getFcmToken","setFcmToken","token","getNotificationPermissionStatus","Promise","reject","requestNotificationPermission","addPushNotificationListener","pushListener","CourierPushListener","onPushNotificationClicked","onNotificationClickedListener","DeviceEventEmitter","JSON","parse","error","onPushNotificationDelivered","onNotificationDeliveredListener","registerPushNotificationClickedOnKilledState","userId","getUserId","signIn","accessToken","clientKey","signOut","addAuthenticationListener","authListener","CourierAuthenticationListener","onUserChanged","listenerId","removeAuthenticationListener","readMessage","messageId","unreadMessage","readAllInboxMessages","addInboxListener","inboxListener","CourierInboxListener","onInitialLoad","onError","onMessagesChanged","messages","unreadMessageCount","totalMessageCount","canPaginate","removeInboxListener","refreshInbox","fetchNextPageOfMessages","setInboxPaginationLimit","limit","_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;AAIA,IAAAI,iBAAA,GAAAJ,OAAA;AACA,IAAAK,gBAAA,GAAAL,OAAA;AARA;;AAMA;;AAQA,MAAMM,aAAa,GAChB,2FAA0F,GAC3FC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,yBAAyB,GAAGC,0BAAa,CAACC,wBAAwB,GACpED,0BAAa,CAACC,wBAAwB,GACtC,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACV,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAEL,MAAMW,mBAAmB,GAAG,IAAIC,+BAAkB,CAChDN,0BAAa,CAACC,wBAChB,CAAC;AAED,MAAMM,OAAO,CAAC;EAEHC,yBAAy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GpE,yBAAyB,CAAC0E,gBAAgB,CAAC,CAAC;IAEvE,OAAOC,aAAa;EAEtB;;EAEA;AACF;AACA;EACSS,mBAAmBA,CAACvD,KAA6B,EAAU;IAChE,OAAO7B,yBAAyB,CAACoF,mBAAmB,CAACvD,KAAK,CAACuC,UAAU,CAAC;EACxE;;EAEA;AACF;AACA;AACA;EACE,MAAaiB,YAAYA,CAAA,EAAkB;IACzC,OAAOrF,yBAAyB,CAACqF,YAAY,CAAC,CAAC;EACjD;;EAEA;AACF;AACA;AACA;EACG,MAAaC,uBAAuBA,CAAA,EAA4B;IAC/D,OAAOtF,yBAAyB,CAACsF,uBAAuB,CAAC,CAAC;EAC5D;;EAEA;AACF;AACA;AACA;AACA;EACUC,uBAAuBA,CAAC1D,KAAwB,EAAQ;IAC9D7B,yBAAyB,CAACuF,uBAAuB,CAAC1D,KAAK,CAAC2D,KAAK,CAAC;EAChE;AAEF;AAAC,IAAAC,QAAA,GAEcjF,OAAO;AAAAkF,OAAA,CAAA3F,OAAA,GAAA0F,QAAA"}
|
package/lib/module/index.js
CHANGED
|
@@ -48,7 +48,6 @@ class Courier {
|
|
|
48
48
|
/**
|
|
49
49
|
* Tells native Courier SDKs to show or hide logs.
|
|
50
50
|
* Defaults to the React __DEV__ mode
|
|
51
|
-
* @example Courier.setIsDebugging(true)
|
|
52
51
|
*/
|
|
53
52
|
setIsDebugging(isDebugging) {
|
|
54
53
|
var _this$debugListener;
|
|
@@ -66,14 +65,16 @@ class Courier {
|
|
|
66
65
|
this._isDebugging = isDebugging;
|
|
67
66
|
return this._isDebugging;
|
|
68
67
|
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Returns the status of debugging
|
|
71
|
+
*/
|
|
69
72
|
get isDebugging() {
|
|
70
73
|
return this._isDebugging;
|
|
71
74
|
}
|
|
72
75
|
|
|
73
76
|
/**
|
|
74
|
-
*
|
|
75
|
-
* @param props
|
|
76
|
-
* @returns
|
|
77
|
+
* Sets the notification presentation options for iOS
|
|
77
78
|
*/
|
|
78
79
|
iOSForegroundPresentationOptions(props) {
|
|
79
80
|
// Only works on iOS
|
|
@@ -85,9 +86,7 @@ class Courier {
|
|
|
85
86
|
}
|
|
86
87
|
|
|
87
88
|
/**
|
|
88
|
-
*
|
|
89
|
-
* using Courier token management apis
|
|
90
|
-
* @example const apnsToken = await Courier.apnsToken
|
|
89
|
+
* Gets the apns token being used
|
|
91
90
|
*/
|
|
92
91
|
get apnsToken() {
|
|
93
92
|
if (Platform.OS !== 'ios') return undefined;
|
|
@@ -95,47 +94,45 @@ class Courier {
|
|
|
95
94
|
}
|
|
96
95
|
|
|
97
96
|
/**
|
|
98
|
-
*
|
|
99
|
-
* using Courier token management apis
|
|
100
|
-
* @example const fcmToken = await Courier.fcmToken
|
|
97
|
+
* Gets the fcm token being used
|
|
101
98
|
*/
|
|
102
99
|
get fcmToken() {
|
|
103
100
|
return CourierReactNativeModules.getFcmToken();
|
|
104
101
|
}
|
|
105
102
|
|
|
106
103
|
/**
|
|
107
|
-
* Sets the
|
|
108
|
-
* using Courier token management apis
|
|
109
|
-
* @example await setFcmToken('asdf...asdf')
|
|
104
|
+
* Sets the fcm token to be used by Courier
|
|
110
105
|
*/
|
|
111
106
|
setFcmToken(props) {
|
|
112
107
|
return CourierReactNativeModules.setFcmToken(props.token);
|
|
113
108
|
}
|
|
114
109
|
|
|
115
110
|
/**
|
|
116
|
-
*
|
|
117
|
-
*
|
|
111
|
+
* Returns the notification permission status
|
|
112
|
+
* Only supported on iOS
|
|
118
113
|
*/
|
|
119
114
|
getNotificationPermissionStatus() {
|
|
120
|
-
|
|
115
|
+
if (Platform.OS === 'ios') {
|
|
116
|
+
return CourierReactNativeModules.getNotificationPermissionStatus();
|
|
117
|
+
}
|
|
118
|
+
return Promise.reject('unknown');
|
|
121
119
|
}
|
|
122
120
|
|
|
123
121
|
/**
|
|
124
|
-
* Requests notification
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
* if the user has already been asked for permission.
|
|
128
|
-
* @example const permissionStatus = await Courier.requestNotificationPermission()
|
|
122
|
+
* Requests notification permissions
|
|
123
|
+
* This will show a dialog asking the user for permission
|
|
124
|
+
* Only supported on iOS
|
|
129
125
|
*/
|
|
130
126
|
requestNotificationPermission() {
|
|
131
|
-
|
|
127
|
+
if (Platform.OS === 'ios') {
|
|
128
|
+
return CourierReactNativeModules.requestNotificationPermission();
|
|
129
|
+
}
|
|
130
|
+
return Promise.reject('unknown');
|
|
132
131
|
}
|
|
133
132
|
|
|
134
133
|
/**
|
|
135
|
-
*
|
|
136
|
-
|
|
137
|
-
* @returns function that can be used to unsubscribe from registered listeners
|
|
138
|
-
*/
|
|
134
|
+
* Listens to push notification clicked and delivered messages
|
|
135
|
+
*/
|
|
139
136
|
addPushNotificationListener(props) {
|
|
140
137
|
const pushListener = new CourierPushListener();
|
|
141
138
|
if (Platform.OS === 'android') {
|
|
@@ -188,46 +185,29 @@ class Courier {
|
|
|
188
185
|
}
|
|
189
186
|
|
|
190
187
|
/**
|
|
191
|
-
*
|
|
192
|
-
*
|
|
188
|
+
* Gets the user id that is currently being used
|
|
189
|
+
* This is the user id associated with the http requests the sdk does
|
|
193
190
|
*/
|
|
194
191
|
get userId() {
|
|
195
192
|
return CourierReactNativeModules.getUserId() ?? undefined;
|
|
196
193
|
}
|
|
197
194
|
|
|
198
195
|
/**
|
|
199
|
-
*
|
|
200
|
-
* using native level storage apis
|
|
201
|
-
*
|
|
202
|
-
* @example
|
|
203
|
-
* ```
|
|
204
|
-
*await Courier.signIn({
|
|
205
|
-
accessToken: YOUR_COURIER_GENERATED_JWT,
|
|
206
|
-
clientKey: YOUR_CLIENT_KEY,
|
|
207
|
-
userId: YOUR_USER_ID,
|
|
208
|
-
})
|
|
209
|
-
* ```
|
|
210
|
-
* Your access token should be generated using this endpoint
|
|
211
|
-
* that is requested from your backend
|
|
212
|
-
* https://www.courier.com/docs/reference/auth/issue-token/
|
|
196
|
+
* Registers the auth token, client key and user id the sdk should use for requests
|
|
213
197
|
*/
|
|
214
198
|
signIn(props) {
|
|
215
199
|
return CourierReactNativeModules.signIn(props.accessToken, props.clientKey ?? null, props.userId);
|
|
216
200
|
}
|
|
217
201
|
|
|
218
202
|
/**
|
|
219
|
-
*
|
|
220
|
-
* @param props
|
|
221
|
-
* @returns
|
|
203
|
+
* Removes the current user and credentials from the sdk
|
|
222
204
|
*/
|
|
223
205
|
signOut() {
|
|
224
206
|
return CourierReactNativeModules.signOut();
|
|
225
207
|
}
|
|
226
208
|
|
|
227
209
|
/**
|
|
228
|
-
*
|
|
229
|
-
* @param props
|
|
230
|
-
* @returns
|
|
210
|
+
* Listens to authentication changes for the current user
|
|
231
211
|
*/
|
|
232
212
|
addAuthenticationListener(props) {
|
|
233
213
|
const authListener = new CourierAuthenticationListener();
|
|
@@ -239,45 +219,35 @@ class Courier {
|
|
|
239
219
|
}
|
|
240
220
|
|
|
241
221
|
/**
|
|
242
|
-
*
|
|
243
|
-
* @param props
|
|
244
|
-
* @returns
|
|
222
|
+
* Removes an authentication listener
|
|
245
223
|
*/
|
|
246
224
|
removeAuthenticationListener(props) {
|
|
247
225
|
return CourierReactNativeModules.removeAuthenticationListener(props.listenerId);
|
|
248
226
|
}
|
|
249
227
|
|
|
250
228
|
/**
|
|
251
|
-
*
|
|
252
|
-
* @param props
|
|
253
|
-
* @returns
|
|
229
|
+
* Reads an inbox message
|
|
254
230
|
*/
|
|
255
231
|
readMessage(props) {
|
|
256
232
|
return CourierReactNativeModules.readMessage(props.messageId);
|
|
257
233
|
}
|
|
258
234
|
|
|
259
235
|
/**
|
|
260
|
-
*
|
|
261
|
-
* @param props
|
|
262
|
-
* @returns
|
|
236
|
+
* Unreads an inbox message
|
|
263
237
|
*/
|
|
264
238
|
unreadMessage(props) {
|
|
265
239
|
return CourierReactNativeModules.unreadMessage(props.messageId);
|
|
266
240
|
}
|
|
267
241
|
|
|
268
242
|
/**
|
|
269
|
-
*
|
|
270
|
-
* @param props
|
|
271
|
-
* @returns
|
|
243
|
+
* Reads all the inbox messages
|
|
272
244
|
*/
|
|
273
245
|
readAllInboxMessages() {
|
|
274
246
|
return CourierReactNativeModules.readAllInboxMessages();
|
|
275
247
|
}
|
|
276
248
|
|
|
277
249
|
/**
|
|
278
|
-
*
|
|
279
|
-
* @param props
|
|
280
|
-
* @returns
|
|
250
|
+
* Listens to changes for the inbox itself
|
|
281
251
|
*/
|
|
282
252
|
addInboxListener(props) {
|
|
283
253
|
// Create the initial listeners
|
|
@@ -302,38 +272,32 @@ class Courier {
|
|
|
302
272
|
}
|
|
303
273
|
|
|
304
274
|
/**
|
|
305
|
-
*
|
|
306
|
-
* @param props
|
|
307
|
-
* @returns
|
|
275
|
+
* Removes an inbox listener
|
|
308
276
|
*/
|
|
309
277
|
removeInboxListener(props) {
|
|
310
278
|
return CourierReactNativeModules.removeInboxListener(props.listenerId);
|
|
311
279
|
}
|
|
312
280
|
|
|
313
281
|
/**
|
|
314
|
-
*
|
|
315
|
-
*
|
|
316
|
-
* @returns
|
|
282
|
+
* Refreshes the inbox
|
|
283
|
+
* Useful for pull to refresh
|
|
317
284
|
*/
|
|
318
285
|
async refreshInbox() {
|
|
319
286
|
return CourierReactNativeModules.refreshInbox();
|
|
320
287
|
}
|
|
321
288
|
|
|
322
289
|
/**
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
* @returns
|
|
290
|
+
* Fetches the next page of inbox messages
|
|
291
|
+
* Returns the fetched inbox messages
|
|
326
292
|
*/
|
|
327
293
|
async fetchNextPageOfMessages() {
|
|
328
294
|
return CourierReactNativeModules.fetchNextPageOfMessages();
|
|
329
295
|
}
|
|
330
296
|
|
|
331
297
|
/**
|
|
332
|
-
*
|
|
298
|
+
* Sets the pagination limit
|
|
333
299
|
* Min = 1
|
|
334
300
|
* Max = 100
|
|
335
|
-
* @param props
|
|
336
|
-
* @returns
|
|
337
301
|
*/
|
|
338
302
|
setInboxPaginationLimit(props) {
|
|
339
303
|
CourierReactNativeModules.setInboxPaginationLimit(props.limit);
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeModules","NativeEventEmitter","Platform","DeviceEventEmitter","CourierInboxListener","CourierPushListener","CourierAuthenticationListener","CourierInboxView","CourierProvider","useCourierAuth","useCourierPush","useCourierInbox","LINKING_ERROR","select","ios","default","CourierReactNativeModules","CourierReactNativeModule","Proxy","get","Error","CourierEventEmitter","Courier","PUSH_NOTIFICATION_CLICKED","PUSH_NOTIFICATION_DELIVERED","_isDebugging","constructor","setDefaults","shared","_sharedInstance","setIsDebugging","__DEV__","iOSForegroundPresentationOptions","options","isDebugging","_this$debugListener","debugListener","remove","addListener","event","console","log","setDebugMode","props","OS","normalizedParams","Array","from","Set","apnsToken","undefined","getApnsToken","fcmToken","getFcmToken","setFcmToken","token","getNotificationPermissionStatus","requestNotificationPermission","addPushNotificationListener","pushListener","onPushNotificationClicked","onNotificationClickedListener","JSON","parse","error","onPushNotificationDelivered","onNotificationDeliveredListener","registerPushNotificationClickedOnKilledState","userId","getUserId","signIn","accessToken","clientKey","signOut","addAuthenticationListener","authListener","onUserChanged","listenerId","removeAuthenticationListener","readMessage","messageId","unreadMessage","readAllInboxMessages","addInboxListener","inboxListener","onInitialLoad","onError","onMessagesChanged","messages","unreadMessageCount","totalMessageCount","canPaginate","removeInboxListener","refreshInbox","fetchNextPageOfMessages","setInboxPaginationLimit","limit"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SACEA,aAAa,EACbC,kBAAkB,EAElBC,QAAQ,EACRC,kBAAkB,QACb,cAAc;;AAErB;AACA,SAASC,oBAAoB,QAAQ,+BAA+B;AACpE,SAASC,mBAAmB,QAAQ,8BAA8B;AAClE,SAASC,6BAA6B,QAAQ,wCAAwC;AAGtF;AACA,SAASC,gBAAgB,QAAQ,0BAA0B;AAC3D,SAASC,eAAe,EAAEC,cAAc,EAAEC,cAAc,EAAEC,eAAe,QAAQ,yBAAyB;AAC1G,SAASP,oBAAoB,QAAQ,+BAA+B;AACpE,SAASC,mBAAmB,QAAQ,8BAA8B;AAClE,SAASC,6BAA6B,QAAQ,wCAAwC;AAGtF,MAAMM,aAAa,GAChB,2FAA0F,GAC3FV,QAAQ,CAACW,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,yBAAyB,GAAGhB,aAAa,CAACiB,wBAAwB,GACpEjB,aAAa,CAACiB,wBAAwB,GACtC,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACR,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAEL,MAAMS,mBAAmB,GAAG,IAAIpB,kBAAkB,CAChDD,aAAa,CAACiB,wBAChB,CAAC;AAED,MAAMK,OAAO,CAAC;EAEHC,yBAAyB,GAAG,yBAAyB;EACrDC,2BAA2B,GAAG,2BAA2B;EAG1DC,YAAY,GAAG,KAAK;EAGrBC,WAAWA,CAAA,EAAG;IAEnB;IACA;IACA;IACA,IAAI,CAACC,WAAW,CAAC,CAAC;EACpB;;EAEA;EACA,WAAkBC,MAAMA,CAAA,EAAY;IAElC,IAAI,CAAC,IAAI,CAACC,eAAe,EAAE;MACzB,IAAI,CAACA,eAAe,GAAG,IAAIP,OAAO,CAAC,CAAC;IACtC;IAEA,OAAO,IAAI,CAACO,eAAe;EAE7B;EAEA,MAAcF,WAAWA,CAAA,EAAG;IAC1B,IAAI,CAACG,cAAc,CAACC,OAAO,CAAC;IAC5B,IAAI,CAACC,gCAAgC,CAAC;MAAEC,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ;IAAE,CAAC,CAAC;EAC1F;;EAEA;AACF;AACA;AACA;
|
|
1
|
+
{"version":3,"names":["NativeModules","NativeEventEmitter","Platform","DeviceEventEmitter","CourierInboxListener","CourierPushListener","CourierAuthenticationListener","CourierInboxView","CourierProvider","useCourierAuth","useCourierPush","useCourierInbox","LINKING_ERROR","select","ios","default","CourierReactNativeModules","CourierReactNativeModule","Proxy","get","Error","CourierEventEmitter","Courier","PUSH_NOTIFICATION_CLICKED","PUSH_NOTIFICATION_DELIVERED","_isDebugging","constructor","setDefaults","shared","_sharedInstance","setIsDebugging","__DEV__","iOSForegroundPresentationOptions","options","isDebugging","_this$debugListener","debugListener","remove","addListener","event","console","log","setDebugMode","props","OS","normalizedParams","Array","from","Set","apnsToken","undefined","getApnsToken","fcmToken","getFcmToken","setFcmToken","token","getNotificationPermissionStatus","Promise","reject","requestNotificationPermission","addPushNotificationListener","pushListener","onPushNotificationClicked","onNotificationClickedListener","JSON","parse","error","onPushNotificationDelivered","onNotificationDeliveredListener","registerPushNotificationClickedOnKilledState","userId","getUserId","signIn","accessToken","clientKey","signOut","addAuthenticationListener","authListener","onUserChanged","listenerId","removeAuthenticationListener","readMessage","messageId","unreadMessage","readAllInboxMessages","addInboxListener","inboxListener","onInitialLoad","onError","onMessagesChanged","messages","unreadMessageCount","totalMessageCount","canPaginate","removeInboxListener","refreshInbox","fetchNextPageOfMessages","setInboxPaginationLimit","limit"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SACEA,aAAa,EACbC,kBAAkB,EAElBC,QAAQ,EACRC,kBAAkB,QACb,cAAc;;AAErB;AACA,SAASC,oBAAoB,QAAQ,+BAA+B;AACpE,SAASC,mBAAmB,QAAQ,8BAA8B;AAClE,SAASC,6BAA6B,QAAQ,wCAAwC;AAGtF;AACA,SAASC,gBAAgB,QAAQ,0BAA0B;AAC3D,SAASC,eAAe,EAAEC,cAAc,EAAEC,cAAc,EAAEC,eAAe,QAAQ,yBAAyB;AAC1G,SAASP,oBAAoB,QAAQ,+BAA+B;AACpE,SAASC,mBAAmB,QAAQ,8BAA8B;AAClE,SAASC,6BAA6B,QAAQ,wCAAwC;AAGtF,MAAMM,aAAa,GAChB,2FAA0F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,WAAW,CAAC,YAAY,EAAEC,KAAK,IAAI;QAC7EI,KAAK,CAAC6C,OAAO,CAAEjD,KAAK,CAAC;MACvB,CAAC,CAAC;IAEJ;IAEA,IAAII,KAAK,CAAC8C,iBAAiB,EAAE;MAE3BH,aAAa,CAACG,iBAAiB,GAAGpE,mBAAmB,CAACiB,WAAW,CAAC,sBAAsB,EAAEC,KAAK,IAAI;QACjGI,KAAK,CAAC8C,iBAAiB,CACrBlD,KAAK,CAACmD,QAAQ,EACdnD,KAAK,CAACoD,kBAAkB,EACxBpD,KAAK,CAACqD,iBAAiB,EACvBrD,KAAK,CAACsD,WACR,CAAC;MACH,CAAC,CAAC;IAEJ;IAEAP,aAAa,CAACP,UAAU,GAAG/D,yBAAyB,CAACqE,gBAAgB,CAAC,CAAC;IAEvE,OAAOC,aAAa;EAEtB;;EAEA;AACF;AACA;EACSQ,mBAAmBA,CAACnD,KAA6B,EAAU;IAChE,OAAO3B,yBAAyB,CAAC8E,mBAAmB,CAACnD,KAAK,CAACoC,UAAU,CAAC;EACxE;;EAEA;AACF;AACA;AACA;EACE,MAAagB,YAAYA,CAAA,EAAkB;IACzC,OAAO/E,yBAAyB,CAAC+E,YAAY,CAAC,CAAC;EACjD;;EAEA;AACF;AACA;AACA;EACG,MAAaC,uBAAuBA,CAAA,EAA4B;IAC/D,OAAOhF,yBAAyB,CAACgF,uBAAuB,CAAC,CAAC;EAC5D;;EAEA;AACF;AACA;AACA;AACA;EACUC,uBAAuBA,CAACtD,KAAwB,EAAQ;IAC9D3B,yBAAyB,CAACiF,uBAAuB,CAACtD,KAAK,CAACuD,KAAK,CAAC;EAChE;AAEF;AAEA,eAAe5E,OAAO"}
|
|
@@ -20,80 +20,57 @@ declare class Courier {
|
|
|
20
20
|
/**
|
|
21
21
|
* Tells native Courier SDKs to show or hide logs.
|
|
22
22
|
* Defaults to the React __DEV__ mode
|
|
23
|
-
* @example Courier.setIsDebugging(true)
|
|
24
23
|
*/
|
|
25
24
|
setIsDebugging(isDebugging: boolean): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Returns the status of debugging
|
|
27
|
+
*/
|
|
26
28
|
get isDebugging(): boolean;
|
|
27
29
|
/**
|
|
28
|
-
*
|
|
29
|
-
* @param props
|
|
30
|
-
* @returns
|
|
30
|
+
* Sets the notification presentation options for iOS
|
|
31
31
|
*/
|
|
32
32
|
iOSForegroundPresentationOptions(props: {
|
|
33
33
|
options: iOSForegroundPresentationOptions[];
|
|
34
34
|
}): string;
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
37
|
-
* using Courier token management apis
|
|
38
|
-
* @example const apnsToken = await Courier.apnsToken
|
|
36
|
+
* Gets the apns token being used
|
|
39
37
|
*/
|
|
40
38
|
get apnsToken(): string | undefined;
|
|
41
39
|
/**
|
|
42
|
-
*
|
|
43
|
-
* using Courier token management apis
|
|
44
|
-
* @example const fcmToken = await Courier.fcmToken
|
|
40
|
+
* Gets the fcm token being used
|
|
45
41
|
*/
|
|
46
42
|
get fcmToken(): Promise<string | undefined>;
|
|
47
43
|
/**
|
|
48
|
-
* Sets the
|
|
49
|
-
* using Courier token management apis
|
|
50
|
-
* @example await setFcmToken('asdf...asdf')
|
|
44
|
+
* Sets the fcm token to be used by Courier
|
|
51
45
|
*/
|
|
52
46
|
setFcmToken(props: {
|
|
53
47
|
token: string;
|
|
54
48
|
}): Promise<void>;
|
|
55
49
|
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
50
|
+
* Returns the notification permission status
|
|
51
|
+
* Only supported on iOS
|
|
58
52
|
*/
|
|
59
53
|
getNotificationPermissionStatus(): Promise<string>;
|
|
60
54
|
/**
|
|
61
|
-
* Requests notification
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
* if the user has already been asked for permission.
|
|
65
|
-
* @example const permissionStatus = await Courier.requestNotificationPermission()
|
|
55
|
+
* Requests notification permissions
|
|
56
|
+
* This will show a dialog asking the user for permission
|
|
57
|
+
* Only supported on iOS
|
|
66
58
|
*/
|
|
67
59
|
requestNotificationPermission(): Promise<string>;
|
|
68
60
|
/**
|
|
69
|
-
*
|
|
70
|
-
|
|
71
|
-
* @returns function that can be used to unsubscribe from registered listeners
|
|
72
|
-
*/
|
|
61
|
+
* Listens to push notification clicked and delivered messages
|
|
62
|
+
*/
|
|
73
63
|
addPushNotificationListener(props: {
|
|
74
64
|
onPushNotificationClicked?: (push: any) => void;
|
|
75
65
|
onPushNotificationDelivered?: (push: any) => void;
|
|
76
66
|
}): CourierPushListener;
|
|
77
67
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
68
|
+
* Gets the user id that is currently being used
|
|
69
|
+
* This is the user id associated with the http requests the sdk does
|
|
80
70
|
*/
|
|
81
71
|
get userId(): string | undefined;
|
|
82
72
|
/**
|
|
83
|
-
*
|
|
84
|
-
* using native level storage apis
|
|
85
|
-
*
|
|
86
|
-
* @example
|
|
87
|
-
* ```
|
|
88
|
-
*await Courier.signIn({
|
|
89
|
-
accessToken: YOUR_COURIER_GENERATED_JWT,
|
|
90
|
-
clientKey: YOUR_CLIENT_KEY,
|
|
91
|
-
userId: YOUR_USER_ID,
|
|
92
|
-
})
|
|
93
|
-
* ```
|
|
94
|
-
* Your access token should be generated using this endpoint
|
|
95
|
-
* that is requested from your backend
|
|
96
|
-
* https://www.courier.com/docs/reference/auth/issue-token/
|
|
73
|
+
* Registers the auth token, client key and user id the sdk should use for requests
|
|
97
74
|
*/
|
|
98
75
|
signIn(props: {
|
|
99
76
|
accessToken: string;
|
|
@@ -101,53 +78,39 @@ declare class Courier {
|
|
|
101
78
|
userId: string;
|
|
102
79
|
}): Promise<void>;
|
|
103
80
|
/**
|
|
104
|
-
*
|
|
105
|
-
* @param props
|
|
106
|
-
* @returns
|
|
81
|
+
* Removes the current user and credentials from the sdk
|
|
107
82
|
*/
|
|
108
83
|
signOut(): Promise<void>;
|
|
109
84
|
/**
|
|
110
|
-
*
|
|
111
|
-
* @param props
|
|
112
|
-
* @returns
|
|
85
|
+
* Listens to authentication changes for the current user
|
|
113
86
|
*/
|
|
114
87
|
addAuthenticationListener(props: {
|
|
115
88
|
onUserChanged: (userId?: string) => void;
|
|
116
89
|
}): CourierAuthenticationListener;
|
|
117
90
|
/**
|
|
118
|
-
*
|
|
119
|
-
* @param props
|
|
120
|
-
* @returns
|
|
91
|
+
* Removes an authentication listener
|
|
121
92
|
*/
|
|
122
93
|
removeAuthenticationListener(props: {
|
|
123
94
|
listenerId: string;
|
|
124
95
|
}): string;
|
|
125
96
|
/**
|
|
126
|
-
*
|
|
127
|
-
* @param props
|
|
128
|
-
* @returns
|
|
97
|
+
* Reads an inbox message
|
|
129
98
|
*/
|
|
130
99
|
readMessage(props: {
|
|
131
100
|
messageId: string;
|
|
132
101
|
}): string;
|
|
133
102
|
/**
|
|
134
|
-
*
|
|
135
|
-
* @param props
|
|
136
|
-
* @returns
|
|
103
|
+
* Unreads an inbox message
|
|
137
104
|
*/
|
|
138
105
|
unreadMessage(props: {
|
|
139
106
|
messageId: string;
|
|
140
107
|
}): string;
|
|
141
108
|
/**
|
|
142
|
-
*
|
|
143
|
-
* @param props
|
|
144
|
-
* @returns
|
|
109
|
+
* Reads all the inbox messages
|
|
145
110
|
*/
|
|
146
111
|
readAllInboxMessages(): Promise<void>;
|
|
147
112
|
/**
|
|
148
|
-
*
|
|
149
|
-
* @param props
|
|
150
|
-
* @returns
|
|
113
|
+
* Listens to changes for the inbox itself
|
|
151
114
|
*/
|
|
152
115
|
addInboxListener(props: {
|
|
153
116
|
onInitialLoad?: () => void;
|
|
@@ -155,31 +118,25 @@ declare class Courier {
|
|
|
155
118
|
onMessagesChanged?: (messages: InboxMessage[], unreadMessageCount: number, totalMessageCount: number, canPaginate: boolean) => void;
|
|
156
119
|
}): CourierInboxListener;
|
|
157
120
|
/**
|
|
158
|
-
*
|
|
159
|
-
* @param props
|
|
160
|
-
* @returns
|
|
121
|
+
* Removes an inbox listener
|
|
161
122
|
*/
|
|
162
123
|
removeInboxListener(props: {
|
|
163
124
|
listenerId: string;
|
|
164
125
|
}): string;
|
|
165
126
|
/**
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
* @returns
|
|
127
|
+
* Refreshes the inbox
|
|
128
|
+
* Useful for pull to refresh
|
|
169
129
|
*/
|
|
170
130
|
refreshInbox(): Promise<void>;
|
|
171
131
|
/**
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
* @returns
|
|
132
|
+
* Fetches the next page of inbox messages
|
|
133
|
+
* Returns the fetched inbox messages
|
|
175
134
|
*/
|
|
176
135
|
fetchNextPageOfMessages(): Promise<InboxMessage[]>;
|
|
177
136
|
/**
|
|
178
|
-
*
|
|
137
|
+
* Sets the pagination limit
|
|
179
138
|
* Min = 1
|
|
180
139
|
* Max = 100
|
|
181
|
-
* @param props
|
|
182
|
-
* @returns
|
|
183
140
|
*/
|
|
184
141
|
setInboxPaginationLimit(props: {
|
|
185
142
|
limit: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AACvF,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAGrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC3G,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AACvF,MAAM,MAAM,gCAAgC,GAAG,OAAO,GAAG,OAAO,GAAG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AAE,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM;IAI1E;;OAEG;IACI,WAAW,CAAC,KAAK,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM;IAIxD;;OAEG;IACI,aAAa,CAAC,KAAK,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM;IAI1D;;OAEG;IACI,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5C;;OAEG;IACI,gBAAgB,CAAC,KAAK,EAAE;QAAE,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;QAAC,iBAAiB,CAAC,EAAE,CAAC,QAAQ,EAAE,YAAY,EAAE,EAAE,kBAAkB,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,KAAK,IAAI,CAAA;KAAE,GAAG,oBAAoB;IAwC5P;;OAEG;IACI,mBAAmB,CAAC,KAAK,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM;IAIjE;;;OAGG;IACU,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAI1C;;;OAGG;IACW,uBAAuB,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;IAIhE;;;;OAIG;IACK,uBAAuB,CAAC,KAAK,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;CAIhE;AAED,eAAe,OAAO,CAAC"}
|
package/package.json
CHANGED
package/src/index.tsx
CHANGED
|
@@ -77,7 +77,6 @@ class Courier {
|
|
|
77
77
|
/**
|
|
78
78
|
* Tells native Courier SDKs to show or hide logs.
|
|
79
79
|
* Defaults to the React __DEV__ mode
|
|
80
|
-
* @example Courier.setIsDebugging(true)
|
|
81
80
|
*/
|
|
82
81
|
public setIsDebugging(isDebugging: boolean): boolean {
|
|
83
82
|
|
|
@@ -100,14 +99,15 @@ class Courier {
|
|
|
100
99
|
|
|
101
100
|
}
|
|
102
101
|
|
|
102
|
+
/**
|
|
103
|
+
* Returns the status of debugging
|
|
104
|
+
*/
|
|
103
105
|
get isDebugging(): boolean {
|
|
104
106
|
return this._isDebugging;
|
|
105
107
|
}
|
|
106
108
|
|
|
107
109
|
/**
|
|
108
|
-
*
|
|
109
|
-
* @param props
|
|
110
|
-
* @returns
|
|
110
|
+
* Sets the notification presentation options for iOS
|
|
111
111
|
*/
|
|
112
112
|
public iOSForegroundPresentationOptions(props: { options: iOSForegroundPresentationOptions[] }): string {
|
|
113
113
|
|
|
@@ -122,9 +122,7 @@ class Courier {
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
/**
|
|
125
|
-
*
|
|
126
|
-
* using Courier token management apis
|
|
127
|
-
* @example const apnsToken = await Courier.apnsToken
|
|
125
|
+
* Gets the apns token being used
|
|
128
126
|
*/
|
|
129
127
|
get apnsToken(): string | undefined {
|
|
130
128
|
if (Platform.OS !== 'ios') return undefined;
|
|
@@ -132,47 +130,51 @@ class Courier {
|
|
|
132
130
|
}
|
|
133
131
|
|
|
134
132
|
/**
|
|
135
|
-
*
|
|
136
|
-
* using Courier token management apis
|
|
137
|
-
* @example const fcmToken = await Courier.fcmToken
|
|
133
|
+
* Gets the fcm token being used
|
|
138
134
|
*/
|
|
139
135
|
get fcmToken(): Promise<string | undefined> {
|
|
140
136
|
return CourierReactNativeModules.getFcmToken();
|
|
141
137
|
}
|
|
142
138
|
|
|
143
139
|
/**
|
|
144
|
-
* Sets the
|
|
145
|
-
* using Courier token management apis
|
|
146
|
-
* @example await setFcmToken('asdf...asdf')
|
|
140
|
+
* Sets the fcm token to be used by Courier
|
|
147
141
|
*/
|
|
148
142
|
public setFcmToken(props: { token: string }): Promise<void> {
|
|
149
143
|
return CourierReactNativeModules.setFcmToken(props.token);
|
|
150
144
|
}
|
|
151
145
|
|
|
152
146
|
/**
|
|
153
|
-
*
|
|
154
|
-
*
|
|
147
|
+
* Returns the notification permission status
|
|
148
|
+
* Only supported on iOS
|
|
155
149
|
*/
|
|
156
150
|
public getNotificationPermissionStatus(): Promise<string> {
|
|
157
|
-
|
|
151
|
+
|
|
152
|
+
if (Platform.OS === 'ios') {
|
|
153
|
+
return CourierReactNativeModules.getNotificationPermissionStatus();
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return Promise.reject('unknown')
|
|
157
|
+
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
/**
|
|
161
|
-
* Requests notification
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
* if the user has already been asked for permission.
|
|
165
|
-
* @example const permissionStatus = await Courier.requestNotificationPermission()
|
|
161
|
+
* Requests notification permissions
|
|
162
|
+
* This will show a dialog asking the user for permission
|
|
163
|
+
* Only supported on iOS
|
|
166
164
|
*/
|
|
167
165
|
public requestNotificationPermission(): Promise<string> {
|
|
168
|
-
|
|
166
|
+
|
|
167
|
+
if (Platform.OS === 'ios') {
|
|
168
|
+
return CourierReactNativeModules.requestNotificationPermission();
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return Promise.reject('unknown')
|
|
172
|
+
|
|
169
173
|
}
|
|
170
174
|
|
|
171
175
|
/**
|
|
172
|
-
*
|
|
173
|
-
|
|
174
|
-
* @returns function that can be used to unsubscribe from registered listeners
|
|
175
|
-
*/
|
|
176
|
+
* Listens to push notification clicked and delivered messages
|
|
177
|
+
*/
|
|
176
178
|
public addPushNotificationListener(props: { onPushNotificationClicked?: (push: any) => void, onPushNotificationDelivered?: (push: any) => void }): CourierPushListener {
|
|
177
179
|
|
|
178
180
|
const pushListener = new CourierPushListener();
|
|
@@ -236,46 +238,29 @@ class Courier {
|
|
|
236
238
|
}
|
|
237
239
|
|
|
238
240
|
/**
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
+
* Gets the user id that is currently being used
|
|
242
|
+
* This is the user id associated with the http requests the sdk does
|
|
241
243
|
*/
|
|
242
244
|
get userId(): string | undefined {
|
|
243
245
|
return CourierReactNativeModules.getUserId() ?? undefined
|
|
244
246
|
}
|
|
245
247
|
|
|
246
248
|
/**
|
|
247
|
-
*
|
|
248
|
-
* using native level storage apis
|
|
249
|
-
*
|
|
250
|
-
* @example
|
|
251
|
-
* ```
|
|
252
|
-
*await Courier.signIn({
|
|
253
|
-
accessToken: YOUR_COURIER_GENERATED_JWT,
|
|
254
|
-
clientKey: YOUR_CLIENT_KEY,
|
|
255
|
-
userId: YOUR_USER_ID,
|
|
256
|
-
})
|
|
257
|
-
* ```
|
|
258
|
-
* Your access token should be generated using this endpoint
|
|
259
|
-
* that is requested from your backend
|
|
260
|
-
* https://www.courier.com/docs/reference/auth/issue-token/
|
|
249
|
+
* Registers the auth token, client key and user id the sdk should use for requests
|
|
261
250
|
*/
|
|
262
251
|
public signIn(props: { accessToken: string, clientKey?: string, userId: string }): Promise<void> {
|
|
263
252
|
return CourierReactNativeModules.signIn(props.accessToken, props.clientKey ?? null, props.userId);
|
|
264
253
|
}
|
|
265
254
|
|
|
266
255
|
/**
|
|
267
|
-
*
|
|
268
|
-
* @param props
|
|
269
|
-
* @returns
|
|
256
|
+
* Removes the current user and credentials from the sdk
|
|
270
257
|
*/
|
|
271
258
|
public signOut(): Promise<void> {
|
|
272
259
|
return CourierReactNativeModules.signOut();
|
|
273
260
|
}
|
|
274
261
|
|
|
275
262
|
/**
|
|
276
|
-
*
|
|
277
|
-
* @param props
|
|
278
|
-
* @returns
|
|
263
|
+
* Listens to authentication changes for the current user
|
|
279
264
|
*/
|
|
280
265
|
public addAuthenticationListener(props: { onUserChanged: (userId?: string) => void }): CourierAuthenticationListener {
|
|
281
266
|
|
|
@@ -292,45 +277,35 @@ class Courier {
|
|
|
292
277
|
}
|
|
293
278
|
|
|
294
279
|
/**
|
|
295
|
-
*
|
|
296
|
-
* @param props
|
|
297
|
-
* @returns
|
|
280
|
+
* Removes an authentication listener
|
|
298
281
|
*/
|
|
299
282
|
public removeAuthenticationListener(props: { listenerId: string }): string {
|
|
300
283
|
return CourierReactNativeModules.removeAuthenticationListener(props.listenerId);
|
|
301
284
|
}
|
|
302
285
|
|
|
303
286
|
/**
|
|
304
|
-
*
|
|
305
|
-
* @param props
|
|
306
|
-
* @returns
|
|
287
|
+
* Reads an inbox message
|
|
307
288
|
*/
|
|
308
289
|
public readMessage(props: { messageId: string }): string {
|
|
309
290
|
return CourierReactNativeModules.readMessage(props.messageId);
|
|
310
291
|
}
|
|
311
292
|
|
|
312
293
|
/**
|
|
313
|
-
*
|
|
314
|
-
* @param props
|
|
315
|
-
* @returns
|
|
294
|
+
* Unreads an inbox message
|
|
316
295
|
*/
|
|
317
296
|
public unreadMessage(props: { messageId: string }): string {
|
|
318
297
|
return CourierReactNativeModules.unreadMessage(props.messageId);
|
|
319
298
|
}
|
|
320
299
|
|
|
321
300
|
/**
|
|
322
|
-
*
|
|
323
|
-
* @param props
|
|
324
|
-
* @returns
|
|
301
|
+
* Reads all the inbox messages
|
|
325
302
|
*/
|
|
326
303
|
public readAllInboxMessages(): Promise<void> {
|
|
327
304
|
return CourierReactNativeModules.readAllInboxMessages();
|
|
328
305
|
}
|
|
329
306
|
|
|
330
307
|
/**
|
|
331
|
-
*
|
|
332
|
-
* @param props
|
|
333
|
-
* @returns
|
|
308
|
+
* Listens to changes for the inbox itself
|
|
334
309
|
*/
|
|
335
310
|
public addInboxListener(props: { onInitialLoad?: () => void, onError?: (error: string) => void, onMessagesChanged?: (messages: InboxMessage[], unreadMessageCount: number, totalMessageCount: number, canPaginate: boolean) => void }): CourierInboxListener {
|
|
336
311
|
|
|
@@ -373,38 +348,32 @@ class Courier {
|
|
|
373
348
|
}
|
|
374
349
|
|
|
375
350
|
/**
|
|
376
|
-
*
|
|
377
|
-
* @param props
|
|
378
|
-
* @returns
|
|
351
|
+
* Removes an inbox listener
|
|
379
352
|
*/
|
|
380
353
|
public removeInboxListener(props: { listenerId: string }): string {
|
|
381
354
|
return CourierReactNativeModules.removeInboxListener(props.listenerId);
|
|
382
355
|
}
|
|
383
356
|
|
|
384
357
|
/**
|
|
385
|
-
*
|
|
386
|
-
*
|
|
387
|
-
* @returns
|
|
358
|
+
* Refreshes the inbox
|
|
359
|
+
* Useful for pull to refresh
|
|
388
360
|
*/
|
|
389
361
|
public async refreshInbox(): Promise<void> {
|
|
390
362
|
return CourierReactNativeModules.refreshInbox();
|
|
391
363
|
}
|
|
392
364
|
|
|
393
365
|
/**
|
|
394
|
-
*
|
|
395
|
-
*
|
|
396
|
-
* @returns
|
|
366
|
+
* Fetches the next page of inbox messages
|
|
367
|
+
* Returns the fetched inbox messages
|
|
397
368
|
*/
|
|
398
369
|
public async fetchNextPageOfMessages(): Promise<InboxMessage[]> {
|
|
399
370
|
return CourierReactNativeModules.fetchNextPageOfMessages();
|
|
400
371
|
}
|
|
401
372
|
|
|
402
373
|
/**
|
|
403
|
-
*
|
|
374
|
+
* Sets the pagination limit
|
|
404
375
|
* Min = 1
|
|
405
376
|
* Max = 100
|
|
406
|
-
* @param props
|
|
407
|
-
* @returns
|
|
408
377
|
*/
|
|
409
378
|
public setInboxPaginationLimit(props: { limit: number }): void {
|
|
410
379
|
CourierReactNativeModules.setInboxPaginationLimit(props.limit);
|