react-native-mobile-chat 0.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.
Files changed (96) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +235 -0
  3. package/android/build.gradle +77 -0
  4. package/android/gradle.properties +5 -0
  5. package/android/src/main/AndroidManifest.xml +4 -0
  6. package/android/src/main/java/com/appchat/AppChatModule.java +58 -0
  7. package/android/src/main/java/com/appchat/AppChatPackage.java +28 -0
  8. package/ios/AppChat.h +12 -0
  9. package/ios/AppChat.mm +67 -0
  10. package/ios/AppChat.xcodeproj/project.pbxproj +274 -0
  11. package/ios/AppChat.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
  12. package/lib/commonjs/assets/images/arrow_left.png +0 -0
  13. package/lib/commonjs/assets/images/arrow_left_black.png +0 -0
  14. package/lib/commonjs/common/constants/index.js +20 -0
  15. package/lib/commonjs/common/constants/index.js.map +1 -0
  16. package/lib/commonjs/common/utils/index.js +53 -0
  17. package/lib/commonjs/common/utils/index.js.map +1 -0
  18. package/lib/commonjs/data/local/index.js +28 -0
  19. package/lib/commonjs/data/local/index.js.map +1 -0
  20. package/lib/commonjs/data/remote/index.js +87 -0
  21. package/lib/commonjs/data/remote/index.js.map +1 -0
  22. package/lib/commonjs/data/static/index.js +35 -0
  23. package/lib/commonjs/data/static/index.js.map +1 -0
  24. package/lib/commonjs/index.js +46 -0
  25. package/lib/commonjs/index.js.map +1 -0
  26. package/lib/commonjs/native/component/WebView.js +16 -0
  27. package/lib/commonjs/native/component/WebView.js.map +1 -0
  28. package/lib/commonjs/native/module/index.js +18 -0
  29. package/lib/commonjs/native/module/index.js.map +1 -0
  30. package/lib/commonjs/presentation/component/AppChatComponent.js +236 -0
  31. package/lib/commonjs/presentation/component/AppChatComponent.js.map +1 -0
  32. package/lib/commonjs/presentation/initialization/index.js +148 -0
  33. package/lib/commonjs/presentation/initialization/index.js.map +1 -0
  34. package/lib/commonjs/presentation/notification/index.js +50 -0
  35. package/lib/commonjs/presentation/notification/index.js.map +1 -0
  36. package/lib/module/assets/images/arrow_left.png +0 -0
  37. package/lib/module/assets/images/arrow_left_black.png +0 -0
  38. package/lib/module/common/constants/index.js +13 -0
  39. package/lib/module/common/constants/index.js.map +1 -0
  40. package/lib/module/common/utils/index.js +45 -0
  41. package/lib/module/common/utils/index.js.map +1 -0
  42. package/lib/module/data/local/index.js +20 -0
  43. package/lib/module/data/local/index.js.map +1 -0
  44. package/lib/module/data/remote/index.js +75 -0
  45. package/lib/module/data/remote/index.js.map +1 -0
  46. package/lib/module/data/static/index.js +28 -0
  47. package/lib/module/data/static/index.js.map +1 -0
  48. package/lib/module/index.js +5 -0
  49. package/lib/module/index.js.map +1 -0
  50. package/lib/module/native/component/WebView.js +10 -0
  51. package/lib/module/native/component/WebView.js.map +1 -0
  52. package/lib/module/native/module/index.js +11 -0
  53. package/lib/module/native/module/index.js.map +1 -0
  54. package/lib/module/presentation/component/AppChatComponent.js +227 -0
  55. package/lib/module/presentation/component/AppChatComponent.js.map +1 -0
  56. package/lib/module/presentation/initialization/index.js +141 -0
  57. package/lib/module/presentation/initialization/index.js.map +1 -0
  58. package/lib/module/presentation/notification/index.js +41 -0
  59. package/lib/module/presentation/notification/index.js.map +1 -0
  60. package/lib/typescript/common/constants/index.d.ts +13 -0
  61. package/lib/typescript/common/constants/index.d.ts.map +1 -0
  62. package/lib/typescript/common/utils/index.d.ts +15 -0
  63. package/lib/typescript/common/utils/index.d.ts.map +1 -0
  64. package/lib/typescript/data/local/index.d.ts +4 -0
  65. package/lib/typescript/data/local/index.d.ts.map +1 -0
  66. package/lib/typescript/data/remote/index.d.ts +7 -0
  67. package/lib/typescript/data/remote/index.d.ts.map +1 -0
  68. package/lib/typescript/data/static/index.d.ts +23 -0
  69. package/lib/typescript/data/static/index.d.ts.map +1 -0
  70. package/lib/typescript/index.d.ts +5 -0
  71. package/lib/typescript/index.d.ts.map +1 -0
  72. package/lib/typescript/native/component/WebView.d.ts +8 -0
  73. package/lib/typescript/native/component/WebView.d.ts.map +1 -0
  74. package/lib/typescript/native/module/index.d.ts +2 -0
  75. package/lib/typescript/native/module/index.d.ts.map +1 -0
  76. package/lib/typescript/presentation/component/AppChatComponent.d.ts +22 -0
  77. package/lib/typescript/presentation/component/AppChatComponent.d.ts.map +1 -0
  78. package/lib/typescript/presentation/initialization/index.d.ts +2 -0
  79. package/lib/typescript/presentation/initialization/index.d.ts.map +1 -0
  80. package/lib/typescript/presentation/notification/index.d.ts +5 -0
  81. package/lib/typescript/presentation/notification/index.d.ts.map +1 -0
  82. package/package.json +165 -0
  83. package/react-native-app-chat.podspec +35 -0
  84. package/src/assets/images/arrow_left.png +0 -0
  85. package/src/assets/images/arrow_left_black.png +0 -0
  86. package/src/common/constants/index.tsx +12 -0
  87. package/src/common/utils/index.tsx +58 -0
  88. package/src/data/local/index.tsx +23 -0
  89. package/src/data/remote/index.tsx +80 -0
  90. package/src/data/static/index.tsx +28 -0
  91. package/src/index.tsx +11 -0
  92. package/src/native/component/WebView.tsx +10 -0
  93. package/src/native/module/index.tsx +18 -0
  94. package/src/presentation/component/AppChatComponent.tsx +154 -0
  95. package/src/presentation/initialization/index.tsx +149 -0
  96. package/src/presentation/notification/index.tsx +45 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/common/utils/index.tsx"],"names":[],"mappings":"AAOA,KAAK,gBAAgB,GAAG;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,gBAAgB,GAAG,MAAM,CAUpE;AAED,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAOlE;AAED,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM,CAkBxG"}
