@trycourier/courier-react-native 2.0.0-beta0 → 2.0.0-beta2
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/ios/CourierReactNative-Bridging-Header.h +1 -0
- package/ios/CourierReactNative.xcodeproj/project.pbxproj +5 -3
- package/ios/CourierReactNative.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/CourierReactNative.xcodeproj/project.xcworkspace/xcuserdata/mike.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/CourierReactNative.xcodeproj/xcuserdata/mike.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/ios/CourierReactNativeDelegate.h +18 -0
- package/ios/CourierReactNativeDelegate.m +125 -0
- package/ios/CourierReactNativeModule.m +18 -0
- package/ios/CourierReactNativeModule.swift +39 -0
- package/ios/CourierReactNativeViewManager.swift +10 -1
- package/lib/commonjs/index.js +61 -19
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/CourierInboxListener.js +2 -2
- package/lib/commonjs/models/CourierInboxListener.js.map +1 -1
- package/lib/commonjs/views/CourierInboxView.js +1 -1
- package/lib/commonjs/views/CourierInboxView.js.map +1 -1
- package/lib/module/index.js +61 -19
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/CourierInboxListener.js +2 -2
- package/lib/module/models/CourierInboxListener.js.map +1 -1
- package/lib/module/views/CourierInboxView.js +1 -1
- package/lib/module/views/CourierInboxView.js.map +1 -1
- package/lib/typescript/index.d.ts +34 -8
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/models/CourierInboxListener.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/index.tsx +70 -24
- package/src/models/CourierInboxListener.tsx +3 -3
- package/src/views/CourierInboxView.tsx +1 -1
|
@@ -7,8 +7,7 @@
|
|
|
7
7
|
objects = {
|
|
8
8
|
|
|
9
9
|
/* Begin PBXBuildFile section */
|
|
10
|
-
|
|
11
|
-
F4FF95D7245B92E800C19C63 /* CourierReactNative.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4FF95D6245B92E800C19C63 /* CourierReactNative.swift */; };
|
|
10
|
+
F4FF95D7245B92E800C19C63 /* CourierReactNative.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4FF95D6245B92E800C19C63 /* CourierReactNative.swift */; };
|
|
12
11
|
/* End PBXBuildFile section */
|
|
13
12
|
|
|
14
13
|
/* Begin PBXCopyFilesBuildPhase section */
|
|
@@ -25,6 +24,8 @@
|
|
|
25
24
|
|
|
26
25
|
/* Begin PBXFileReference section */
|
|
27
26
|
134814201AA4EA6300B7C361 /* libCourierReactNative.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libCourierReactNative.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
|
27
|
+
27960AF02A9E722F0076CE04 /* CourierReactNativeDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CourierReactNativeDelegate.h; sourceTree = "<group>"; };
|
|
28
|
+
27960AF12A9E722F0076CE04 /* CourierReactNativeDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CourierReactNativeDelegate.m; sourceTree = "<group>"; };
|
|
28
29
|
B3E7B5891CC2AC0600A0062D /* CourierReactNative.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CourierReactNative.mm; sourceTree = "<group>"; };
|
|
29
30
|
F4FF95D5245B92E700C19C63 /* CourierReactNative-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "CourierReactNative-Bridging-Header.h"; sourceTree = "<group>"; };
|
|
30
31
|
F4FF95D6245B92E800C19C63 /* CourierReactNative.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CourierReactNative.swift; sourceTree = "<group>"; };
|
|
@@ -52,6 +53,8 @@
|
|
|
52
53
|
58B511D21A9E6C8500147676 = {
|
|
53
54
|
isa = PBXGroup;
|
|
54
55
|
children = (
|
|
56
|
+
27960AF02A9E722F0076CE04 /* CourierReactNativeDelegate.h */,
|
|
57
|
+
27960AF12A9E722F0076CE04 /* CourierReactNativeDelegate.m */,
|
|
55
58
|
F4FF95D6245B92E800C19C63 /* CourierReactNative.swift */,
|
|
56
59
|
B3E7B5891CC2AC0600A0062D /* CourierReactNative.mm */,
|
|
57
60
|
F4FF95D5245B92E700C19C63 /* CourierReactNative-Bridging-Header.h */,
|
|
@@ -117,7 +120,6 @@
|
|
|
117
120
|
buildActionMask = 2147483647;
|
|
118
121
|
files = (
|
|
119
122
|
F4FF95D7245B92E800C19C63 /* CourierReactNative.swift in Sources */,
|
|
120
|
-
B3E7B58A1CC2AC0600A0062D /* CourierReactNative.mm in Sources */,
|
|
121
123
|
);
|
|
122
124
|
runOnlyForDeploymentPostprocessing = 0;
|
|
123
125
|
};
|
|
Binary file
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>SchemeUserState</key>
|
|
6
|
+
<dict>
|
|
7
|
+
<key>CourierReactNative.xcscheme_^#shared#^_</key>
|
|
8
|
+
<dict>
|
|
9
|
+
<key>orderHint</key>
|
|
10
|
+
<integer>0</integer>
|
|
11
|
+
</dict>
|
|
12
|
+
</dict>
|
|
13
|
+
</dict>
|
|
14
|
+
</plist>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//
|
|
2
|
+
// CourierReactNativeDelegate.h
|
|
3
|
+
// courier-react-native
|
|
4
|
+
//
|
|
5
|
+
// Created by Michael Miller on 8/29/23.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#import "RCTAppDelegate.h"
|
|
9
|
+
#import <UIKit/UIKit.h>
|
|
10
|
+
#import <UserNotifications/UserNotifications.h>
|
|
11
|
+
|
|
12
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
13
|
+
|
|
14
|
+
@interface CourierReactNativeDelegate : RCTAppDelegate<UNUserNotificationCenterDelegate>
|
|
15
|
+
|
|
16
|
+
@end
|
|
17
|
+
|
|
18
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
//
|
|
2
|
+
// CourierReactNativeDelegate.m
|
|
3
|
+
// courier-react-native
|
|
4
|
+
//
|
|
5
|
+
// Created by Michael Miller on 10/7/22.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
@import Courier_iOS;
|
|
9
|
+
#import "CourierReactNativeDelegate.h"
|
|
10
|
+
#pragma GCC diagnostic ignored "-Wprotocol"
|
|
11
|
+
#pragma clang diagnostic ignored "-Wprotocol"
|
|
12
|
+
|
|
13
|
+
@implementation CourierReactNativeDelegate
|
|
14
|
+
|
|
15
|
+
NSString *iosForegroundNotificationPresentationOptions = @"iosForegroundNotificationPresentationOptions";
|
|
16
|
+
NSUInteger notificationPresentationOptions = UNNotificationPresentationOptionNone;
|
|
17
|
+
|
|
18
|
+
- (id) init {
|
|
19
|
+
|
|
20
|
+
self = [super init];
|
|
21
|
+
|
|
22
|
+
if (self) {
|
|
23
|
+
|
|
24
|
+
// Register for remote notifications
|
|
25
|
+
UIApplication *app = [UIApplication sharedApplication];
|
|
26
|
+
[app registerForRemoteNotifications];
|
|
27
|
+
|
|
28
|
+
// Register notification center changes
|
|
29
|
+
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
|
|
30
|
+
center.delegate = self;
|
|
31
|
+
|
|
32
|
+
[[NSNotificationCenter defaultCenter]
|
|
33
|
+
addObserver:self
|
|
34
|
+
selector:@selector(notificationPresentationOptionsUpdate:)
|
|
35
|
+
name:iosForegroundNotificationPresentationOptions
|
|
36
|
+
object:nil
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return(self);
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
- (void) notificationPresentationOptionsUpdate:(NSNotification *) notification
|
|
46
|
+
{
|
|
47
|
+
if ([[notification name] isEqualToString:iosForegroundNotificationPresentationOptions])
|
|
48
|
+
{
|
|
49
|
+
NSDictionary *userInfo = notification.userInfo;
|
|
50
|
+
notificationPresentationOptions = ((NSNumber *) [userInfo objectForKey:@"options"]).unsignedIntegerValue;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler
|
|
55
|
+
{
|
|
56
|
+
|
|
57
|
+
UNNotificationContent *content = notification.request.content;
|
|
58
|
+
NSDictionary *message = content.userInfo;
|
|
59
|
+
|
|
60
|
+
[[Courier shared] trackNotificationWithMessage:message event:CourierPushEventDelivered completionHandler:^(NSError *error)
|
|
61
|
+
{
|
|
62
|
+
if (error != nil) {
|
|
63
|
+
[self log:error];
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
];
|
|
67
|
+
|
|
68
|
+
NSDictionary *pushNotification = [Courier formatPushNotificationWithContent:content];
|
|
69
|
+
[[NSNotificationCenter defaultCenter] postNotificationName:@"pushNotificationDelivered" object:nil userInfo:pushNotification];
|
|
70
|
+
|
|
71
|
+
completionHandler(notificationPresentationOptions);
|
|
72
|
+
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler
|
|
76
|
+
{
|
|
77
|
+
|
|
78
|
+
UNNotificationContent *content = response.notification.request.content;
|
|
79
|
+
NSDictionary *message = content.userInfo;
|
|
80
|
+
|
|
81
|
+
[[Courier shared] trackNotificationWithMessage:message event:CourierPushEventClicked completionHandler:^(NSError *error)
|
|
82
|
+
{
|
|
83
|
+
if (error != nil) {
|
|
84
|
+
[self log:error];
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
];
|
|
88
|
+
|
|
89
|
+
NSDictionary *pushNotification = [Courier formatPushNotificationWithContent:content];
|
|
90
|
+
[[NSNotificationCenter defaultCenter] postNotificationName:@"pushNotificationClicked" object:nil userInfo:pushNotification];
|
|
91
|
+
|
|
92
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
93
|
+
completionHandler();
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
|
|
99
|
+
{
|
|
100
|
+
[self log:error];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
|
|
104
|
+
{
|
|
105
|
+
|
|
106
|
+
[[Courier shared]
|
|
107
|
+
setAPNSToken:deviceToken
|
|
108
|
+
onSuccess:^()
|
|
109
|
+
{
|
|
110
|
+
// Empty
|
|
111
|
+
}
|
|
112
|
+
onFailure:^(NSError *error)
|
|
113
|
+
{
|
|
114
|
+
[self log:error];
|
|
115
|
+
}
|
|
116
|
+
];
|
|
117
|
+
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
- (void)log: (NSError*)error {
|
|
121
|
+
NSString *err = [NSString stringWithFormat:@"%@", error];
|
|
122
|
+
[Courier log:err];
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
@end
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
@interface RCT_EXTERN_MODULE(CourierReactNativeModule, NSObject)
|
|
4
4
|
|
|
5
|
+
RCT_EXTERN__BLOCKING_SYNCHRONOUS_METHOD(
|
|
6
|
+
setDebugMode: (BOOL*)isDebugging
|
|
7
|
+
)
|
|
8
|
+
|
|
5
9
|
RCT_EXTERN_METHOD(
|
|
6
10
|
signIn: (NSString*)accessToken
|
|
7
11
|
withClientKey: (NSString*)clientKey
|
|
@@ -45,4 +49,18 @@ RCT_EXTERN__BLOCKING_SYNCHRONOUS_METHOD(
|
|
|
45
49
|
removeInboxListener: (NSString*)listenerId
|
|
46
50
|
)
|
|
47
51
|
|
|
52
|
+
RCT_EXTERN_METHOD(
|
|
53
|
+
refreshInbox: (RCTPromiseResolveBlock)resolve
|
|
54
|
+
withRejecter: (RCTPromiseRejectBlock)reject
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
RCT_EXTERN_METHOD(
|
|
58
|
+
fetchNextPageOfMessages: (RCTPromiseResolveBlock)resolve
|
|
59
|
+
withRejecter: (RCTPromiseRejectBlock)reject
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
RCT_EXTERN__BLOCKING_SYNCHRONOUS_METHOD(
|
|
63
|
+
setInboxPaginationLimit: (nonnull NSNumber*)limit
|
|
64
|
+
)
|
|
65
|
+
|
|
48
66
|
@end
|
|
@@ -37,6 +37,12 @@ class CourierReactNativeModule: RCTEventEmitter {
|
|
|
37
37
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
@objc(setDebugMode:)
|
|
41
|
+
func setDebugMode(isDebugging: Bool) -> String {
|
|
42
|
+
Courier.shared.isDebugging = isDebugging
|
|
43
|
+
return String(describing: Courier.shared.isDebugging)
|
|
44
|
+
}
|
|
45
|
+
|
|
40
46
|
override func startObserving() {
|
|
41
47
|
|
|
42
48
|
hasListeners = true
|
|
@@ -302,16 +308,20 @@ class CourierReactNativeModule: RCTEventEmitter {
|
|
|
302
308
|
|
|
303
309
|
let listener = Courier.shared.addInboxListener(
|
|
304
310
|
onInitialLoad: { [weak self] in
|
|
311
|
+
|
|
305
312
|
self?.sendEvent(
|
|
306
313
|
withName: CourierReactNativeModule.InboxEvents.INITIAL_LOADING,
|
|
307
314
|
body: nil
|
|
308
315
|
)
|
|
316
|
+
|
|
309
317
|
},
|
|
310
318
|
onError: { [weak self] error in
|
|
319
|
+
|
|
311
320
|
self?.sendEvent(
|
|
312
321
|
withName: CourierReactNativeModule.InboxEvents.ERROR,
|
|
313
322
|
body: String(describing: error)
|
|
314
323
|
)
|
|
324
|
+
|
|
315
325
|
},
|
|
316
326
|
onMessagesChanged: { [weak self] messages, unreadMessageCount, totalMessageCount, canPaginate in
|
|
317
327
|
|
|
@@ -338,6 +348,15 @@ class CourierReactNativeModule: RCTEventEmitter {
|
|
|
338
348
|
|
|
339
349
|
}
|
|
340
350
|
|
|
351
|
+
@objc(refreshInbox: withRejecter:)
|
|
352
|
+
func refreshInbox(resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) -> Void {
|
|
353
|
+
|
|
354
|
+
Courier.shared.refreshInbox {
|
|
355
|
+
resolve(nil)
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
}
|
|
359
|
+
|
|
341
360
|
@objc(removeInboxListener:)
|
|
342
361
|
func removeInboxListener(listenerId: NSString) -> String {
|
|
343
362
|
|
|
@@ -353,6 +372,26 @@ class CourierReactNativeModule: RCTEventEmitter {
|
|
|
353
372
|
return id
|
|
354
373
|
|
|
355
374
|
}
|
|
375
|
+
|
|
376
|
+
@objc(fetchNextPageOfMessages: withRejecter:)
|
|
377
|
+
func fetchNextPageOfMessages(resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) -> Void {
|
|
378
|
+
|
|
379
|
+
Courier.shared.fetchNextPageOfMessages(
|
|
380
|
+
onSuccess: { messages in
|
|
381
|
+
resolve(messages.map { $0.toDictionary() })
|
|
382
|
+
},
|
|
383
|
+
onFailure: { error in
|
|
384
|
+
reject(String(describing: error), CourierReactNativeModule.COURIER_ERROR_TAG, nil)
|
|
385
|
+
}
|
|
386
|
+
)
|
|
387
|
+
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
@objc(setInboxPaginationLimit:)
|
|
391
|
+
func setInboxPaginationLimit(limit: NSNumber) -> String {
|
|
392
|
+
Courier.shared.inboxPaginationLimit = limit.intValue
|
|
393
|
+
return String(describing: limit.intValue)
|
|
394
|
+
}
|
|
356
395
|
|
|
357
396
|
override func supportedEvents() -> [String]! {
|
|
358
397
|
return [
|
|
@@ -45,7 +45,13 @@ class CourierReactNativeView : UIView {
|
|
|
45
45
|
|
|
46
46
|
private func refreshInbox() {
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
// Disable animations
|
|
49
|
+
UIView.setAnimationsEnabled(false)
|
|
50
|
+
|
|
51
|
+
// Remove all previous views
|
|
52
|
+
subviews.forEach {
|
|
53
|
+
$0.removeFromSuperview()
|
|
54
|
+
}
|
|
49
55
|
|
|
50
56
|
// Create the view
|
|
51
57
|
let courierInbox = CourierInbox(
|
|
@@ -86,6 +92,9 @@ class CourierReactNativeView : UIView {
|
|
|
86
92
|
courierInbox.trailingAnchor.constraint(equalTo: trailingAnchor),
|
|
87
93
|
])
|
|
88
94
|
|
|
95
|
+
// Enable animations
|
|
96
|
+
UIView.setAnimationsEnabled(true)
|
|
97
|
+
|
|
89
98
|
}
|
|
90
99
|
|
|
91
100
|
func dictionaryToTheme(dictionary: NSDictionary?) -> CourierInboxTheme? {
|
package/lib/commonjs/index.js
CHANGED
|
@@ -13,7 +13,7 @@ exports.default = void 0;
|
|
|
13
13
|
var _reactNative = require("react-native");
|
|
14
14
|
var _CourierInboxListener = require("./models/CourierInboxListener");
|
|
15
15
|
var _CourierInboxView = require("./views/CourierInboxView");
|
|
16
|
-
const LINKING_ERROR = `The package 'courier-react-native' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
|
|
16
|
+
const LINKING_ERROR = `The package '@trycourier/courier-react-native' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
|
|
17
17
|
ios: "- You have run 'pod install'\n",
|
|
18
18
|
default: ''
|
|
19
19
|
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
|
|
@@ -24,30 +24,41 @@ const CourierReactNativeModules = _reactNative.NativeModules.CourierReactNativeM
|
|
|
24
24
|
});
|
|
25
25
|
const CourierEventEmitter = new _reactNative.NativeEventEmitter(_reactNative.NativeModules.CourierReactNativeModule);
|
|
26
26
|
class Courier {
|
|
27
|
+
_isDebugging = false;
|
|
27
28
|
constructor() {
|
|
28
29
|
// Sets the initial SDK values
|
|
29
30
|
// Defaults to React Native level debugging
|
|
30
31
|
// and will show all foreground notification styles in iOS
|
|
31
32
|
this.setDefaults();
|
|
32
33
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
// }),
|
|
39
|
-
]);
|
|
40
|
-
} catch (error) {
|
|
41
|
-
console.log(error);
|
|
34
|
+
|
|
35
|
+
// Returns the public shared instance
|
|
36
|
+
static get shared() {
|
|
37
|
+
if (!this._sharedInstance) {
|
|
38
|
+
this._sharedInstance = new Courier();
|
|
42
39
|
}
|
|
40
|
+
return this._sharedInstance;
|
|
43
41
|
}
|
|
44
|
-
|
|
42
|
+
async setDefaults() {
|
|
43
|
+
this.setIsDebugging(__DEV__);
|
|
44
|
+
// try {
|
|
45
|
+
// await Promise.all([
|
|
46
|
+
// this.setIsDebugging(__DEV__),
|
|
47
|
+
// // this.iOSForegroundPresentationOptions({
|
|
48
|
+
// // options: ['sound', 'badge', 'list', 'banner'],
|
|
49
|
+
// // }),
|
|
50
|
+
// ]);
|
|
51
|
+
// } catch (error) {
|
|
52
|
+
// console.log(error);
|
|
53
|
+
// }
|
|
54
|
+
}
|
|
55
|
+
|
|
45
56
|
/**
|
|
46
57
|
* Tells native Courier SDKs to show or hide logs.
|
|
47
58
|
* Defaults to the React __DEV__ mode
|
|
48
59
|
* @example Courier.setIsDebugging(true)
|
|
49
60
|
*/
|
|
50
|
-
|
|
61
|
+
setIsDebugging(isDebugging) {
|
|
51
62
|
var _this$debugListener;
|
|
52
63
|
// Remove the existing listener if needed
|
|
53
64
|
(_this$debugListener = this.debugListener) === null || _this$debugListener === void 0 ? void 0 : _this$debugListener.remove();
|
|
@@ -59,7 +70,8 @@ class Courier {
|
|
|
59
70
|
console.log('\x1b[36m%s\x1b[0m', 'COURIER', event);
|
|
60
71
|
});
|
|
61
72
|
}
|
|
62
|
-
|
|
73
|
+
CourierReactNativeModules.setDebugMode(isDebugging);
|
|
74
|
+
this._isDebugging = isDebugging;
|
|
63
75
|
return this._isDebugging;
|
|
64
76
|
}
|
|
65
77
|
get isDebugging() {
|
|
@@ -136,24 +148,54 @@ class Courier {
|
|
|
136
148
|
}
|
|
137
149
|
if (props.onError) {
|
|
138
150
|
inboxListener.onError = CourierEventEmitter.addListener('inboxError', event => {
|
|
139
|
-
|
|
140
|
-
props.onError();
|
|
151
|
+
props.onError(event);
|
|
141
152
|
});
|
|
142
153
|
}
|
|
143
154
|
if (props.onMessagesChanged) {
|
|
144
155
|
inboxListener.onMessagesChanged = CourierEventEmitter.addListener('inboxMessagesChanged', event => {
|
|
145
|
-
|
|
146
|
-
console.log(event);
|
|
147
|
-
props.onMessagesChanged(event.messages);
|
|
156
|
+
props.onMessagesChanged(event.messages, event.unreadMessageCount, event.totalMessageCount, event.canPaginate);
|
|
148
157
|
});
|
|
149
158
|
}
|
|
150
159
|
inboxListener.listenerId = CourierReactNativeModules.addInboxListener(null);
|
|
151
160
|
return inboxListener;
|
|
152
161
|
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* TODO
|
|
165
|
+
* @param props
|
|
166
|
+
* @returns
|
|
167
|
+
*/
|
|
153
168
|
removeInboxListener(props) {
|
|
154
169
|
return CourierReactNativeModules.removeInboxListener(props.listenerId);
|
|
155
170
|
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* TODO
|
|
174
|
+
* @param props
|
|
175
|
+
* @returns
|
|
176
|
+
*/
|
|
177
|
+
async refreshInbox() {
|
|
178
|
+
return CourierReactNativeModules.refreshInbox();
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* TODO
|
|
183
|
+
* @param props
|
|
184
|
+
* @returns
|
|
185
|
+
*/
|
|
186
|
+
async fetchNextPageOfMessages() {
|
|
187
|
+
return CourierReactNativeModules.fetchNextPageOfMessages();
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* TODO
|
|
192
|
+
* @param props
|
|
193
|
+
* @returns
|
|
194
|
+
*/
|
|
195
|
+
setInboxPaginationLimit(props) {
|
|
196
|
+
CourierReactNativeModules.setInboxPaginationLimit(props.limit);
|
|
197
|
+
}
|
|
156
198
|
}
|
|
157
|
-
var _default =
|
|
199
|
+
var _default = Courier;
|
|
158
200
|
exports.default = _default;
|
|
159
201
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_CourierInboxListener","_CourierInboxView","LINKING_ERROR","Platform","select","ios","default","CourierReactNativeModules","NativeModules","CourierReactNativeModule","Proxy","get","Error","CourierEventEmitter","NativeEventEmitter","Courier","constructor","setDefaults","
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_CourierInboxListener","_CourierInboxView","LINKING_ERROR","Platform","select","ios","default","CourierReactNativeModules","NativeModules","CourierReactNativeModule","Proxy","get","Error","CourierEventEmitter","NativeEventEmitter","Courier","_isDebugging","constructor","setDefaults","shared","_sharedInstance","setIsDebugging","__DEV__","isDebugging","_this$debugListener","debugListener","remove","addListener","event","console","log","setDebugMode","userId","getUserId","signIn","props","accessToken","clientKey","readMessage","messageId","unreadMessage","readAllInboxMessages","addInboxListener","inboxListener","CourierInboxListener","onInitialLoad","onError","onMessagesChanged","messages","unreadMessageCount","totalMessageCount","canPaginate","listenerId","removeInboxListener","refreshInbox","fetchNextPageOfMessages","setInboxPaginationLimit","limit","_default","exports"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAOA,IAAAC,qBAAA,GAAAD,OAAA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AAC,QAAA,GAEc3C,OAAO;AAAA4C,OAAA,CAAArD,OAAA,GAAAoD,QAAA"}
|
|
@@ -4,14 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.CourierInboxListener = void 0;
|
|
7
|
-
var _courierReactNative = _interopRequireDefault(require("courier-react-native"));
|
|
7
|
+
var _courierReactNative = _interopRequireDefault(require("@trycourier/courier-react-native"));
|
|
8
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
9
|
class CourierInboxListener {
|
|
10
10
|
remove() {
|
|
11
11
|
var _this$onInitialLoad, _this$onError, _this$onMessagesChang;
|
|
12
12
|
// Remove the native inbox listener
|
|
13
13
|
if (this.listenerId) {
|
|
14
|
-
_courierReactNative.default.removeInboxListener({
|
|
14
|
+
_courierReactNative.default.shared.removeInboxListener({
|
|
15
15
|
listenerId: this.listenerId
|
|
16
16
|
});
|
|
17
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_courierReactNative","_interopRequireDefault","require","obj","__esModule","default","CourierInboxListener","remove","_this$onInitialLoad","_this$onError","_this$onMessagesChang","listenerId","Courier","removeInboxListener","onInitialLoad","onError","onMessagesChanged","exports"],"sourceRoot":"../../../src","sources":["models/CourierInboxListener.tsx"],"mappings":";;;;;;AACA,IAAAA,mBAAA,GAAAC,sBAAA,CAAAC,OAAA;
|
|
1
|
+
{"version":3,"names":["_courierReactNative","_interopRequireDefault","require","obj","__esModule","default","CourierInboxListener","remove","_this$onInitialLoad","_this$onError","_this$onMessagesChang","listenerId","Courier","shared","removeInboxListener","onInitialLoad","onError","onMessagesChanged","exports"],"sourceRoot":"../../../src","sources":["models/CourierInboxListener.tsx"],"mappings":";;;;;;AACA,IAAAA,mBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAuD,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEhD,MAAMG,oBAAoB,CAAC;EAOzBC,MAAMA,CAAA,EAAG;IAAA,IAAAC,mBAAA,EAAAC,aAAA,EAAAC,qBAAA;IAEd;IACA,IAAI,IAAI,CAACC,UAAU,EAAE;MACnBC,2BAAO,CAACC,MAAM,CAACC,mBAAmB,CAAC;QAAEH,UAAU,EAAE,IAAI,CAACA;MAAW,CAAC,CAAC;IACrE;;IAEA;IACA,CAAAH,mBAAA,OAAI,CAACO,aAAa,cAAAP,mBAAA,uBAAlBA,mBAAA,CAAoBD,MAAM,CAAC,CAAC;IAC5B,CAAAE,aAAA,OAAI,CAACO,OAAO,cAAAP,aAAA,uBAAZA,aAAA,CAAcF,MAAM,CAAC,CAAC;IACtB,CAAAG,qBAAA,OAAI,CAACO,iBAAiB,cAAAP,qBAAA,uBAAtBA,qBAAA,CAAwBH,MAAM,CAAC,CAAC;EAElC;AAEF;AAACW,OAAA,CAAAZ,oBAAA,GAAAA,oBAAA"}
|
|
@@ -8,7 +8,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
10
|
const ComponentName = 'CourierReactNativeView';
|
|
11
|
-
const LINKING_ERROR = `The package 'courier-react-native' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
|
|
11
|
+
const LINKING_ERROR = `The package '@trycourier/courier-react-native' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
|
|
12
12
|
ios: "- You have run 'pod install'\n",
|
|
13
13
|
default: ''
|
|
14
14
|
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","obj","__esModule","default","ComponentName","LINKING_ERROR","Platform","select","ios","CourierInbox","UIManager","getViewManagerConfig","requireNativeComponent","Error","CourierInboxView","props","onClickInboxMessageAtIndex","event","index","nativeEvent","message","onClickInboxActionForMessageAtIndex","action","onScrollInbox","contentOffset","createElement","lightTheme","darkTheme","style","exports"],"sourceRoot":"../../../src","sources":["views/CourierInboxView.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAAsF,SAAAD,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AActF,MAAMG,aAAa,GAAG,wBAAwB;AAE9C,MAAMC,aAAa,GAChB
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","obj","__esModule","default","ComponentName","LINKING_ERROR","Platform","select","ios","CourierInbox","UIManager","getViewManagerConfig","requireNativeComponent","Error","CourierInboxView","props","onClickInboxMessageAtIndex","event","index","nativeEvent","message","onClickInboxActionForMessageAtIndex","action","onScrollInbox","contentOffset","createElement","lightTheme","darkTheme","style","exports"],"sourceRoot":"../../../src","sources":["views/CourierInboxView.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAAsF,SAAAD,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AActF,MAAMG,aAAa,GAAG,wBAAwB;AAE9C,MAAMC,aAAa,GAChB,2FAA0F,GAC3FC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEL,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMM,YAAY,GAChBC,sBAAS,CAACC,oBAAoB,CAACP,aAAa,CAAC,IAAI,IAAI,GACjD,IAAAQ,mCAAsB,EAAwBR,aAAa,CAAC,GAC5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oC;IACzEE,aAAa,EAAEA,aAAc;IAC7BK,KAAK,EAAEb,KAAK,CAACa;EAAM,CACpB,CAAC;AAGN,CAAC;AAAAC,OAAA,CAAAf,gBAAA,GAAAA,gBAAA"}
|
package/lib/module/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NativeModules, NativeEventEmitter, Platform } from 'react-native';
|
|
2
2
|
import { CourierInboxListener } from './models/CourierInboxListener';
|
|
3
3
|
export { CourierInboxView } from './views/CourierInboxView';
|
|
4
|
-
const LINKING_ERROR = `The package 'courier-react-native' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
|
|
4
|
+
const LINKING_ERROR = `The package '@trycourier/courier-react-native' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
|
|
5
5
|
ios: "- You have run 'pod install'\n",
|
|
6
6
|
default: ''
|
|
7
7
|
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
|
|
@@ -12,30 +12,41 @@ const CourierReactNativeModules = NativeModules.CourierReactNativeModule ? Nativ
|
|
|
12
12
|
});
|
|
13
13
|
const CourierEventEmitter = new NativeEventEmitter(NativeModules.CourierReactNativeModule);
|
|
14
14
|
class Courier {
|
|
15
|
+
_isDebugging = false;
|
|
15
16
|
constructor() {
|
|
16
17
|
// Sets the initial SDK values
|
|
17
18
|
// Defaults to React Native level debugging
|
|
18
19
|
// and will show all foreground notification styles in iOS
|
|
19
20
|
this.setDefaults();
|
|
20
21
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
// }),
|
|
27
|
-
]);
|
|
28
|
-
} catch (error) {
|
|
29
|
-
console.log(error);
|
|
22
|
+
|
|
23
|
+
// Returns the public shared instance
|
|
24
|
+
static get shared() {
|
|
25
|
+
if (!this._sharedInstance) {
|
|
26
|
+
this._sharedInstance = new Courier();
|
|
30
27
|
}
|
|
28
|
+
return this._sharedInstance;
|
|
31
29
|
}
|
|
32
|
-
|
|
30
|
+
async setDefaults() {
|
|
31
|
+
this.setIsDebugging(__DEV__);
|
|
32
|
+
// try {
|
|
33
|
+
// await Promise.all([
|
|
34
|
+
// this.setIsDebugging(__DEV__),
|
|
35
|
+
// // this.iOSForegroundPresentationOptions({
|
|
36
|
+
// // options: ['sound', 'badge', 'list', 'banner'],
|
|
37
|
+
// // }),
|
|
38
|
+
// ]);
|
|
39
|
+
// } catch (error) {
|
|
40
|
+
// console.log(error);
|
|
41
|
+
// }
|
|
42
|
+
}
|
|
43
|
+
|
|
33
44
|
/**
|
|
34
45
|
* Tells native Courier SDKs to show or hide logs.
|
|
35
46
|
* Defaults to the React __DEV__ mode
|
|
36
47
|
* @example Courier.setIsDebugging(true)
|
|
37
48
|
*/
|
|
38
|
-
|
|
49
|
+
setIsDebugging(isDebugging) {
|
|
39
50
|
var _this$debugListener;
|
|
40
51
|
// Remove the existing listener if needed
|
|
41
52
|
(_this$debugListener = this.debugListener) === null || _this$debugListener === void 0 ? void 0 : _this$debugListener.remove();
|
|
@@ -47,7 +58,8 @@ class Courier {
|
|
|
47
58
|
console.log('\x1b[36m%s\x1b[0m', 'COURIER', event);
|
|
48
59
|
});
|
|
49
60
|
}
|
|
50
|
-
|
|
61
|
+
CourierReactNativeModules.setDebugMode(isDebugging);
|
|
62
|
+
this._isDebugging = isDebugging;
|
|
51
63
|
return this._isDebugging;
|
|
52
64
|
}
|
|
53
65
|
get isDebugging() {
|
|
@@ -124,23 +136,53 @@ class Courier {
|
|
|
124
136
|
}
|
|
125
137
|
if (props.onError) {
|
|
126
138
|
inboxListener.onError = CourierEventEmitter.addListener('inboxError', event => {
|
|
127
|
-
|
|
128
|
-
props.onError();
|
|
139
|
+
props.onError(event);
|
|
129
140
|
});
|
|
130
141
|
}
|
|
131
142
|
if (props.onMessagesChanged) {
|
|
132
143
|
inboxListener.onMessagesChanged = CourierEventEmitter.addListener('inboxMessagesChanged', event => {
|
|
133
|
-
|
|
134
|
-
console.log(event);
|
|
135
|
-
props.onMessagesChanged(event.messages);
|
|
144
|
+
props.onMessagesChanged(event.messages, event.unreadMessageCount, event.totalMessageCount, event.canPaginate);
|
|
136
145
|
});
|
|
137
146
|
}
|
|
138
147
|
inboxListener.listenerId = CourierReactNativeModules.addInboxListener(null);
|
|
139
148
|
return inboxListener;
|
|
140
149
|
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* TODO
|
|
153
|
+
* @param props
|
|
154
|
+
* @returns
|
|
155
|
+
*/
|
|
141
156
|
removeInboxListener(props) {
|
|
142
157
|
return CourierReactNativeModules.removeInboxListener(props.listenerId);
|
|
143
158
|
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* TODO
|
|
162
|
+
* @param props
|
|
163
|
+
* @returns
|
|
164
|
+
*/
|
|
165
|
+
async refreshInbox() {
|
|
166
|
+
return CourierReactNativeModules.refreshInbox();
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* TODO
|
|
171
|
+
* @param props
|
|
172
|
+
* @returns
|
|
173
|
+
*/
|
|
174
|
+
async fetchNextPageOfMessages() {
|
|
175
|
+
return CourierReactNativeModules.fetchNextPageOfMessages();
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* TODO
|
|
180
|
+
* @param props
|
|
181
|
+
* @returns
|
|
182
|
+
*/
|
|
183
|
+
setInboxPaginationLimit(props) {
|
|
184
|
+
CourierReactNativeModules.setInboxPaginationLimit(props.limit);
|
|
185
|
+
}
|
|
144
186
|
}
|
|
145
|
-
export default
|
|
187
|
+
export default Courier;
|
|
146
188
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeModules","NativeEventEmitter","Platform","CourierInboxListener","CourierInboxView","LINKING_ERROR","select","ios","default","CourierReactNativeModules","CourierReactNativeModule","Proxy","get","Error","CourierEventEmitter","Courier","constructor","setDefaults","
|
|
1
|
+
{"version":3,"names":["NativeModules","NativeEventEmitter","Platform","CourierInboxListener","CourierInboxView","LINKING_ERROR","select","ios","default","CourierReactNativeModules","CourierReactNativeModule","Proxy","get","Error","CourierEventEmitter","Courier","_isDebugging","constructor","setDefaults","shared","_sharedInstance","setIsDebugging","__DEV__","isDebugging","_this$debugListener","debugListener","remove","addListener","event","console","log","setDebugMode","userId","getUserId","signIn","props","accessToken","clientKey","readMessage","messageId","unreadMessage","readAllInboxMessages","addInboxListener","inboxListener","onInitialLoad","onError","onMessagesChanged","messages","unreadMessageCount","totalMessageCount","canPaginate","listenerId","removeInboxListener","refreshInbox","fetchNextPageOfMessages","setInboxPaginationLimit","limit"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SACEA,aAAa,EACbC,kBAAkB,EAElBC,QAAQ,QACH,cAAc;AAErB,SAASC,oBAAoB,QAAQ,+BAA+B;AAEpE,SAASC,gBAAgB,QAAQ,0BAA0B;AAE3D,MAAMC,aAAa,GAChB,2FAA0F,GAC3FH,QAAQ,CAACI,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,yBAAyB,GAAGT,aAAa,CAACU,wBAAwB,GACpEV,aAAa,CAACU,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,IAAIb,kBAAkB,CAChDD,aAAa,CAACU,wBAChB,CAAC;AAED,MAAMK,OAAO,CAAC;EAGJC,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,CA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E,OAAOC,aAAa;EAEtB;;EAEA;AACF;AACA;AACA;AACA;EACSS,mBAAmBA,CAACjB,KAA6B,EAAU;IAChE,OAAO1B,yBAAyB,CAAC2C,mBAAmB,CAACjB,KAAK,CAACgB,UAAU,CAAC;EACxE;;EAEA;AACF;AACA;AACA;AACA;EACE,MAAaE,YAAYA,CAAA,EAAkB;IACzC,OAAO5C,yBAAyB,CAAC4C,YAAY,CAAC,CAAC;EACjD;;EAEA;AACF;AACA;AACA;AACA;EACG,MAAaC,uBAAuBA,CAAA,EAA4B;IAC/D,OAAO7C,yBAAyB,CAAC6C,uBAAuB,CAAC,CAAC;EAC5D;;EAEA;AACF;AACA;AACA;AACA;EACUC,uBAAuBA,CAACpB,KAAwB,EAAQ;IAC9D1B,yBAAyB,CAAC8C,uBAAuB,CAACpB,KAAK,CAACqB,KAAK,CAAC;EAChE;AAEF;AAEA,eAAezC,OAAO"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import Courier from
|
|
1
|
+
import Courier from "@trycourier/courier-react-native";
|
|
2
2
|
export class CourierInboxListener {
|
|
3
3
|
remove() {
|
|
4
4
|
var _this$onInitialLoad, _this$onError, _this$onMessagesChang;
|
|
5
5
|
// Remove the native inbox listener
|
|
6
6
|
if (this.listenerId) {
|
|
7
|
-
Courier.removeInboxListener({
|
|
7
|
+
Courier.shared.removeInboxListener({
|
|
8
8
|
listenerId: this.listenerId
|
|
9
9
|
});
|
|
10
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Courier","CourierInboxListener","remove","_this$onInitialLoad","_this$onError","_this$onMessagesChang","listenerId","removeInboxListener","onInitialLoad","onError","onMessagesChanged"],"sourceRoot":"../../../src","sources":["models/CourierInboxListener.tsx"],"mappings":"AACA,OAAOA,OAAO,MAAM,
|
|
1
|
+
{"version":3,"names":["Courier","CourierInboxListener","remove","_this$onInitialLoad","_this$onError","_this$onMessagesChang","listenerId","shared","removeInboxListener","onInitialLoad","onError","onMessagesChanged"],"sourceRoot":"../../../src","sources":["models/CourierInboxListener.tsx"],"mappings":"AACA,OAAOA,OAAO,MAAM,kCAAkC;AAEtD,OAAO,MAAMC,oBAAoB,CAAC;EAOzBC,MAAMA,CAAA,EAAG;IAAA,IAAAC,mBAAA,EAAAC,aAAA,EAAAC,qBAAA;IAEd;IACA,IAAI,IAAI,CAACC,UAAU,EAAE;MACnBN,OAAO,CAACO,MAAM,CAACC,mBAAmB,CAAC;QAAEF,UAAU,EAAE,IAAI,CAACA;MAAW,CAAC,CAAC;IACrE;;IAEA;IACA,CAAAH,mBAAA,OAAI,CAACM,aAAa,cAAAN,mBAAA,uBAAlBA,mBAAA,CAAoBD,MAAM,CAAC,CAAC;IAC5B,CAAAE,aAAA,OAAI,CAACM,OAAO,cAAAN,aAAA,uBAAZA,aAAA,CAAcF,MAAM,CAAC,CAAC;IACtB,CAAAG,qBAAA,OAAI,CAACM,iBAAiB,cAAAN,qBAAA,uBAAtBA,qBAAA,CAAwBH,MAAM,CAAC,CAAC;EAElC;AAEF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Platform, requireNativeComponent, UIManager } from "react-native";
|
|
3
3
|
const ComponentName = 'CourierReactNativeView';
|
|
4
|
-
const LINKING_ERROR = `The package 'courier-react-native' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
|
|
4
|
+
const LINKING_ERROR = `The package '@trycourier/courier-react-native' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
|
|
5
5
|
ios: "- You have run 'pod install'\n",
|
|
6
6
|
default: ''
|
|
7
7
|
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","Platform","requireNativeComponent","UIManager","ComponentName","LINKING_ERROR","select","ios","default","CourierInbox","getViewManagerConfig","Error","CourierInboxView","props","onClickInboxMessageAtIndex","event","index","nativeEvent","message","onClickInboxActionForMessageAtIndex","action","onScrollInbox","contentOffset","createElement","lightTheme","darkTheme","style"],"sourceRoot":"../../../src","sources":["views/CourierInboxView.tsx"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,QAAQ,EAAEC,sBAAsB,EAAEC,SAAS,QAAmB,cAAc;AAcrF,MAAMC,aAAa,GAAG,wBAAwB;AAE9C,MAAMC,aAAa,GAChB
|
|
1
|
+
{"version":3,"names":["React","Platform","requireNativeComponent","UIManager","ComponentName","LINKING_ERROR","select","ios","default","CourierInbox","getViewManagerConfig","Error","CourierInboxView","props","onClickInboxMessageAtIndex","event","index","nativeEvent","message","onClickInboxActionForMessageAtIndex","action","onScrollInbox","contentOffset","createElement","lightTheme","darkTheme","style"],"sourceRoot":"../../../src","sources":["views/CourierInboxView.tsx"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,QAAQ,EAAEC,sBAAsB,EAAEC,SAAS,QAAmB,cAAc;AAcrF,MAAMC,aAAa,GAAG,wBAAwB;AAE9C,MAAMC,aAAa,GAChB,2FAA0F,GAC3FJ,QAAQ,CAACK,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,YAAY,GAChBN,SAAS,CAACO,oBAAoB,CAACN,aAAa,CAAC,IAAI,IAAI,GACjDF,sBAAsB,CAAwBE,aAAa,CAAC,GAC5D,MAAM;EACJ,MAAM,IAAIO,KAAK,CAACN,aAAa,CAAC;AAChC,CAAC;AAEP,OAAO,MAAMO,gBAAgB,GAAIC,KAA4B,IAAK;EAEhE,MAAMC,0BAA0B,GAAIC,KAAU,IAAK;IAEjD;IACA,IAAIF,KAAK,CAACC,0BAA0B,EAAE;MAEpC,MAAME,KAAK,GAAGD,KAAK,CAACE,WAAW,CAAC,OAAO,CAAC;MACxC,MAAMC,OAAO,GAAGH,KAAK,CAACE,WAAW,CAAC,SAAS,CAAiB;MAE5DJ,KAAK,CAACC,0BAA0B,CAACI,OAAO,EAAEF,KAAK,CAAC;IAElD;EAEF,CAAC;EAED,MAAMG,mCAAmC,GAAIJ,KAAU,IAAK;IAE1D;IACA,IAAIF,KAAK,CAACM,mCAAmC,EAAE;MAE7C,MAAMH,KAAK,GAAGD,KAAK,CAACE,WAAW,CAAC,OAAO,CAAC;MACxC,MAAMG,MAAM,GAAGL,KAAK,CAACE,WAAW,CAAC,QAAQ,CAAgB;MACzD,MAAMC,OAAO,GAAGH,KAAK,CAACE,WAAW,CAAC,SAAS,CAAiB;MAE5DJ,KAAK,CAACM,mCAAmC,CAACC,MAAM,EAAEF,OAAO,EAAEF,KAAK,CAAC;IAEnE;EAEF,CAAC;EAED,MAAMK,aAAa,GAAIN,KAAU,IAAK;IAEpC;IACA,IAAIF,KAAK,CAACQ,aAAa,EAAE;MAEvB,MAAMC,aAAa,GAAGP,KAAK,CAACE,WAAW,CAAC,eAAe,CAAC;MACxDJ,KAAK,CAACQ,aAAa,CAACC,aAAa,CAAC,GAAG,CAAC,EAAEA,aAAa,CAAC,GAAG,CAAC,CAAC;IAE7D;EAEF,CAAC;EAED,oBACEtB,KAAA,CAAAuB,aAAA,CAACd,YAAY;IACXe,UAAU,EAAEX,KAAK,CAACW,UAAW;IAC7BC,SAAS,EAAEZ,KAAK,CAACY,SAAU;IAC3BX,0BAA0B,EAAEA,0BAA2B;IACvDK,mCAAmC,EAAEA,mCAAoC;IACzEE,aAAa,EAAEA,aAAc;IAC7BK,KAAK,EAAEb,KAAK,CAACa;EAAM,CACpB,CAAC;AAGN,CAAC"}
|
|
@@ -2,16 +2,18 @@ import { CourierInboxListener } from './models/CourierInboxListener';
|
|
|
2
2
|
import { InboxMessage } from './models/InboxMessage';
|
|
3
3
|
export { CourierInboxView } from './views/CourierInboxView';
|
|
4
4
|
declare class Courier {
|
|
5
|
-
|
|
6
|
-
private setDefaults;
|
|
5
|
+
private static _sharedInstance;
|
|
7
6
|
private _isDebugging;
|
|
8
7
|
private debugListener;
|
|
8
|
+
constructor();
|
|
9
|
+
static get shared(): Courier;
|
|
10
|
+
private setDefaults;
|
|
9
11
|
/**
|
|
10
12
|
* Tells native Courier SDKs to show or hide logs.
|
|
11
13
|
* Defaults to the React __DEV__ mode
|
|
12
14
|
* @example Courier.setIsDebugging(true)
|
|
13
15
|
*/
|
|
14
|
-
setIsDebugging(isDebugging: boolean):
|
|
16
|
+
setIsDebugging(isDebugging: boolean): boolean;
|
|
15
17
|
get isDebugging(): boolean;
|
|
16
18
|
/**
|
|
17
19
|
* Returns the current user id stored in local native storage
|
|
@@ -67,14 +69,38 @@ declare class Courier {
|
|
|
67
69
|
* @returns
|
|
68
70
|
*/
|
|
69
71
|
addInboxListener(props: {
|
|
70
|
-
onInitialLoad
|
|
71
|
-
onError:
|
|
72
|
-
onMessagesChanged
|
|
72
|
+
onInitialLoad?: () => void;
|
|
73
|
+
onError?: (error: string) => void;
|
|
74
|
+
onMessagesChanged?: (messages: InboxMessage[], unreadMessageCount: number, totalMessageCount: number, canPaginate: boolean) => void;
|
|
73
75
|
}): CourierInboxListener;
|
|
76
|
+
/**
|
|
77
|
+
* TODO
|
|
78
|
+
* @param props
|
|
79
|
+
* @returns
|
|
80
|
+
*/
|
|
74
81
|
removeInboxListener(props: {
|
|
75
82
|
listenerId: string;
|
|
76
83
|
}): string;
|
|
84
|
+
/**
|
|
85
|
+
* TODO
|
|
86
|
+
* @param props
|
|
87
|
+
* @returns
|
|
88
|
+
*/
|
|
89
|
+
refreshInbox(): Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* TODO
|
|
92
|
+
* @param props
|
|
93
|
+
* @returns
|
|
94
|
+
*/
|
|
95
|
+
fetchNextPageOfMessages(): Promise<InboxMessage[]>;
|
|
96
|
+
/**
|
|
97
|
+
* TODO
|
|
98
|
+
* @param props
|
|
99
|
+
* @returns
|
|
100
|
+
*/
|
|
101
|
+
setInboxPaginationLimit(props: {
|
|
102
|
+
limit: number;
|
|
103
|
+
}): void;
|
|
77
104
|
}
|
|
78
|
-
|
|
79
|
-
export default _default;
|
|
105
|
+
export default Courier;
|
|
80
106
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAuB5D,cAAM,OAAO;IAEX,OAAO,CAAC,MAAM,CAAC,eAAe,CAAU;IACxC,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,aAAa,CAAkC;;IAWvD,WAAkB,MAAM,IAAI,OAAO,CAQlC;YAEa,WAAW;IAczB;;;;OAIG;IACI,cAAc,CAAC,WAAW,EAAE,OAAO,GAAG,OAAO;IAqBpD,IAAI,WAAW,IAAI,OAAO,CAEzB;IAED;;;OAGG;IACH,IAAI,MAAM,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAExC;IAED;;;;;;;;;;;;;;;OAeG;IACI,MAAM,CAAC,KAAK,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAIhG;;;;OAIG;IACI,WAAW,CAAC,KAAK,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAI/D;;;;OAIG;IACI,aAAa,CAAC,KAAK,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjE;;;;OAIG;IACI,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5C;;;;OAIG;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;IAkC5P;;;;OAIG;IACI,mBAAmB,CAAC,KAAK,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM;IAIjE;;;;OAIG;IACU,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAI1C;;;;OAIG;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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CourierInboxListener.d.ts","sourceRoot":"","sources":["../../../src/models/CourierInboxListener.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"CourierInboxListener.d.ts","sourceRoot":"","sources":["../../../src/models/CourierInboxListener.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGnD,qBAAa,oBAAoB;IAExB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,aAAa,CAAC,EAAE,mBAAmB,CAAA;IACnC,OAAO,CAAC,EAAE,mBAAmB,CAAA;IAC7B,iBAAiB,CAAC,EAAE,mBAAmB,CAAA;IAEvC,MAAM;CAcd"}
|
package/package.json
CHANGED
package/src/index.tsx
CHANGED
|
@@ -4,13 +4,13 @@ import {
|
|
|
4
4
|
EmitterSubscription,
|
|
5
5
|
Platform,
|
|
6
6
|
} from 'react-native';
|
|
7
|
+
|
|
7
8
|
import { CourierInboxListener } from './models/CourierInboxListener';
|
|
8
9
|
import { InboxMessage } from './models/InboxMessage';
|
|
9
|
-
|
|
10
10
|
export { CourierInboxView } from './views/CourierInboxView';
|
|
11
11
|
|
|
12
12
|
const LINKING_ERROR =
|
|
13
|
-
`The package 'courier-react-native' doesn't seem to be linked. Make sure: \n\n` +
|
|
13
|
+
`The package '@trycourier/courier-react-native' doesn't seem to be linked. Make sure: \n\n` +
|
|
14
14
|
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
|
|
15
15
|
'- You rebuilt the app after installing the package\n' +
|
|
16
16
|
'- You are not using Expo Go\n';
|
|
@@ -32,6 +32,10 @@ const CourierEventEmitter = new NativeEventEmitter(
|
|
|
32
32
|
|
|
33
33
|
class Courier {
|
|
34
34
|
|
|
35
|
+
private static _sharedInstance: Courier;
|
|
36
|
+
private _isDebugging = false;
|
|
37
|
+
private debugListener: EmitterSubscription | undefined;
|
|
38
|
+
|
|
35
39
|
public constructor() {
|
|
36
40
|
|
|
37
41
|
// Sets the initial SDK values
|
|
@@ -40,29 +44,37 @@ class Courier {
|
|
|
40
44
|
this.setDefaults();
|
|
41
45
|
}
|
|
42
46
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
// options: ['sound', 'badge', 'list', 'banner'],
|
|
49
|
-
// }),
|
|
50
|
-
]);
|
|
51
|
-
} catch (error) {
|
|
52
|
-
console.log(error);
|
|
47
|
+
// Returns the public shared instance
|
|
48
|
+
public static get shared(): Courier {
|
|
49
|
+
|
|
50
|
+
if (!this._sharedInstance) {
|
|
51
|
+
this._sharedInstance = new Courier();
|
|
53
52
|
}
|
|
54
|
-
}
|
|
55
53
|
|
|
56
|
-
|
|
54
|
+
return this._sharedInstance;
|
|
57
55
|
|
|
58
|
-
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
private async setDefaults() {
|
|
59
|
+
this.setIsDebugging(__DEV__);
|
|
60
|
+
// try {
|
|
61
|
+
// await Promise.all([
|
|
62
|
+
// this.setIsDebugging(__DEV__),
|
|
63
|
+
// // this.iOSForegroundPresentationOptions({
|
|
64
|
+
// // options: ['sound', 'badge', 'list', 'banner'],
|
|
65
|
+
// // }),
|
|
66
|
+
// ]);
|
|
67
|
+
// } catch (error) {
|
|
68
|
+
// console.log(error);
|
|
69
|
+
// }
|
|
70
|
+
}
|
|
59
71
|
|
|
60
72
|
/**
|
|
61
73
|
* Tells native Courier SDKs to show or hide logs.
|
|
62
74
|
* Defaults to the React __DEV__ mode
|
|
63
75
|
* @example Courier.setIsDebugging(true)
|
|
64
76
|
*/
|
|
65
|
-
public
|
|
77
|
+
public setIsDebugging(isDebugging: boolean): boolean {
|
|
66
78
|
|
|
67
79
|
// Remove the existing listener if needed
|
|
68
80
|
this.debugListener?.remove();
|
|
@@ -75,7 +87,9 @@ class Courier {
|
|
|
75
87
|
});
|
|
76
88
|
}
|
|
77
89
|
|
|
78
|
-
|
|
90
|
+
CourierReactNativeModules.setDebugMode(isDebugging);
|
|
91
|
+
|
|
92
|
+
this._isDebugging = isDebugging
|
|
79
93
|
|
|
80
94
|
return this._isDebugging;
|
|
81
95
|
|
|
@@ -145,7 +159,7 @@ class Courier {
|
|
|
145
159
|
* @param props
|
|
146
160
|
* @returns
|
|
147
161
|
*/
|
|
148
|
-
public addInboxListener(props: { onInitialLoad
|
|
162
|
+
public addInboxListener(props: { onInitialLoad?: () => void, onError?: (error: string) => void, onMessagesChanged?: (messages: InboxMessage[], unreadMessageCount: number, totalMessageCount: number, canPaginate: boolean) => void }): CourierInboxListener {
|
|
149
163
|
|
|
150
164
|
// Create the initial listeners
|
|
151
165
|
const inboxListener = new CourierInboxListener();
|
|
@@ -158,17 +172,17 @@ class Courier {
|
|
|
158
172
|
|
|
159
173
|
if (props.onError) {
|
|
160
174
|
inboxListener.onError = CourierEventEmitter.addListener('inboxError', event => {
|
|
161
|
-
|
|
162
|
-
props.onError!()
|
|
175
|
+
props.onError!(event)
|
|
163
176
|
});
|
|
164
177
|
}
|
|
165
178
|
|
|
166
179
|
if (props.onMessagesChanged) {
|
|
167
180
|
inboxListener.onMessagesChanged = CourierEventEmitter.addListener('inboxMessagesChanged', event => {
|
|
168
|
-
console.log('onMessagesChanged')
|
|
169
|
-
console.log(event)
|
|
170
181
|
props.onMessagesChanged!(
|
|
171
|
-
event.messages
|
|
182
|
+
event.messages,
|
|
183
|
+
event.unreadMessageCount,
|
|
184
|
+
event.totalMessageCount,
|
|
185
|
+
event.canPaginate,
|
|
172
186
|
)
|
|
173
187
|
});
|
|
174
188
|
}
|
|
@@ -179,10 +193,42 @@ class Courier {
|
|
|
179
193
|
|
|
180
194
|
}
|
|
181
195
|
|
|
196
|
+
/**
|
|
197
|
+
* TODO
|
|
198
|
+
* @param props
|
|
199
|
+
* @returns
|
|
200
|
+
*/
|
|
182
201
|
public removeInboxListener(props: { listenerId: string }): string {
|
|
183
202
|
return CourierReactNativeModules.removeInboxListener(props.listenerId);
|
|
184
203
|
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* TODO
|
|
207
|
+
* @param props
|
|
208
|
+
* @returns
|
|
209
|
+
*/
|
|
210
|
+
public async refreshInbox(): Promise<void> {
|
|
211
|
+
return CourierReactNativeModules.refreshInbox();
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* TODO
|
|
216
|
+
* @param props
|
|
217
|
+
* @returns
|
|
218
|
+
*/
|
|
219
|
+
public async fetchNextPageOfMessages(): Promise<InboxMessage[]> {
|
|
220
|
+
return CourierReactNativeModules.fetchNextPageOfMessages();
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* TODO
|
|
225
|
+
* @param props
|
|
226
|
+
* @returns
|
|
227
|
+
*/
|
|
228
|
+
public setInboxPaginationLimit(props: { limit: number }): void {
|
|
229
|
+
CourierReactNativeModules.setInboxPaginationLimit(props.limit);
|
|
230
|
+
}
|
|
185
231
|
|
|
186
232
|
}
|
|
187
233
|
|
|
188
|
-
export default
|
|
234
|
+
export default Courier;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { EmitterSubscription } from "react-native"
|
|
2
|
-
import Courier from
|
|
1
|
+
import { EmitterSubscription } from "react-native";
|
|
2
|
+
import Courier from "@trycourier/courier-react-native";
|
|
3
3
|
|
|
4
4
|
export class CourierInboxListener {
|
|
5
5
|
|
|
@@ -12,7 +12,7 @@ export class CourierInboxListener {
|
|
|
12
12
|
|
|
13
13
|
// Remove the native inbox listener
|
|
14
14
|
if (this.listenerId) {
|
|
15
|
-
Courier.removeInboxListener({ listenerId: this.listenerId });
|
|
15
|
+
Courier.shared.removeInboxListener({ listenerId: this.listenerId });
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
// Remove the emitters
|
|
@@ -16,7 +16,7 @@ type CourierInboxViewProps = {
|
|
|
16
16
|
const ComponentName = 'CourierReactNativeView';
|
|
17
17
|
|
|
18
18
|
const LINKING_ERROR =
|
|
19
|
-
`The package 'courier-react-native' doesn't seem to be linked. Make sure: \n\n` +
|
|
19
|
+
`The package '@trycourier/courier-react-native' doesn't seem to be linked. Make sure: \n\n` +
|
|
20
20
|
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
|
|
21
21
|
'- You rebuilt the app after installing the package\n' +
|
|
22
22
|
'- You are not using Expo Go\n';
|