@trycourier/courier-react-native 2.0.2 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -8
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/courierreactnative/CourierReactNativeModule.kt +50 -0
- package/android/src/main/java/com/courierreactnative/Extensions.kt +51 -3
- package/courier-react-native.podspec +1 -1
- package/ios/CourierReactNative.xcodeproj/project.xcworkspace/contents.xcworkspacedata +3 -0
- package/ios/CourierReactNative.xcodeproj/project.xcworkspace/xcuserdata/mike.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/CourierReactNativeModule.m +27 -0
- package/ios/CourierReactNativeModule.swift +51 -15
- package/ios/CourierReactNativeViewManager.swift +0 -123
- package/ios/Utils.swift +199 -0
- package/lib/commonjs/hooks/CourierProvider.js +8 -12
- package/lib/commonjs/hooks/CourierProvider.js.map +1 -1
- package/lib/commonjs/index.js +35 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/CourierPaging.js +2 -0
- package/lib/commonjs/models/CourierPaging.js.map +1 -0
- package/lib/commonjs/models/CourierUserPreferences.js +6 -0
- package/lib/commonjs/models/CourierUserPreferences.js.map +1 -0
- package/lib/commonjs/models/CourierUserPreferencesChannel.js +17 -0
- package/lib/commonjs/models/CourierUserPreferencesChannel.js.map +1 -0
- package/lib/commonjs/models/CourierUserPreferencesStatus.js +15 -0
- package/lib/commonjs/models/CourierUserPreferencesStatus.js.map +1 -0
- package/lib/commonjs/models/CourierUserPreferencesTopic.js +6 -0
- package/lib/commonjs/models/CourierUserPreferencesTopic.js.map +1 -0
- package/lib/module/hooks/CourierProvider.js +8 -12
- package/lib/module/hooks/CourierProvider.js.map +1 -1
- package/lib/module/index.js +23 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/CourierPaging.js +2 -0
- package/lib/module/models/CourierPaging.js.map +1 -0
- package/lib/module/models/CourierUserPreferences.js +2 -0
- package/lib/module/models/CourierUserPreferences.js.map +1 -0
- package/lib/module/models/CourierUserPreferencesChannel.js +10 -0
- package/lib/module/models/CourierUserPreferencesChannel.js.map +1 -0
- package/lib/module/models/CourierUserPreferencesStatus.js +8 -0
- package/lib/module/models/CourierUserPreferencesStatus.js.map +1 -0
- package/lib/module/models/CourierUserPreferencesTopic.js +2 -0
- package/lib/module/models/CourierUserPreferencesTopic.js.map +1 -0
- package/lib/typescript/index.d.ts +27 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/models/CourierPaging.d.ts +5 -0
- package/lib/typescript/models/CourierPaging.d.ts.map +1 -0
- package/lib/typescript/models/CourierUserPreferences.d.ts +7 -0
- package/lib/typescript/models/CourierUserPreferences.d.ts.map +1 -0
- package/lib/typescript/models/CourierUserPreferencesChannel.d.ts +9 -0
- package/lib/typescript/models/CourierUserPreferencesChannel.d.ts.map +1 -0
- package/lib/typescript/models/CourierUserPreferencesStatus.d.ts +7 -0
- package/lib/typescript/models/CourierUserPreferencesStatus.d.ts.map +1 -0
- package/lib/typescript/models/CourierUserPreferencesTopic.d.ts +11 -0
- package/lib/typescript/models/CourierUserPreferencesTopic.d.ts.map +1 -0
- package/lib/typescript/views/CourierInboxView.d.ts +3 -3
- package/lib/typescript/views/CourierInboxView.d.ts.map +1 -1
- package/package.json +4 -2
- package/src/hooks/CourierProvider.tsx +9 -9
- package/src/index.tsx +27 -0
- package/src/models/CourierPaging.tsx +4 -0
- package/src/models/CourierUserPreferences.tsx +7 -0
- package/src/models/CourierUserPreferencesChannel.tsx +8 -0
- package/src/models/CourierUserPreferencesStatus.tsx +6 -0
- package/src/models/CourierUserPreferencesTopic.tsx +11 -0
- package/src/views/CourierInboxView.tsx +3 -3
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CourierPaging } from "./CourierPaging";
|
|
2
|
+
import { CourierUserPreferencesTopic } from "./CourierUserPreferencesTopic";
|
|
3
|
+
export interface CourierUserPreferences {
|
|
4
|
+
items?: CourierUserPreferencesTopic[];
|
|
5
|
+
paging?: CourierPaging;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=CourierUserPreferences.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CourierUserPreferences.d.ts","sourceRoot":"","sources":["../../../src/models/CourierUserPreferences.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAE5E,MAAM,WAAW,sBAAsB;IACrC,KAAK,CAAC,EAAE,2BAA2B,EAAE,CAAC;IACtC,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CourierUserPreferencesChannel.d.ts","sourceRoot":"","sources":["../../../src/models/CourierUserPreferencesChannel.tsx"],"names":[],"mappings":"AAAA,oBAAY,6BAA6B;IACvC,aAAa,mBAAmB;IAChC,KAAK,UAAU;IACf,IAAI,SAAS;IACb,GAAG,QAAQ;IACX,OAAO,YAAY;IACnB,OAAO,YAAY;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CourierUserPreferencesStatus.d.ts","sourceRoot":"","sources":["../../../src/models/CourierUserPreferencesStatus.tsx"],"names":[],"mappings":"AAAA,oBAAY,4BAA4B;IACtC,OAAO,aAAa;IACpB,QAAQ,cAAc;IACtB,QAAQ,aAAa;IACrB,OAAO,YAAY;CACpB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CourierUserPreferencesChannel } from "./CourierUserPreferencesChannel";
|
|
2
|
+
import { CourierUserPreferencesStatus } from "./CourierUserPreferencesStatus";
|
|
3
|
+
export interface CourierUserPreferencesTopic {
|
|
4
|
+
defaultStatus?: string;
|
|
5
|
+
hasCustomRouting?: string;
|
|
6
|
+
customRouting?: CourierUserPreferencesChannel[];
|
|
7
|
+
status?: CourierUserPreferencesStatus;
|
|
8
|
+
topicId?: string;
|
|
9
|
+
topicName?: string;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=CourierUserPreferencesTopic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CourierUserPreferencesTopic.d.ts","sourceRoot":"","sources":["../../../src/models/CourierUserPreferencesTopic.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAE9E,MAAM,WAAW,2BAA2B;IAC1C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,aAAa,CAAC,EAAE,6BAA6B,EAAE,CAAC;IAChD,MAAM,CAAC,EAAE,4BAA4B,CAAC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { ViewStyle } from "react-native";
|
|
3
|
-
import CourierInboxTheme from "
|
|
4
|
-
import { InboxAction } from "
|
|
5
|
-
import { InboxMessage } from "
|
|
3
|
+
import CourierInboxTheme from "../models/CourierInboxTheme";
|
|
4
|
+
import { InboxAction } from "../models/InboxAction";
|
|
5
|
+
import { InboxMessage } from "../models/InboxMessage";
|
|
6
6
|
type CourierInboxViewProps = {
|
|
7
7
|
theme?: {
|
|
8
8
|
light?: CourierInboxTheme;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CourierInboxView.d.ts","sourceRoot":"","sources":["../../../src/views/CourierInboxView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AACzC,OAAO,EAA+C,SAAS,EAA2C,MAAM,cAAc,CAAC;AAC/H,OAAO,iBAAiB,MAAM,
|
|
1
|
+
{"version":3,"file":"CourierInboxView.d.ts","sourceRoot":"","sources":["../../../src/views/CourierInboxView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AACzC,OAAO,EAA+C,SAAS,EAA2C,MAAM,cAAc,CAAC;AAC/H,OAAO,iBAAiB,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,KAAK,qBAAqB,GAAG;IAC3B,KAAK,CAAC,EAAE;QACN,KAAK,CAAC,EAAE,iBAAiB,CAAC;QAC1B,IAAI,CAAC,EAAE,iBAAiB,CAAA;KACzB,CAAC;IACF,0BAA0B,CAAC,EAAE,CAAC,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5E,mCAAmC,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1G,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3D,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAiBF,eAAO,MAAM,gBAAgB,UAAW,qBAAqB,sBAiG5D,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trycourier/courier-react-native",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Inbox & Push Notifications for React Native",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -36,7 +36,9 @@
|
|
|
36
36
|
"build:android": "cd example/android && ./gradlew assembleDebug --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a",
|
|
37
37
|
"build:ios": "cd example/ios && xcodebuild -workspace CourierReactNativeExample.xcworkspace -scheme CourierReactNativeExample -configuration Debug -sdk iphonesimulator CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ GCC_OPTIMIZATION_LEVEL=0 GCC_PRECOMPILE_PREFIX_HEADER=YES ASSETCATALOG_COMPILER_OPTIMIZATION=time DEBUG_INFORMATION_FORMAT=dwarf COMPILER_INDEX_STORE_ENABLE=NO",
|
|
38
38
|
"bootstrap": "yarn example && yarn install && yarn example pods",
|
|
39
|
-
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build"
|
|
39
|
+
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build",
|
|
40
|
+
"linkPackage": "yarn link && yarn example link @trycourier/courier-react-native && yarn example setupEnv",
|
|
41
|
+
"setup": "sh setup.sh"
|
|
40
42
|
},
|
|
41
43
|
"keywords": [
|
|
42
44
|
"react-native",
|
|
@@ -82,12 +82,6 @@ export const CourierProvider: React.FC<{ children: ReactNode }> = ({ children })
|
|
|
82
82
|
const userId = Courier.shared.userId;
|
|
83
83
|
auth_setUserId(userId);
|
|
84
84
|
|
|
85
|
-
// Permissions
|
|
86
|
-
syncNotificationPermissions();
|
|
87
|
-
|
|
88
|
-
// Push tokens
|
|
89
|
-
syncTokens();
|
|
90
|
-
|
|
91
85
|
}, []);
|
|
92
86
|
|
|
93
87
|
useEffect(() => {
|
|
@@ -114,6 +108,12 @@ export const CourierProvider: React.FC<{ children: ReactNode }> = ({ children })
|
|
|
114
108
|
|
|
115
109
|
const startPush = () => {
|
|
116
110
|
|
|
111
|
+
// Permissions
|
|
112
|
+
syncNotificationPermissions();
|
|
113
|
+
|
|
114
|
+
// Push tokens
|
|
115
|
+
syncTokens();
|
|
116
|
+
|
|
117
117
|
if (!pushListener) {
|
|
118
118
|
|
|
119
119
|
pushListener = Courier.shared.addPushNotificationListener({
|
|
@@ -321,7 +321,7 @@ export const useCourierPush = (props: UseCourierPushProps = {}): CourierPushCont
|
|
|
321
321
|
// Set the presentation options
|
|
322
322
|
const options = props.iOSForegroundPresentationOptions;
|
|
323
323
|
if (options) {
|
|
324
|
-
context.push
|
|
324
|
+
context.push.iOSForegroundPresentationOptions(options);
|
|
325
325
|
}
|
|
326
326
|
|
|
327
327
|
context.push.start();
|
|
@@ -346,10 +346,10 @@ export const useCourierInbox = (props: UseCourierInboxProps = {}): CourierInboxC
|
|
|
346
346
|
// Set the initial pagination limit if needed
|
|
347
347
|
const limit = props.paginationLimit;
|
|
348
348
|
if (limit) {
|
|
349
|
-
context.inbox
|
|
349
|
+
context.inbox.setPaginationLimit(limit);
|
|
350
350
|
}
|
|
351
351
|
|
|
352
|
-
context.inbox
|
|
352
|
+
context.inbox.start();
|
|
353
353
|
|
|
354
354
|
return context.inbox;
|
|
355
355
|
|
package/src/index.tsx
CHANGED
|
@@ -11,6 +11,10 @@ import { CourierInboxListener } from './models/CourierInboxListener';
|
|
|
11
11
|
import { CourierPushListener } from './models/CourierPushListener';
|
|
12
12
|
import { CourierAuthenticationListener } from './models/CourierAuthenticationListener';
|
|
13
13
|
import { InboxMessage } from './models/InboxMessage';
|
|
14
|
+
import { CourierUserPreferences } from './models/CourierUserPreferences';
|
|
15
|
+
import { CourierUserPreferencesTopic } from './models/CourierUserPreferencesTopic';
|
|
16
|
+
import { CourierUserPreferencesChannel } from './models/CourierUserPreferencesChannel';
|
|
17
|
+
import { CourierUserPreferencesStatus } from './models/CourierUserPreferencesStatus';
|
|
14
18
|
|
|
15
19
|
// Exports
|
|
16
20
|
export { CourierInboxView } from './views/CourierInboxView';
|
|
@@ -18,6 +22,8 @@ export { CourierProvider, useCourierAuth, useCourierPush, useCourierInbox } from
|
|
|
18
22
|
export { CourierInboxListener } from './models/CourierInboxListener';
|
|
19
23
|
export { CourierPushListener } from './models/CourierPushListener';
|
|
20
24
|
export { CourierAuthenticationListener } from './models/CourierAuthenticationListener';
|
|
25
|
+
export { CourierUserPreferencesChannel } from './models/CourierUserPreferencesChannel';
|
|
26
|
+
export { CourierUserPreferencesStatus } from './models/CourierUserPreferencesStatus';
|
|
21
27
|
export type iOSForegroundPresentationOptions = 'sound' | 'badge' | 'list' | 'banner';
|
|
22
28
|
|
|
23
29
|
const LINKING_ERROR =
|
|
@@ -379,6 +385,27 @@ class Courier {
|
|
|
379
385
|
CourierReactNativeModules.setInboxPaginationLimit(props.limit);
|
|
380
386
|
}
|
|
381
387
|
|
|
388
|
+
/**
|
|
389
|
+
* Get all available preferences
|
|
390
|
+
*/
|
|
391
|
+
public async getUserPreferences(props?: { paginationCursor: string }): Promise<CourierUserPreferences> {
|
|
392
|
+
return CourierReactNativeModules.getUserPreferences(props?.paginationCursor ?? "");
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Get individual preferences topic
|
|
397
|
+
*/
|
|
398
|
+
public async getUserPreferencesTopic(props: { topicId: string }): Promise<CourierUserPreferencesTopic> {
|
|
399
|
+
return CourierReactNativeModules.getUserPreferencesTopic(props.topicId);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* Update individual preferences topic
|
|
404
|
+
*/
|
|
405
|
+
public async putUserPreferencesTopic(props: { topicId: string, status: CourierUserPreferencesStatus, hasCustomRouting: boolean, customRouting: CourierUserPreferencesChannel[] }): Promise<void> {
|
|
406
|
+
return CourierReactNativeModules.putUserPreferencesTopic(props.topicId, props.status, props.hasCustomRouting, props.customRouting);
|
|
407
|
+
}
|
|
408
|
+
|
|
382
409
|
}
|
|
383
410
|
|
|
384
411
|
export default Courier;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CourierUserPreferencesChannel } from "./CourierUserPreferencesChannel";
|
|
2
|
+
import { CourierUserPreferencesStatus } from "./CourierUserPreferencesStatus";
|
|
3
|
+
|
|
4
|
+
export interface CourierUserPreferencesTopic {
|
|
5
|
+
defaultStatus?: string;
|
|
6
|
+
hasCustomRouting?: string;
|
|
7
|
+
customRouting?: CourierUserPreferencesChannel[];
|
|
8
|
+
status?: CourierUserPreferencesStatus;
|
|
9
|
+
topicId?: string;
|
|
10
|
+
topicName?: string;
|
|
11
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, { useEffect } from "react";
|
|
2
2
|
import { Platform, requireNativeComponent, UIManager, ViewStyle, DeviceEventEmitter, EmitterSubscription } from "react-native";
|
|
3
|
-
import CourierInboxTheme from "
|
|
4
|
-
import { InboxAction } from "
|
|
5
|
-
import { InboxMessage } from "
|
|
3
|
+
import CourierInboxTheme from "../models/CourierInboxTheme";
|
|
4
|
+
import { InboxAction } from "../models/InboxAction";
|
|
5
|
+
import { InboxMessage } from "../models/InboxMessage";
|
|
6
6
|
|
|
7
7
|
type CourierInboxViewProps = {
|
|
8
8
|
theme?: {
|