@trycourier/courier-react-native 1.0.9 → 2.0.0-beta0
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/LICENSE +1 -1
- package/README.md +16 -412
- package/android/build.gradle +48 -83
- package/android/src/main/AndroidManifest.xml +0 -1
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/courierreactnative/CourierReactNativeActivity.kt +10 -10
- package/android/src/main/java/com/courierreactnative/CourierReactNativeModule.kt +146 -137
- package/android/src/main/java/com/courierreactnative/CourierReactNativePackage.kt +1 -3
- package/android/src/main/java/com/courierreactnative/CourierReactNativeViewManager.kt +43 -0
- package/courier-react-native.podspec +12 -4
- package/ios/CourierReactNative-Bridging-Header.h +0 -1
- package/ios/CourierReactNative.xcodeproj/project.pbxproj +4 -4
- package/ios/CourierReactNative.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
- package/ios/CourierReactNativeModule.m +48 -0
- package/ios/{CourierReactNative.swift → CourierReactNativeModule.swift} +165 -45
- package/ios/CourierReactNativeViewManager.m +15 -0
- package/ios/CourierReactNativeViewManager.swift +348 -0
- package/lib/commonjs/index.js +68 -213
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/CourierInboxListener.js +26 -0
- package/lib/commonjs/models/CourierInboxListener.js.map +1 -0
- package/lib/commonjs/models/CourierInboxTheme.js +2 -0
- package/lib/commonjs/models/CourierInboxTheme.js.map +1 -0
- package/lib/commonjs/models/InboxAction.js +2 -0
- package/lib/commonjs/models/InboxAction.js.map +1 -0
- package/lib/commonjs/models/InboxMessage.js +6 -0
- package/lib/commonjs/models/InboxMessage.js.map +1 -0
- package/lib/commonjs/views/CourierInboxView.js +53 -0
- package/lib/commonjs/views/CourierInboxView.js.map +1 -0
- package/lib/module/index.js +62 -212
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/CourierInboxListener.js +18 -0
- package/lib/module/models/CourierInboxListener.js.map +1 -0
- package/lib/module/models/CourierInboxTheme.js +2 -0
- package/lib/module/models/CourierInboxTheme.js.map +1 -0
- package/lib/module/models/InboxAction.js +2 -0
- package/lib/module/models/InboxAction.js.map +1 -0
- package/lib/module/models/InboxMessage.js +2 -0
- package/lib/module/models/InboxMessage.js.map +1 -0
- package/lib/module/views/CourierInboxView.js +45 -0
- package/lib/module/views/CourierInboxView.js.map +1 -0
- package/lib/typescript/index.d.ts +34 -92
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/models/CourierInboxListener.d.ts +9 -0
- package/lib/typescript/models/CourierInboxListener.d.ts.map +1 -0
- package/lib/typescript/models/CourierInboxTheme.d.ts +34 -0
- package/lib/typescript/models/CourierInboxTheme.d.ts.map +1 -0
- package/lib/typescript/models/InboxAction.d.ts +8 -0
- package/lib/typescript/models/InboxAction.d.ts.map +1 -0
- package/lib/typescript/models/InboxMessage.d.ts +18 -0
- package/lib/typescript/models/InboxMessage.d.ts.map +1 -0
- package/lib/typescript/views/CourierInboxView.d.ts +16 -0
- package/lib/typescript/views/CourierInboxView.d.ts.map +1 -0
- package/package.json +61 -44
- package/src/index.tsx +188 -0
- package/src/models/CourierInboxListener.tsx +25 -0
- package/src/models/CourierInboxTheme.tsx +30 -0
- package/src/models/InboxAction.tsx +5 -0
- package/src/models/InboxMessage.tsx +16 -0
- package/src/views/CourierInboxView.tsx +85 -0
- package/android/.gradle/7.1/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.1/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/7.1/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/7.1/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.1/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/7.1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.1/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.gradle/checksums/checksums.lock +0 -0
- package/android/.gradle/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/.idea/compiler.xml +0 -6
- package/android/.idea/gradle.xml +0 -17
- package/android/.idea/jarRepositories.xml +0 -35
- package/android/.idea/misc.xml +0 -10
- package/android/.idea/vcs.xml +0 -6
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +0 -5
- package/android/gradlew +0 -185
- package/android/gradlew.bat +0 -89
- package/android/local.properties +0 -8
- package/android/src/main/java/com/courierreactnative/NotificationPermissionStatus.kt +0 -6
- package/ios/CourierReactNative.m +0 -52
- package/ios/CourierReactNativeDelegate.h +0 -20
- package/ios/CourierReactNativeDelegate.m +0 -125
- package/src/index.ts +0 -337
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAuB5D,cAAM,OAAO;;YAUG,WAAW;IAazB,OAAO,CAAC,YAAY,CAAS;IAE7B,OAAO,CAAC,aAAa,CAAkC;IAEvD;;;;OAIG;IACU,cAAc,CAAC,WAAW,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAmBnE,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,EAAE,MAAM,IAAI,CAAC;QAAC,OAAO,EAAE,MAAM,IAAI,CAAC;QAAC,iBAAiB,EAAE,CAAC,QAAQ,EAAE,YAAY,EAAE,KAAK,IAAI,CAAA;KAAE,GAAG,oBAAoB;IAkCxJ,mBAAmB,CAAC,KAAK,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM;CAIlE;;AAED,wBAA6B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { EmitterSubscription } from "react-native";
|
|
2
|
+
export declare class CourierInboxListener {
|
|
3
|
+
listenerId?: string;
|
|
4
|
+
onInitialLoad?: EmitterSubscription;
|
|
5
|
+
onError?: EmitterSubscription;
|
|
6
|
+
onMessagesChanged?: EmitterSubscription;
|
|
7
|
+
remove(): void;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=CourierInboxListener.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CourierInboxListener.d.ts","sourceRoot":"","sources":["../../../src/models/CourierInboxListener.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAGlD,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"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface CourierInboxFont {
|
|
2
|
+
family?: string;
|
|
3
|
+
size?: number;
|
|
4
|
+
color?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface CourierInboxButtonStyles {
|
|
7
|
+
font?: CourierInboxFont;
|
|
8
|
+
backgroundColor?: string;
|
|
9
|
+
cornerRadius?: number;
|
|
10
|
+
}
|
|
11
|
+
export default interface CourierInboxTheme {
|
|
12
|
+
unreadIndicatorBarColor?: string;
|
|
13
|
+
loadingIndicatorColor?: string;
|
|
14
|
+
titleFont?: CourierInboxFont;
|
|
15
|
+
timeFont?: CourierInboxFont;
|
|
16
|
+
bodyFont?: CourierInboxFont;
|
|
17
|
+
detailTitleFont?: CourierInboxFont;
|
|
18
|
+
buttonStyles?: CourierInboxButtonStyles;
|
|
19
|
+
iOS?: {
|
|
20
|
+
messageAnimationStyle?: 'fade' | 'right' | 'left' | 'top' | 'bottom' | 'none' | 'middle' | 'automatic';
|
|
21
|
+
cellStyles?: {
|
|
22
|
+
separatorStyle?: 'none' | 'singleLine' | 'singleLineEtched';
|
|
23
|
+
separatorInsets?: {
|
|
24
|
+
top?: number;
|
|
25
|
+
left?: number;
|
|
26
|
+
bottom?: number;
|
|
27
|
+
right?: number;
|
|
28
|
+
};
|
|
29
|
+
separatorColor?: string;
|
|
30
|
+
selectionStyle?: 'none' | 'blue' | 'gray' | 'default';
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=CourierInboxTheme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CourierInboxTheme.d.ts","sourceRoot":"","sources":["../../../src/models/CourierInboxTheme.tsx"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,wBAAwB;IACvC,IAAI,CAAC,EAAE,gBAAgB,CAAA;IACvB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,CAAC,OAAO,WAAW,iBAAiB;IACxC,uBAAuB,CAAC,EAAE,MAAM,CAAA;IAChC,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,SAAS,CAAC,EAAE,gBAAgB,CAAA;IAC5B,QAAQ,CAAC,EAAE,gBAAgB,CAAA;IAC3B,QAAQ,CAAC,EAAE,gBAAgB,CAAA;IAC3B,eAAe,CAAC,EAAE,gBAAgB,CAAA;IAClC,YAAY,CAAC,EAAE,wBAAwB,CAAA;IACvC,GAAG,CAAC,EAAE;QACJ,qBAAqB,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,WAAW,CAAC;QACvG,UAAU,CAAC,EAAE;YACX,cAAc,CAAC,EAAE,MAAM,GAAG,YAAY,GAAG,kBAAkB,CAAC;YAC5D,eAAe,CAAC,EAAE;gBAAE,GAAG,CAAC,EAAE,MAAM,CAAC;gBAAC,IAAI,CAAC,EAAE,MAAM,CAAC;gBAAC,MAAM,CAAC,EAAE,MAAM,CAAC;gBAAC,KAAK,CAAC,EAAE,MAAM,CAAA;aAAE,CAAC;YACnF,cAAc,CAAC,EAAE,MAAM,CAAC;YACxB,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;SACtD,CAAA;KACF,CAAA;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InboxAction.d.ts","sourceRoot":"","sources":["../../../src/models/InboxAction.tsx"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,IAAI,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,GAAG,IAAI,CAAC;CACtC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { InboxAction } from "./InboxAction";
|
|
2
|
+
export interface InboxMessage {
|
|
3
|
+
messageId: string;
|
|
4
|
+
title?: string | null;
|
|
5
|
+
body?: string | null;
|
|
6
|
+
preview?: string | null;
|
|
7
|
+
created?: string | null;
|
|
8
|
+
actions?: InboxAction[] | null;
|
|
9
|
+
data?: {
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
} | null;
|
|
12
|
+
read?: boolean | null;
|
|
13
|
+
opened?: boolean | null;
|
|
14
|
+
archived?: boolean | null;
|
|
15
|
+
subtitle?: string | null;
|
|
16
|
+
time?: string;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=InboxMessage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InboxMessage.d.ts","sourceRoot":"","sources":["../../../src/models/InboxMessage.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,CAAC,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC;IAC/B,IAAI,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,GAAG,IAAI,CAAC;IACrC,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACtB,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,GAAG,IAAI,CAAA;IACzB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ViewStyle } from "react-native";
|
|
3
|
+
import CourierInboxTheme from "src/models/CourierInboxTheme";
|
|
4
|
+
import { InboxAction } from "src/models/InboxAction";
|
|
5
|
+
import { InboxMessage } from "src/models/InboxMessage";
|
|
6
|
+
type CourierInboxViewProps = {
|
|
7
|
+
lightTheme?: CourierInboxTheme;
|
|
8
|
+
darkTheme?: CourierInboxTheme;
|
|
9
|
+
onClickInboxMessageAtIndex?: (message: InboxMessage, index: number) => void;
|
|
10
|
+
onClickInboxActionForMessageAtIndex?: (action: InboxAction, message: InboxMessage, index: number) => void;
|
|
11
|
+
onScrollInbox?: (offsetY: number, offsetX: number) => void;
|
|
12
|
+
style?: ViewStyle;
|
|
13
|
+
};
|
|
14
|
+
export declare const CourierInboxView: (props: CourierInboxViewProps) => React.JSX.Element;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=CourierInboxView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CourierInboxView.d.ts","sourceRoot":"","sources":["../../../src/views/CourierInboxView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAA+C,SAAS,EAAE,MAAM,cAAc,CAAC;AACtF,OAAO,iBAAiB,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,KAAK,qBAAqB,GAAG;IAC3B,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAC/B,SAAS,CAAC,EAAE,iBAAiB,CAAC;IAC9B,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,sBAsD5D,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trycourier/courier-react-native",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.0.0-beta0",
|
|
4
|
+
"description": "Inbox & Push Notifications for React Native",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
7
7
|
"types": "lib/typescript/index.d.ts",
|
|
@@ -13,24 +13,30 @@
|
|
|
13
13
|
"android",
|
|
14
14
|
"ios",
|
|
15
15
|
"cpp",
|
|
16
|
-
"
|
|
16
|
+
"*.podspec",
|
|
17
17
|
"!lib/typescript/example",
|
|
18
|
-
"!android/build",
|
|
19
18
|
"!ios/build",
|
|
19
|
+
"!android/build",
|
|
20
|
+
"!android/gradle",
|
|
21
|
+
"!android/gradlew",
|
|
22
|
+
"!android/gradlew.bat",
|
|
23
|
+
"!android/local.properties",
|
|
20
24
|
"!**/__tests__",
|
|
21
25
|
"!**/__fixtures__",
|
|
22
|
-
"!**/__mocks__"
|
|
26
|
+
"!**/__mocks__",
|
|
27
|
+
"!**/.*"
|
|
23
28
|
],
|
|
24
29
|
"scripts": {
|
|
25
30
|
"test": "jest",
|
|
26
|
-
"
|
|
31
|
+
"typecheck": "tsc --noEmit",
|
|
27
32
|
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
28
|
-
"
|
|
33
|
+
"prepack": "bob build",
|
|
29
34
|
"release": "release-it",
|
|
30
35
|
"example": "yarn --cwd example",
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
36
|
+
"build:android": "cd example/android && ./gradlew assembleDebug --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a",
|
|
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
|
+
"bootstrap": "yarn example && yarn install && yarn example pods",
|
|
39
|
+
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build"
|
|
34
40
|
},
|
|
35
41
|
"keywords": [
|
|
36
42
|
"react-native",
|
|
@@ -38,7 +44,7 @@
|
|
|
38
44
|
"android"
|
|
39
45
|
],
|
|
40
46
|
"repository": "https://github.com/trycourier/courier-react-native",
|
|
41
|
-
"author": "
|
|
47
|
+
"author": "mikemilla <mike@mikemiller.design> (https://github.com/mikemilla)",
|
|
42
48
|
"license": "MIT",
|
|
43
49
|
"bugs": {
|
|
44
50
|
"url": "https://github.com/trycourier/courier-react-native/issues"
|
|
@@ -48,33 +54,27 @@
|
|
|
48
54
|
"registry": "https://registry.npmjs.org/"
|
|
49
55
|
},
|
|
50
56
|
"devDependencies": {
|
|
51
|
-
"@babel/eslint-parser": "^7.18.2",
|
|
52
57
|
"@commitlint/config-conventional": "^17.0.2",
|
|
53
|
-
"@
|
|
58
|
+
"@evilmartians/lefthook": "^1.2.2",
|
|
59
|
+
"@react-native-community/eslint-config": "^3.0.2",
|
|
54
60
|
"@release-it/conventional-changelog": "^5.0.0",
|
|
55
61
|
"@types/jest": "^28.1.2",
|
|
56
62
|
"@types/react": "~17.0.21",
|
|
57
|
-
"@types/react-native": "0.
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"cz-conventional-changelog": "^3.3.0",
|
|
62
|
-
"eslint": "^8.27.0",
|
|
63
|
-
"eslint-config-airbnb": "^19.0.4",
|
|
63
|
+
"@types/react-native": "0.70.0",
|
|
64
|
+
"commitlint": "^17.0.2",
|
|
65
|
+
"del-cli": "^5.0.0",
|
|
66
|
+
"eslint": "^8.4.1",
|
|
64
67
|
"eslint-config-prettier": "^8.5.0",
|
|
65
|
-
"eslint-plugin-
|
|
66
|
-
"eslint-plugin-jsx-a11y": "^6.6.1",
|
|
67
|
-
"eslint-plugin-prettier": "^4.2.1",
|
|
68
|
-
"eslint-plugin-react": "^7.31.10",
|
|
68
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
69
69
|
"jest": "^28.1.1",
|
|
70
|
-
"lefthook": "^1.2.0",
|
|
71
70
|
"pod-install": "^0.1.0",
|
|
72
|
-
"prettier": "^2.
|
|
73
|
-
"react": "
|
|
74
|
-
"react-native": "0.
|
|
75
|
-
"react-native-builder-bob": "^0.
|
|
71
|
+
"prettier": "^2.0.5",
|
|
72
|
+
"react": "18.2.0",
|
|
73
|
+
"react-native": "0.72.4",
|
|
74
|
+
"react-native-builder-bob": "^0.21.3",
|
|
76
75
|
"release-it": "^15.0.0",
|
|
77
|
-
"
|
|
76
|
+
"turbo": "^1.10.7",
|
|
77
|
+
"typescript": "^5.0.2"
|
|
78
78
|
},
|
|
79
79
|
"resolutions": {
|
|
80
80
|
"@types/react": "17.0.21"
|
|
@@ -83,14 +83,15 @@
|
|
|
83
83
|
"react": "*",
|
|
84
84
|
"react-native": "*"
|
|
85
85
|
},
|
|
86
|
+
"engines": {
|
|
87
|
+
"node": ">= 16.0.0"
|
|
88
|
+
},
|
|
89
|
+
"packageManager": "^yarn@1.22.15",
|
|
86
90
|
"jest": {
|
|
87
91
|
"preset": "react-native",
|
|
88
92
|
"modulePathIgnorePatterns": [
|
|
89
93
|
"<rootDir>/example/node_modules",
|
|
90
94
|
"<rootDir>/lib/"
|
|
91
|
-
],
|
|
92
|
-
"setupFiles": [
|
|
93
|
-
"./src/__mocks__/native-module-bridge.js"
|
|
94
95
|
]
|
|
95
96
|
},
|
|
96
97
|
"commitlint": {
|
|
@@ -115,14 +116,36 @@
|
|
|
115
116
|
}
|
|
116
117
|
}
|
|
117
118
|
},
|
|
119
|
+
"eslintConfig": {
|
|
120
|
+
"root": true,
|
|
121
|
+
"extends": [
|
|
122
|
+
"@react-native-community",
|
|
123
|
+
"prettier"
|
|
124
|
+
],
|
|
125
|
+
"rules": {
|
|
126
|
+
"prettier/prettier": [
|
|
127
|
+
"error",
|
|
128
|
+
{
|
|
129
|
+
"quoteProps": "consistent",
|
|
130
|
+
"singleQuote": true,
|
|
131
|
+
"tabWidth": 2,
|
|
132
|
+
"trailingComma": "off",
|
|
133
|
+
"useTabs": false
|
|
134
|
+
}
|
|
135
|
+
]
|
|
136
|
+
}
|
|
137
|
+
},
|
|
118
138
|
"eslintIgnore": [
|
|
119
139
|
"node_modules/",
|
|
120
|
-
"lib/"
|
|
121
|
-
"**/babel.config.**",
|
|
122
|
-
"**/metro.config.**",
|
|
123
|
-
"**/react-native.config.**",
|
|
124
|
-
"**/scripts/**"
|
|
140
|
+
"lib/"
|
|
125
141
|
],
|
|
142
|
+
"prettier": {
|
|
143
|
+
"quoteProps": "consistent",
|
|
144
|
+
"singleQuote": true,
|
|
145
|
+
"tabWidth": 2,
|
|
146
|
+
"trailingComma": "es5",
|
|
147
|
+
"useTabs": false
|
|
148
|
+
},
|
|
126
149
|
"react-native-builder-bob": {
|
|
127
150
|
"source": "src",
|
|
128
151
|
"output": "lib",
|
|
@@ -136,11 +159,5 @@
|
|
|
136
159
|
}
|
|
137
160
|
]
|
|
138
161
|
]
|
|
139
|
-
},
|
|
140
|
-
"dependencies": {},
|
|
141
|
-
"config": {
|
|
142
|
-
"commitizen": {
|
|
143
|
-
"path": "./node_modules/cz-conventional-changelog"
|
|
144
|
-
}
|
|
145
162
|
}
|
|
146
163
|
}
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import {
|
|
2
|
+
NativeModules,
|
|
3
|
+
NativeEventEmitter,
|
|
4
|
+
EmitterSubscription,
|
|
5
|
+
Platform,
|
|
6
|
+
} from 'react-native';
|
|
7
|
+
import { CourierInboxListener } from './models/CourierInboxListener';
|
|
8
|
+
import { InboxMessage } from './models/InboxMessage';
|
|
9
|
+
|
|
10
|
+
export { CourierInboxView } from './views/CourierInboxView';
|
|
11
|
+
|
|
12
|
+
const LINKING_ERROR =
|
|
13
|
+
`The package 'courier-react-native' doesn't seem to be linked. Make sure: \n\n` +
|
|
14
|
+
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
|
|
15
|
+
'- You rebuilt the app after installing the package\n' +
|
|
16
|
+
'- You are not using Expo Go\n';
|
|
17
|
+
|
|
18
|
+
const CourierReactNativeModules = NativeModules.CourierReactNativeModule
|
|
19
|
+
? NativeModules.CourierReactNativeModule
|
|
20
|
+
: new Proxy(
|
|
21
|
+
{},
|
|
22
|
+
{
|
|
23
|
+
get() {
|
|
24
|
+
throw new Error(LINKING_ERROR);
|
|
25
|
+
},
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const CourierEventEmitter = new NativeEventEmitter(
|
|
30
|
+
NativeModules.CourierReactNativeModule
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
class Courier {
|
|
34
|
+
|
|
35
|
+
public constructor() {
|
|
36
|
+
|
|
37
|
+
// Sets the initial SDK values
|
|
38
|
+
// Defaults to React Native level debugging
|
|
39
|
+
// and will show all foreground notification styles in iOS
|
|
40
|
+
this.setDefaults();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
private async setDefaults() {
|
|
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
|
+
|
|
56
|
+
private _isDebugging = false;
|
|
57
|
+
|
|
58
|
+
private debugListener: EmitterSubscription | undefined;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Tells native Courier SDKs to show or hide logs.
|
|
62
|
+
* Defaults to the React __DEV__ mode
|
|
63
|
+
* @example Courier.setIsDebugging(true)
|
|
64
|
+
*/
|
|
65
|
+
public async setIsDebugging(isDebugging: boolean): Promise<boolean> {
|
|
66
|
+
|
|
67
|
+
// Remove the existing listener if needed
|
|
68
|
+
this.debugListener?.remove();
|
|
69
|
+
|
|
70
|
+
// Set a new listener
|
|
71
|
+
// listener needs to be registered first to catch the event
|
|
72
|
+
if (isDebugging) {
|
|
73
|
+
this.debugListener = CourierEventEmitter.addListener('courierDebugEvent', event => {
|
|
74
|
+
console.log('\x1b[36m%s\x1b[0m', 'COURIER', event);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
this._isDebugging = await CourierReactNativeModules.setDebugMode(isDebugging);
|
|
79
|
+
|
|
80
|
+
return this._isDebugging;
|
|
81
|
+
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
get isDebugging(): boolean {
|
|
85
|
+
return this._isDebugging;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Returns the current user id stored in local native storage
|
|
90
|
+
* @example const userId = await Courier.userId
|
|
91
|
+
*/
|
|
92
|
+
get userId(): Promise<string | undefined> {
|
|
93
|
+
return CourierReactNativeModules.getUserId();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Signs user in and persists signin in between sessions
|
|
98
|
+
* using native level storage apis
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```
|
|
102
|
+
*await Courier.signIn({
|
|
103
|
+
accessToken: YOUR_COURIER_GENERATED_JWT,
|
|
104
|
+
clientKey: YOUR_CLIENT_KEY,
|
|
105
|
+
userId: YOUR_USER_ID,
|
|
106
|
+
})
|
|
107
|
+
* ```
|
|
108
|
+
* Your access token should be generated using this endpoint
|
|
109
|
+
* that is requested from your backend
|
|
110
|
+
* https://www.courier.com/docs/reference/auth/issue-token/
|
|
111
|
+
*/
|
|
112
|
+
public signIn(props: { accessToken: string, clientKey?: string, userId: string }): Promise<void> {
|
|
113
|
+
return CourierReactNativeModules.signIn(props.accessToken, props.clientKey ?? null, props.userId);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* TODO
|
|
118
|
+
* @param props
|
|
119
|
+
* @returns
|
|
120
|
+
*/
|
|
121
|
+
public readMessage(props: { messageId: string }): Promise<void> {
|
|
122
|
+
return CourierReactNativeModules.readMessage(props.messageId);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* TODO
|
|
127
|
+
* @param props
|
|
128
|
+
* @returns
|
|
129
|
+
*/
|
|
130
|
+
public unreadMessage(props: { messageId: string }): Promise<void> {
|
|
131
|
+
return CourierReactNativeModules.unreadMessage(props.messageId);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* TODO
|
|
136
|
+
* @param props
|
|
137
|
+
* @returns
|
|
138
|
+
*/
|
|
139
|
+
public readAllInboxMessages(): Promise<void> {
|
|
140
|
+
return CourierReactNativeModules.readAllInboxMessages();
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* TODO
|
|
145
|
+
* @param props
|
|
146
|
+
* @returns
|
|
147
|
+
*/
|
|
148
|
+
public addInboxListener(props: { onInitialLoad: () => void, onError: () => void, onMessagesChanged: (messages: InboxMessage[]) => void }): CourierInboxListener {
|
|
149
|
+
|
|
150
|
+
// Create the initial listeners
|
|
151
|
+
const inboxListener = new CourierInboxListener();
|
|
152
|
+
|
|
153
|
+
if (props.onInitialLoad) {
|
|
154
|
+
inboxListener.onInitialLoad = CourierEventEmitter.addListener('inboxInitialLoad', () => {
|
|
155
|
+
props.onInitialLoad!()
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (props.onError) {
|
|
160
|
+
inboxListener.onError = CourierEventEmitter.addListener('inboxError', event => {
|
|
161
|
+
console.log(event)
|
|
162
|
+
props.onError!()
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (props.onMessagesChanged) {
|
|
167
|
+
inboxListener.onMessagesChanged = CourierEventEmitter.addListener('inboxMessagesChanged', event => {
|
|
168
|
+
console.log('onMessagesChanged')
|
|
169
|
+
console.log(event)
|
|
170
|
+
props.onMessagesChanged!(
|
|
171
|
+
event.messages
|
|
172
|
+
)
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
inboxListener.listenerId = CourierReactNativeModules.addInboxListener(null);
|
|
177
|
+
|
|
178
|
+
return inboxListener;
|
|
179
|
+
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
public removeInboxListener(props: { listenerId: string }): string {
|
|
183
|
+
return CourierReactNativeModules.removeInboxListener(props.listenerId);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export default new Courier();
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { EmitterSubscription } from "react-native"
|
|
2
|
+
import Courier from 'courier-react-native';
|
|
3
|
+
|
|
4
|
+
export class CourierInboxListener {
|
|
5
|
+
|
|
6
|
+
public listenerId?: string
|
|
7
|
+
public onInitialLoad?: EmitterSubscription
|
|
8
|
+
public onError?: EmitterSubscription
|
|
9
|
+
public onMessagesChanged?: EmitterSubscription
|
|
10
|
+
|
|
11
|
+
public remove() {
|
|
12
|
+
|
|
13
|
+
// Remove the native inbox listener
|
|
14
|
+
if (this.listenerId) {
|
|
15
|
+
Courier.removeInboxListener({ listenerId: this.listenerId });
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Remove the emitters
|
|
19
|
+
this.onInitialLoad?.remove();
|
|
20
|
+
this.onError?.remove();
|
|
21
|
+
this.onMessagesChanged?.remove();
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface CourierInboxFont {
|
|
2
|
+
family?: string
|
|
3
|
+
size?: number
|
|
4
|
+
color?: string
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface CourierInboxButtonStyles {
|
|
8
|
+
font?: CourierInboxFont
|
|
9
|
+
backgroundColor?: string
|
|
10
|
+
cornerRadius?: number
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default interface CourierInboxTheme {
|
|
14
|
+
unreadIndicatorBarColor?: string
|
|
15
|
+
loadingIndicatorColor?: string
|
|
16
|
+
titleFont?: CourierInboxFont
|
|
17
|
+
timeFont?: CourierInboxFont
|
|
18
|
+
bodyFont?: CourierInboxFont
|
|
19
|
+
detailTitleFont?: CourierInboxFont
|
|
20
|
+
buttonStyles?: CourierInboxButtonStyles
|
|
21
|
+
iOS?: {
|
|
22
|
+
messageAnimationStyle?: 'fade' | 'right' | 'left' | 'top' | 'bottom' | 'none' | 'middle' | 'automatic',
|
|
23
|
+
cellStyles?: {
|
|
24
|
+
separatorStyle?: 'none' | 'singleLine' | 'singleLineEtched',
|
|
25
|
+
separatorInsets?: { top?: number, left?: number, bottom?: number, right?: number },
|
|
26
|
+
separatorColor?: string,
|
|
27
|
+
selectionStyle?: 'none' | 'blue' | 'gray' | 'default'
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { InboxAction } from "./InboxAction";
|
|
2
|
+
|
|
3
|
+
export interface InboxMessage {
|
|
4
|
+
messageId: string;
|
|
5
|
+
title?: string | null;
|
|
6
|
+
body?: string | null;
|
|
7
|
+
preview?: string | null;
|
|
8
|
+
created?: string | null;
|
|
9
|
+
actions?: InboxAction[] | null;
|
|
10
|
+
data?: { [key: string]: any } | null;
|
|
11
|
+
read?: boolean | null;
|
|
12
|
+
opened?: boolean | null;
|
|
13
|
+
archived?: boolean | null
|
|
14
|
+
subtitle?: string | null;
|
|
15
|
+
time?: string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Platform, requireNativeComponent, UIManager, ViewStyle } from "react-native";
|
|
3
|
+
import CourierInboxTheme from "src/models/CourierInboxTheme";
|
|
4
|
+
import { InboxAction } from "src/models/InboxAction";
|
|
5
|
+
import { InboxMessage } from "src/models/InboxMessage";
|
|
6
|
+
|
|
7
|
+
type CourierInboxViewProps = {
|
|
8
|
+
lightTheme?: CourierInboxTheme;
|
|
9
|
+
darkTheme?: CourierInboxTheme;
|
|
10
|
+
onClickInboxMessageAtIndex?: (message: InboxMessage, index: number) => void;
|
|
11
|
+
onClickInboxActionForMessageAtIndex?: (action: InboxAction, message: InboxMessage, index: number) => void;
|
|
12
|
+
onScrollInbox?: (offsetY: number, offsetX: number) => void;
|
|
13
|
+
style?: ViewStyle;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const ComponentName = 'CourierReactNativeView';
|
|
17
|
+
|
|
18
|
+
const LINKING_ERROR =
|
|
19
|
+
`The package 'courier-react-native' doesn't seem to be linked. Make sure: \n\n` +
|
|
20
|
+
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
|
|
21
|
+
'- You rebuilt the app after installing the package\n' +
|
|
22
|
+
'- You are not using Expo Go\n';
|
|
23
|
+
|
|
24
|
+
const CourierInbox =
|
|
25
|
+
UIManager.getViewManagerConfig(ComponentName) != null
|
|
26
|
+
? requireNativeComponent<CourierInboxViewProps>(ComponentName)
|
|
27
|
+
: () => {
|
|
28
|
+
throw new Error(LINKING_ERROR);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const CourierInboxView = (props: CourierInboxViewProps) => {
|
|
32
|
+
|
|
33
|
+
const onClickInboxMessageAtIndex = (event: any) => {
|
|
34
|
+
|
|
35
|
+
// Parse the native event data
|
|
36
|
+
if (props.onClickInboxMessageAtIndex) {
|
|
37
|
+
|
|
38
|
+
const index = event.nativeEvent["index"]
|
|
39
|
+
const message = event.nativeEvent["message"] as InboxMessage
|
|
40
|
+
|
|
41
|
+
props.onClickInboxMessageAtIndex(message, index)
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const onClickInboxActionForMessageAtIndex = (event: any) => {
|
|
48
|
+
|
|
49
|
+
// Parse the native event data
|
|
50
|
+
if (props.onClickInboxActionForMessageAtIndex) {
|
|
51
|
+
|
|
52
|
+
const index = event.nativeEvent["index"]
|
|
53
|
+
const action = event.nativeEvent["action"] as InboxAction
|
|
54
|
+
const message = event.nativeEvent["message"] as InboxMessage
|
|
55
|
+
|
|
56
|
+
props.onClickInboxActionForMessageAtIndex(action, message, index)
|
|
57
|
+
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const onScrollInbox = (event: any) => {
|
|
63
|
+
|
|
64
|
+
// Parse the native event data
|
|
65
|
+
if (props.onScrollInbox) {
|
|
66
|
+
|
|
67
|
+
const contentOffset = event.nativeEvent["contentOffset"]
|
|
68
|
+
props.onScrollInbox(contentOffset["y"], contentOffset["x"])
|
|
69
|
+
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<CourierInbox
|
|
76
|
+
lightTheme={props.lightTheme}
|
|
77
|
+
darkTheme={props.darkTheme}
|
|
78
|
+
onClickInboxMessageAtIndex={onClickInboxMessageAtIndex}
|
|
79
|
+
onClickInboxActionForMessageAtIndex={onClickInboxActionForMessageAtIndex}
|
|
80
|
+
onScrollInbox={onScrollInbox}
|
|
81
|
+
style={props.style}
|
|
82
|
+
/>
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
}
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|