@@ -0,0 +1,4 @@
1
+ export declare function putString(key: string, value: string): Promise<string>;
2
+ export declare function getString(key: string): Promise<any>;
3
+ export declare function getBundleIdOrPackageName(): Promise<any>;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/data/local/index.tsx"],"names":[],"mappings":"AAEA,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAE3E;AAED,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAQzD;AAED,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,GAAG,CAAC,CAM7D"}
@@ -0,0 +1,7 @@
1
+ export declare function authenticate(clientId: String, clienSecret: String): Promise<Response>;
2
+ export declare function createContact(externalId: any, fullName: any): Promise<Response>;
3
+ export declare function registerFcmToken(fcmToken: any): Promise<Response>;
4
+ export declare function revokeFcmToken(fcmToken: any): Promise<Response>;
5
+ export declare function validateBundleId(bundleId: any): Promise<Response>;
6
+ export declare function getWidgetSetting(): Promise<Response>;
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/data/remote/index.tsx"],"names":[],"mappings":"AAIA,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAS3F;AAED,wBAAsB,aAAa,CAAC,UAAU,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,qBAWjE;AAED,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,GAAG,qBAanD;AAED,wBAAsB,cAAc,CAAC,QAAQ,EAAE,GAAG,qBAajD;AAED,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,GAAG,qBAYnD;AAED,wBAAsB,gBAAgB,sBAOrC"}
@@ -0,0 +1,23 @@
1
+ export declare class AppChatStatic {
2
+ static appChatOpened: boolean;
3
+ static accessToken: string;
4
+ static contactId: string;
5
+ static bundleIdValidation: string;
6
+ static encryptedUrlParams: string;
7
+ static initAppChatResult: string;
8
+ static appChatTheme: {
9
+ bgColorTheme: string;
10
+ bgColorThemeOverlaid: string;
11
+ fontColor: string;
12
+ textHeader: string;
13
+ textDescription: string;
14
+ isAnyEmpty: () => boolean;
15
+ };
16
+ static appId: string;
17
+ static clientId: string;
18
+ static clientSecret: string;
19
+ static externalId: string;
20
+ static fullName: string;
21
+ static fcmToken: string;
22
+ }
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/data/static/index.tsx"],"names":[],"mappings":"AAAA,qBAAa,aAAa;IAExB,MAAM,CAAC,aAAa,UAAQ;IAG5B,MAAM,CAAC,WAAW,SAAK;IACvB,MAAM,CAAC,SAAS,SAAK;IACrB,MAAM,CAAC,kBAAkB,SAAK;IAC9B,MAAM,CAAC,kBAAkB,SAAK;IAC9B,MAAM,CAAC,iBAAiB,SAAK;IAE7B,MAAM,CAAC,YAAY;;;;;;;MAOlB;IAGD,MAAM,CAAC,KAAK,SAAK;IACjB,MAAM,CAAC,QAAQ,SAAK;IACpB,MAAM,CAAC,YAAY,SAAK;IACxB,MAAM,CAAC,UAAU,SAAK;IACtB,MAAM,CAAC,QAAQ,SAAK;IACpB,MAAM,CAAC,QAAQ,SAAK;CACrB"}
@@ -0,0 +1,5 @@
1
+ import AppChatComponent from "./presentation/component/AppChatComponent";
2
+ import { initAppChat } from "./presentation/initialization";
3
+ import { isAppChatOpened, isAppChatPayload, registerNotification, revokeNotification } from "./presentation/notification";
4
+ export { initAppChat as initMobileChat, isAppChatOpened as isMobileChatOpened, isAppChatPayload as isMobileChatPayload, AppChatComponent as MobileChatComponent, registerNotification as registerMobileChatNotification, revokeNotification as revokeMobileChatNotification };
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,2CAA2C,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAC1H,OAAO,EACL,WAAW,IAAI,cAAc,EAC7B,eAAe,IAAI,kBAAkB,EACrC,gBAAgB,IAAI,mBAAmB,EACvC,gBAAgB,IAAI,mBAAmB,EACvC,oBAAoB,IAAI,8BAA8B,EACtD,kBAAkB,IAAI,4BAA4B,EACnD,CAAA"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Composes `WebView`.
3
+ *
4
+ * - url: string
5
+ */
6
+ declare const WebView: import("react-native").HostComponent<unknown>;
7
+ export default WebView;
8
+ //# sourceMappingURL=WebView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WebView.d.ts","sourceRoot":"","sources":["../../../../src/native/component/WebView.tsx"],"names":[],"mappings":"AAEA;;;;EAIE;AACF,QAAA,MAAM,OAAO,+CAA8C,CAAC;AAE5D,eAAe,OAAO,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const AppChatNative: any;
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/native/module/index.tsx"],"names":[],"mappings":"AAQA,eAAO,MAAM,aAAa,KASvB,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { PureComponent, ReactNode } from 'react';
2
+ import { WebViewMessageEvent } from 'react-native-webview';
3
+ type AppChatComponentProps = {
4
+ onBackButtonTapped: () => void;
5
+ };
6
+ export default class AppChatComponent extends PureComponent<AppChatComponentProps> {
7
+ _isMounted: boolean;
8
+ state: {
9
+ isOverlaid: boolean;
10
+ toggleRefresh: boolean;
11
+ };
12
+ constructor(props: AppChatComponentProps);
13
+ _setState: (state: any) => void;
14
+ _requestPermission: (permission: any) => Promise<void>;
15
+ _onAccessTokenExpired: () => Promise<void>;
16
+ _onMessage: (event: WebViewMessageEvent) => void;
17
+ componentDidMount(): void;
18
+ componentWillUnmount(): void;
19
+ render(): ReactNode;
20
+ }
21
+ export {};
22
+ //# sourceMappingURL=AppChatComponent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppChatComponent.d.ts","sourceRoot":"","sources":["../../../../src/presentation/component/AppChatComponent.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,aAAa,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAIlE,OAAgB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAKpE,KAAK,qBAAqB,GAAG;IAC3B,kBAAkB,EAAE,MAAM,IAAI,CAAA;CAC/B,CAAA;AAED,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,aAAa,CAAC,qBAAqB,CAAC;IAEhF,UAAU,UAAQ;IAElB,KAAK;;;MAGJ;gBAEW,KAAK,EAAE,qBAAqB;IAQxC,SAAS,UAAW,GAAG,UAItB;IAED,kBAAkB,eAAsB,GAAG,mBAO1C;IAED,qBAAqB,sBAOpB;IAED,UAAU,uCA8BT;IAED,iBAAiB,IAAI,IAAI;IAazB,oBAAoB,IAAI,IAAI;IAK5B,MAAM,IAAI,SAAS;CAiDpB"}
@@ -0,0 +1,2 @@
1
+ export declare function initAppChat(appId: string, clientId: string, clientSecret: string, externalId: string, fullName: string): Promise<string>;
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/presentation/initialization/index.tsx"],"names":[],"mappings":"AAMA,wBAAsB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,mBAgE5H"}
@@ -0,0 +1,5 @@
1
+ export declare function registerNotification(fcmToken: string): Promise<"FCM token registration success, user can receive notification" | "FCM token registration failed, user can't receive notification" | "FCM token registration : waiting initialization success" | undefined>;
2
+ export declare function revokeNotification(): Promise<"Revoke FCM token success" | "Revoke FCM token failed" | undefined>;
3
+ export declare function isAppChatPayload(payload: any): boolean;
4
+ export declare function isAppChatOpened(): boolean;
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/presentation/notification/index.tsx"],"names":[],"mappings":"AAIA,wBAAsB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,uNAe1D;AAED,wBAAsB,kBAAkB,gFAWvC;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,CAMtD;AAED,wBAAgB,eAAe,IAAI,OAAO,CAEzC"}
package/package.json ADDED
@@ -0,0 +1,165 @@
1
+ {
2
+ "name": "react-native-mobile-chat",
3
+ "version": "0.1.0",
4
+ "description": "React Native Mobile Chat help you to manage customer relationship with customer conversation feature inside your react native app.",
5
+ "main": "lib/commonjs/index",
6
+ "module": "lib/module/index",
7
+ "types": "lib/typescript/index.d.ts",
8
+ "react-native": "src/index",
9
+ "source": "src/index",
10
+ "files": [
11
+ "src",
12
+ "lib",
13
+ "android",
14
+ "ios",
15
+ "cpp",
16
+ "*.podspec",
17
+ "!lib/typescript/example",
18
+ "!ios/build",
19
+ "!android/build",
20
+ "!android/gradle",
21
+ "!android/gradlew",
22
+ "!android/gradlew.bat",
23
+ "!android/local.properties",
24
+ "!**/__tests__",
25
+ "!**/__fixtures__",
26
+ "!**/__mocks__",
27
+ "!**/.*"
28
+ ],
29
+ "scripts": {
30
+ "test": "jest",
31
+ "typecheck": "tsc --noEmit",
32
+ "lint": "eslint \"**/*.{js,ts,tsx}\"",
33
+ "prepack": "bob build",
34
+ "release": "release-it",
35
+ "example": "yarn --cwd example",
36
+ "bootstrap": "yarn example && yarn install && yarn example pods",
37
+ "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build"
38
+ },
39
+ "keywords": [
40
+ "react-native",
41
+ "ios",
42
+ "android"
43
+ ],
44
+ "repository": "https://help-center.qontak.com/hc/en-us/articles/22614405832473-How-to-Integrate-Mobile-Chat-in-Omnichannel-Qontak",
45
+ "author": "Mekari <shalahudin.ayyub@mekari.com> (https://mekari.com/)",
46
+ "license": "MIT",
47
+ "bugs": {
48
+ "url": "https://qontak.com/en-id/contact-us/"
49
+ },
50
+ "homepage": "https://qontak.com",
51
+ "publishConfig": {
52
+ "registry": "https://registry.npmjs.org/"
53
+ },
54
+ "devDependencies": {
55
+ "@commitlint/config-conventional": "^17.0.2",
56
+ "@evilmartians/lefthook": "^1.2.2",
57
+ "@react-native-community/eslint-config": "^3.0.2",
58
+ "@release-it/conventional-changelog": "^5.0.0",
59
+ "@types/crypto-js": "^4.1.1",
60
+ "@types/jest": "^28.1.2",
61
+ "@types/react": "~17.0.21",
62
+ "@types/react-native": "0.70.0",
63
+ "commitlint": "^17.0.2",
64
+ "del-cli": "^5.0.0",
65
+ "eslint": "^8.4.1",
66
+ "eslint-config-prettier": "^8.5.0",
67
+ "eslint-plugin-prettier": "^4.0.0",
68
+ "jest": "^28.1.1",
69
+ "pod-install": "^0.1.0",
70
+ "prettier": "^2.0.5",
71
+ "react": "18.2.0",
72
+ "react-native": "0.72.3",
73
+ "react-native-builder-bob": "^0.20.0",
74
+ "release-it": "^15.0.0",
75
+ "typescript": "^4.5.2"
76
+ },
77
+ "resolutions": {
78
+ "@types/react": "17.0.21"
79
+ },
80
+ "peerDependencies": {
81
+ "react": "*",
82
+ "react-native": "*",
83
+ "react-native-webview": "*"
84
+ },
85
+ "engines": {
86
+ "node": ">= 16.0.0"
87
+ },
88
+ "packageManager": "^yarn@1.22.15",
89
+ "jest": {
90
+ "preset": "react-native",
91
+ "modulePathIgnorePatterns": [
92
+ "<rootDir>/example/node_modules",
93
+ "<rootDir>/lib/"
94
+ ]
95
+ },
96
+ "commitlint": {
97
+ "extends": [
98
+ "@commitlint/config-conventional"
99
+ ]
100
+ },
101
+ "release-it": {
102
+ "git": {
103
+ "commitMessage": "chore: release ${version}",
104
+ "tagName": "v${version}"
105
+ },
106
+ "npm": {
107
+ "publish": true
108
+ },
109
+ "github": {
110
+ "release": true
111
+ },
112
+ "plugins": {
113
+ "@release-it/conventional-changelog": {
114
+ "preset": "angular"
115
+ }
116
+ }
117
+ },
118
+ "eslintConfig": {
119
+ "root": true,
120
+ "extends": [
121
+ "@react-native-community",
122
+ "prettier"
123
+ ],
124
+ "rules": {
125
+ "prettier/prettier": [
126
+ "error",
127
+ {
128
+ "quoteProps": "consistent",
129
+ "singleQuote": true,
130
+ "tabWidth": 2,
131
+ "trailingComma": "es5",
132
+ "useTabs": false
133
+ }
134
+ ]
135
+ }
136
+ },
137
+ "eslintIgnore": [
138
+ "node_modules/",
139
+ "lib/"
140
+ ],
141
+ "prettier": {
142
+ "quoteProps": "consistent",
143
+ "singleQuote": true,
144
+ "tabWidth": 2,
145
+ "trailingComma": "es5",
146
+ "useTabs": false
147
+ },
148
+ "react-native-builder-bob": {
149
+ "source": "src",
150
+ "output": "lib",
151
+ "targets": [
152
+ "commonjs",
153
+ "module",
154
+ [
155
+ "typescript",
156
+ {
157
+ "project": "tsconfig.build.json"
158
+ }
159
+ ]
160
+ ]
161
+ },
162
+ "dependencies": {
163
+ "crypto-js": "^4.1.1"
164
+ }
165
+ }
@@ -0,0 +1,35 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+ folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
5
+
6
+ Pod::Spec.new do |s|
7
+ s.name = "react-native-app-chat"
8
+ s.version = package["version"]
9
+ s.summary = package["description"]
10
+ s.homepage = package["homepage"]
11
+ s.license = package["license"]
12
+ s.authors = package["author"]
13
+
14
+ s.platforms = { :ios => "11.0" }
15
+ s.source = { :git => "https://github.com/sa-ayyub/react-native-app-chat.git", :tag => "#{s.version}" }
16
+
17
+ s.source_files = "ios/**/*.{h,m,mm}"
18
+
19
+ s.dependency "React-Core"
20
+
21
+ # Don't install the dependencies when we run `pod install` in the old architecture.
22
+ if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
23
+ s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
24
+ s.pod_target_xcconfig = {
25
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
26
+ "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
27
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
28
+ }
29
+ s.dependency "React-Codegen"
30
+ s.dependency "RCT-Folly"
31
+ s.dependency "RCTRequired"
32
+ s.dependency "RCTTypeSafety"
33
+ s.dependency "ReactCommon/turbomodule/core"
34
+ end
35
+ end
Binary file
@@ -0,0 +1,12 @@
1
+ export default class Constant {
2
+ static BASE_URL = "https://chat-service.qontak.com"
3
+ static ENCRYPTION_KEY = '9BEBD42CCA16E4A1'
4
+ static ENCRYPTION_IV = 'EC42B71DAA9CA9E5'
5
+ static BASE_URL_WEBVIEW = 'https://mobilechat.qontak.com/'
6
+ static ENCRYPTED_PARAMS_KEY = '?data='
7
+ static BUNDLE_ID_INVALID = "Your app doesn't eligible to access widget.\nAdd your package name or bundle id to integration dashboard via web"
8
+ static WEBVIEW_BACKGROUND_COLOR = '#F1F5F9'
9
+ static WEBVIEW_BACKGROUND_COLOR_OVERLAID = '#4c525b'
10
+ static OVERLAY_COLOR = '#232933'
11
+ static OVERLAY_OPACITY = 0.8
12
+ }
@@ -0,0 +1,58 @@
1
+ import CryptoJS from 'crypto-js'
2
+
3
+
4
+ // Defining KEY and IV, that are being used as the key and initialization vector (IV) for a cryptographic operation
5
+ const KEY = CryptoJS.enc.Utf8.parse('9BEBD42CCA16E4A1')
6
+ const IV = CryptoJS.enc.Utf8.parse('EC42B71DAA9CA9E5')
7
+
8
+ type URLParamsAppChat = {
9
+ access_token: string,
10
+ app_id: string,
11
+ contact_id: string
12
+ }
13
+
14
+ /**
15
+ * It takes a JSON object, converts it to a string, encrypts it, and returns the encrypted string
16
+ * @param data - The data to be encrypted.
17
+ * @returns A string of hexadecimal characters.
18
+ */
19
+ export function getEncryptedUrlParams(data: URLParamsAppChat): string {
20
+ const parsedData = CryptoJS.enc.Utf8.parse(JSON.stringify(data))
21
+
22
+ let encryptedData = CryptoJS.AES.encrypt(parsedData, KEY, {
23
+ iv: IV,
24
+ mode: CryptoJS.mode.ECB,
25
+ padding: CryptoJS.pad.Pkcs7,
26
+ })
27
+
28
+ return encryptedData.ciphertext.toString(CryptoJS.enc.Hex)
29
+ }
30
+
31
+ export function calculateTextColorOutput(mainColor: string): string {
32
+ if (mainColor.length === 7) mainColor = mainColor.substring(1);
33
+ const R = parseInt(mainColor.substring(0, 2), 16);
34
+ const G = parseInt(mainColor.substring(2, 4), 16);
35
+ const B = parseInt(mainColor.substring(4, 6), 16);
36
+ const brightneess = Math.sqrt(R * R * 0.241 + G * G * 0.691 + B * B * 0.068);
37
+ return brightneess < 130 ? "white" : "black";
38
+ }
39
+
40
+ export function getOverlaidColor(mainColor: string, colorOverlay: string, opacityOverlay: number): string {
41
+ if (mainColor.length === 7) mainColor = mainColor.substring(1);
42
+ const R = parseInt(mainColor.substring(0, 2), 16);
43
+ const G = parseInt(mainColor.substring(2, 4), 16);
44
+ const B = parseInt(mainColor.substring(4, 6), 16);
45
+
46
+ if (colorOverlay.length === 7) colorOverlay = colorOverlay.substring(1);
47
+ const overlayR = parseInt(colorOverlay.substring(0, 2), 16);
48
+ const overlayG = parseInt(colorOverlay.substring(2, 4), 16);
49
+ const overlayB = parseInt(colorOverlay.substring(4, 6), 16);
50
+
51
+ const finalColorR = Math.round(R * (1.0 - opacityOverlay) + overlayR * opacityOverlay);
52
+ const finalColorG = Math.round(G * (1.0 - opacityOverlay) + overlayG * opacityOverlay);
53
+ const finalColorB = Math.round(B * (1.0 - opacityOverlay) + overlayB * opacityOverlay);
54
+ const overlaidR = finalColorR < 10 ? `0${finalColorR}` : finalColorR.toString(16)
55
+ const overlaidG = finalColorG < 10 ? `0${finalColorG}` : finalColorG.toString(16)
56
+ const overlaidB = finalColorB < 10 ? `0${finalColorB}` : finalColorB.toString(16)
57
+ return '#' + overlaidR + overlaidG + overlaidB
58
+ }
@@ -0,0 +1,23 @@
1
+ import { AppChatNative } from "../../native/module"
2
+
3
+ export async function putString(key: string, value: string): Promise<string> {
4
+ return await AppChatNative.putString(key, value)
5
+ }
6
+
7
+ export async function getString(key: string): Promise<any> {
8
+ try {
9
+ const value = await AppChatNative.getString(key)
10
+ if (value === 'default_value') return undefined
11
+ else return value
12
+ } catch (error) {
13
+ return Promise.resolve(undefined)
14
+ }
15
+ }
16
+
17
+ export async function getBundleIdOrPackageName(): Promise<any> {
18
+ try {
19
+ return await AppChatNative.getBundleIdOrPackageName()
20
+ } catch (error) {
21
+ return Promise.resolve(undefined)
22
+ }
23
+ }
@@ -0,0 +1,80 @@
1
+ import { Platform } from "react-native"
2
+ import { AppChatStatic } from "../static"
3
+ import Constant from "../../common/constants"
4
+
5
+ export async function authenticate(clientId: String, clienSecret: String): Promise<Response> {
6
+ const formData = new FormData()
7
+ formData.append('grant_type', 'client_credentials')
8
+ formData.append('client_id', clientId)
9
+ formData.append('client_secret', clienSecret)
10
+ return await fetch(`${Constant.BASE_URL}/oauth/token`, {
11
+ method: 'POST',
12
+ body: formData
13
+ })
14
+ }
15
+
16
+ export async function createContact(externalId: any, fullName: any) {
17
+ let formData = new FormData()
18
+ formData.append('external_id', externalId)
19
+ formData.append('full_name', fullName)
20
+ return await fetch(`${Constant.BASE_URL}/api/core/v1/app_chat/${AppChatStatic.appId}/contacts`, {
21
+ headers: {
22
+ Authorization: AppChatStatic.accessToken
23
+ },
24
+ method: 'POST',
25
+ body: formData
26
+ })
27
+ }
28
+
29
+ export async function registerFcmToken(fcmToken: any) {
30
+ let formData = new FormData()
31
+ formData.append('app_id', AppChatStatic.appId)
32
+ formData.append('contact_id', AppChatStatic.contactId)
33
+ formData.append('resource_type', Platform.OS)
34
+ formData.append('token', fcmToken)
35
+ return await fetch(`${Constant.BASE_URL}/api/core/v1/app_chat/${AppChatStatic.appId}/notification_credentials`, {
36
+ headers: {
37
+ Authorization: AppChatStatic.accessToken
38
+ },
39
+ method: 'PUT',
40
+ body: formData
41
+ })
42
+ }
43
+
44
+ export async function revokeFcmToken(fcmToken: any) {
45
+ let formData = new FormData()
46
+ formData.append('app_id', AppChatStatic.appId)
47
+ formData.append('contact_id', AppChatStatic.contactId)
48
+ formData.append('resource_type', 'current')
49
+ formData.append('token', fcmToken)
50
+ return await fetch(`${Constant.BASE_URL}/api/core/v1/app_chat/${AppChatStatic.appId}/notification_credentials`, {
51
+ headers: {
52
+ Authorization: AppChatStatic.accessToken
53
+ },
54
+ method: 'DELETE',
55
+ body: formData
56
+ })
57
+ }
58
+
59
+ export async function validateBundleId(bundleId: any) {
60
+ let formData = new FormData()
61
+ formData.append('app_id', AppChatStatic.appId)
62
+ formData.append('bundle_id', bundleId)
63
+ formData.append('platform', Platform.OS)
64
+ return await fetch(`${Constant.BASE_URL}/api/core/v1/app_chat/${AppChatStatic.appId}/validate_bundle_id`, {
65
+ headers: {
66
+ Authorization: AppChatStatic.accessToken
67
+ },
68
+ method: 'POST',
69
+ body: formData
70
+ })
71
+ }
72
+
73
+ export async function getWidgetSetting() {
74
+ return await fetch(`${Constant.BASE_URL}/api/core/v1/app_chat/${AppChatStatic.appId}/widget_setting`, {
75
+ headers: {
76
+ Authorization: AppChatStatic.accessToken
77
+ },
78
+ method: 'GET'
79
+ })
80
+ }
@@ -0,0 +1,28 @@
1
+ export class AppChatStatic {
2
+ //Based on event
3
+ static appChatOpened = false
4
+
5
+ //Get from init process
6
+ static accessToken = ''
7
+ static contactId = ''
8
+ static bundleIdValidation = ''
9
+ static encryptedUrlParams = ''
10
+ static initAppChatResult = ''
11
+
12
+ static appChatTheme = {
13
+ bgColorTheme: 'grey',
14
+ bgColorThemeOverlaid: 'grey',
15
+ fontColor: 'white',
16
+ textHeader: '',
17
+ textDescription: '',
18
+ isAnyEmpty: () => this.appChatTheme.bgColorTheme == 'grey' || this.appChatTheme.bgColorThemeOverlaid == 'grey' || this.appChatTheme.bgColorTheme == 'white' || this.appChatTheme.textHeader == '' || this.appChatTheme.textDescription == ''
19
+ }
20
+
21
+ //Assigned as parameter by developer
22
+ static appId = ''
23
+ static clientId = ''
24
+ static clientSecret = ''
25
+ static externalId = ''
26
+ static fullName = ''
27
+ static fcmToken = ''
28
+ }
package/src/index.tsx ADDED
@@ -0,0 +1,11 @@
1
+ import AppChatComponent from "./presentation/component/AppChatComponent";
2
+ import { initAppChat } from "./presentation/initialization";
3
+ import { isAppChatOpened, isAppChatPayload, registerNotification, revokeNotification } from "./presentation/notification";
4
+ export {
5
+ initAppChat as initMobileChat,
6
+ isAppChatOpened as isMobileChatOpened,
7
+ isAppChatPayload as isMobileChatPayload,
8
+ AppChatComponent as MobileChatComponent,
9
+ registerNotification as registerMobileChatNotification,
10
+ revokeNotification as revokeMobileChatNotification
11
+ }
@@ -0,0 +1,10 @@
1
+ import { requireNativeComponent } from 'react-native';
2
+
3
+ /**
4
+ * Composes `WebView`.
5
+ *
6
+ * - url: string
7
+ */
8
+ const WebView = requireNativeComponent('RCTAppChatWebView');
9
+
10
+ export default WebView;
@@ -0,0 +1,18 @@
1
+ import { NativeModules, Platform } from 'react-native';
2
+
3
+ const LINKING_ERROR =
4
+ `The package 'react-native-mobile-chat' doesn't seem to be linked. Make sure: \n\n` +
5
+ Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
6
+ '- You rebuilt the app after installing the package\n' +
7
+ '- You are not using Expo Go\n';
8
+
9
+ export const AppChatNative = NativeModules.AppChat
10
+ ? NativeModules.AppChat
11
+ : new Proxy(
12
+ {},
13
+ {
14
+ get() {
15
+ throw new Error(LINKING_ERROR);
16
+ },
17
+ }
18
+ );