react-native-mobile-chat 0.1.4 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/README.md +83 -3
  2. package/android/bin/build.gradle +77 -0
  3. package/android/bin/gradle.properties +5 -0
  4. package/android/bin/src/main/AndroidManifest.xml +4 -0
  5. package/android/bin/src/main/java/com/appchat/AppChatModule.class +0 -0
  6. package/android/bin/src/main/java/com/appchat/AppChatPackage.class +0 -0
  7. package/android/build.gradle +14 -19
  8. package/ios/AppChat.h +1 -1
  9. package/ios/AppChat.mm +13 -17
  10. package/ios/AppChat.xcodeproj/project.pbxproj +2 -2
  11. package/lib/commonjs/common/constants/index.js.map +1 -1
  12. package/lib/commonjs/common/utils/index.js +1 -1
  13. package/lib/commonjs/common/utils/index.js.map +1 -1
  14. package/lib/commonjs/data/local/index.js.map +1 -1
  15. package/lib/commonjs/data/remote/index.js +1 -1
  16. package/lib/commonjs/data/remote/index.js.map +1 -1
  17. package/lib/commonjs/data/static/index.js.map +1 -1
  18. package/lib/commonjs/index.js +7 -1
  19. package/lib/commonjs/index.js.map +1 -1
  20. package/lib/commonjs/native/component/WebView.js +1 -2
  21. package/lib/commonjs/native/component/WebView.js.map +1 -1
  22. package/lib/commonjs/native/module/index.js +3 -11
  23. package/lib/commonjs/native/module/index.js.map +1 -1
  24. package/lib/commonjs/package.json +1 -0
  25. package/lib/commonjs/presentation/component/AppChatComponent.js +145 -104
  26. package/lib/commonjs/presentation/component/AppChatComponent.js.map +1 -1
  27. package/lib/commonjs/presentation/initialization/index.js +7 -10
  28. package/lib/commonjs/presentation/initialization/index.js.map +1 -1
  29. package/lib/commonjs/presentation/notification/index.js +1 -1
  30. package/lib/commonjs/presentation/notification/index.js.map +1 -1
  31. package/lib/commonjs/specs/NativeAppChat.js +9 -0
  32. package/lib/commonjs/specs/NativeAppChat.js.map +1 -0
  33. package/lib/module/common/constants/index.js +2 -0
  34. package/lib/module/common/constants/index.js.map +1 -1
  35. package/lib/module/common/utils/index.js +2 -0
  36. package/lib/module/common/utils/index.js.map +1 -1
  37. package/lib/module/data/local/index.js +2 -0
  38. package/lib/module/data/local/index.js.map +1 -1
  39. package/lib/module/data/remote/index.js +2 -0
  40. package/lib/module/data/remote/index.js.map +1 -1
  41. package/lib/module/data/static/index.js +2 -0
  42. package/lib/module/data/static/index.js.map +1 -1
  43. package/lib/module/index.js +4 -2
  44. package/lib/module/index.js.map +1 -1
  45. package/lib/module/native/component/WebView.js +2 -0
  46. package/lib/module/native/component/WebView.js.map +1 -1
  47. package/lib/module/native/module/index.js +4 -10
  48. package/lib/module/native/module/index.js.map +1 -1
  49. package/lib/module/package.json +1 -0
  50. package/lib/module/presentation/component/AppChatComponent.js +146 -103
  51. package/lib/module/presentation/component/AppChatComponent.js.map +1 -1
  52. package/lib/module/presentation/initialization/index.js +8 -9
  53. package/lib/module/presentation/initialization/index.js.map +1 -1
  54. package/lib/module/presentation/notification/index.js +3 -1
  55. package/lib/module/presentation/notification/index.js.map +1 -1
  56. package/lib/module/specs/NativeAppChat.js +5 -0
  57. package/lib/module/specs/NativeAppChat.js.map +1 -0
  58. package/lib/typescript/index.d.ts +2 -2
  59. package/lib/typescript/index.d.ts.map +1 -1
  60. package/lib/typescript/native/module/index.d.ts +1 -1
  61. package/lib/typescript/native/module/index.d.ts.map +1 -1
  62. package/lib/typescript/presentation/component/AppChatComponent.d.ts +2 -1
  63. package/lib/typescript/presentation/component/AppChatComponent.d.ts.map +1 -1
  64. package/lib/typescript/specs/NativeAppChat.d.ts +9 -0
  65. package/lib/typescript/specs/NativeAppChat.d.ts.map +1 -0
  66. package/package.json +36 -12
  67. package/react-native-app-chat.podspec +2 -17
  68. package/src/index.tsx +2 -1
  69. package/src/native/module/index.tsx +2 -17
  70. package/src/presentation/component/AppChatComponent.tsx +42 -7
  71. package/src/specs/NativeAppChat.ts +10 -0
  72. package/ios/AppChat.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -4
package/package.json CHANGED
@@ -1,12 +1,20 @@
1
1
  {
2
2
  "name": "react-native-mobile-chat",
3
- "version": "0.1.4",
3
+ "version": "1.0.0",
4
4
  "description": "React Native Mobile Chat help you to manage customer relationship with customer conversation feature inside your react native app.",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
7
7
  "types": "lib/typescript/index.d.ts",
8
8
  "react-native": "src/index",
9
9
  "source": "src/index",
10
+ "codegenConfig": {
11
+ "name": "AppChatSpec",
12
+ "type": "modules",
13
+ "jsSrcsDir": "src/specs",
14
+ "android": {
15
+ "javaPackageName": "com.appchat"
16
+ }
17
+ },
10
18
  "files": [
11
19
  "src",
12
20
  "lib",
@@ -55,42 +63,58 @@
55
63
  "@commitlint/config-conventional": "^17.0.2",
56
64
  "@evilmartians/lefthook": "^1.2.2",
57
65
  "@react-native-community/eslint-config": "^3.0.2",
66
+ "@react-native/babel-preset": "0.83.0",
58
67
  "@release-it/conventional-changelog": "^5.0.0",
59
68
  "@types/crypto-js": "^4.1.1",
60
69
  "@types/jest": "^28.1.2",
61
- "@types/react": "~17.0.21",
62
- "@types/react-native": "0.70.0",
70
+ "@types/react": "18.3.12",
71
+ "@types/react-native": "0.73.0",
72
+ "@types/react-test-renderer": "^19.1.0",
63
73
  "commitlint": "^17.0.2",
64
74
  "del-cli": "^5.0.0",
65
75
  "eslint": "^8.4.1",
66
76
  "eslint-config-prettier": "^8.5.0",
67
77
  "eslint-plugin-prettier": "^4.0.0",
68
78
  "jest": "^28.1.1",
79
+ "metro-react-native-babel-preset": "^0.77.0",
69
80
  "pod-install": "^0.1.0",
70
81
  "prettier": "^2.0.5",
71
- "react": "18.2.0",
72
- "react-native": "0.72.3",
73
- "react-native-builder-bob": "^0.20.0",
82
+ "react": "18.3.1",
83
+ "react-native": "0.83.0",
84
+ "react-native-builder-bob": "^0.30.2",
85
+ "react-native-safe-area-context": "^5.5.2",
86
+ "react-native-webview": "^13.16.0",
87
+ "react-test-renderer": "18.3.1",
74
88
  "release-it": "^15.0.0",
75
- "typescript": "^4.5.2"
89
+ "typescript": "^5.3.3"
76
90
  },
77
91
  "resolutions": {
78
- "@types/react": "17.0.21"
92
+ "@types/react": "18.3.12"
79
93
  },
80
94
  "peerDependencies": {
81
95
  "react": "*",
82
- "react-native": "*",
83
- "react-native-webview": "*"
96
+ "react-native": ">=0.83.0",
97
+ "react-native-safe-area-context": ">=4.0.0",
98
+ "react-native-webview": ">=13.12.0"
84
99
  },
85
100
  "engines": {
86
- "node": ">= 16.0.0"
101
+ "node": ">=20.19.4"
87
102
  },
88
- "packageManager": "^yarn@1.22.15",
103
+ "packageManager": "yarn@1.22.15",
89
104
  "jest": {
90
105
  "preset": "react-native",
91
106
  "modulePathIgnorePatterns": [
92
107
  "<rootDir>/example/node_modules",
93
108
  "<rootDir>/lib/"
109
+ ],
110
+ "transformIgnorePatterns": [
111
+ "node_modules/(?!((jest-)?react-native|@react-native(-community)?|react-native-webview)/)"
112
+ ],
113
+ "moduleNameMapper": {
114
+ "\\.(png|jpg|jpeg|gif|svg)$": "<rootDir>/src/__mocks__/fileMock.js"
115
+ },
116
+ "setupFiles": [
117
+ "./jest.setup.js"
94
118
  ]
95
119
  },
96
120
  "commitlint": {
@@ -11,25 +11,10 @@ Pod::Spec.new do |s|
11
11
  s.license = package["license"]
12
12
  s.authors = package["author"]
13
13
 
14
- s.platforms = { :ios => "11.0" }
14
+ s.platforms = { :ios => "15.1" }
15
15
  s.source = { :git => "https://github.com/sa-ayyub/react-native-app-chat.git", :tag => "#{s.version}" }
16
16
 
17
17
  s.source_files = "ios/**/*.{h,m,mm}"
18
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
19
+ install_modules_dependencies(s)
35
20
  end
package/src/index.tsx CHANGED
@@ -1,8 +1,9 @@
1
1
  import AppChatComponent from "./presentation/component/AppChatComponent";
2
- import { initAppChat } from "./presentation/initialization";
2
+ import { initAppChat, setDebugMode } from "./presentation/initialization";
3
3
  import { isAppChatOpened, isAppChatPayload, registerNotification, revokeNotification } from "./presentation/notification";
4
4
  export {
5
5
  initAppChat as initMobileChat,
6
+ setDebugMode,
6
7
  isAppChatOpened as isMobileChatOpened,
7
8
  isAppChatPayload as isMobileChatPayload,
8
9
  AppChatComponent as MobileChatComponent,
@@ -1,18 +1,3 @@
1
- import { NativeModules, Platform } from 'react-native';
1
+ import NativeAppChat from '../../specs/NativeAppChat';
2
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
- );
3
+ export const AppChatNative = NativeAppChat;
@@ -1,11 +1,11 @@
1
1
  import React, { PureComponent, ReactNode, Fragment } from 'react';
2
- import { ActivityIndicator, StatusBar, View, Dimensions, Text, TouchableOpacity, Image, PermissionsAndroid, Platform } from 'react-native';
2
+ import { ActivityIndicator, StatusBar, View, Dimensions, Text, TouchableOpacity, Image, PermissionsAndroid, Platform, Linking } from 'react-native';
3
3
  import { AppChatStatic } from '../../data/static';
4
4
  import { initAppChat } from '../../presentation/initialization';
5
- import WebView, { WebViewMessageEvent } from 'react-native-webview';
5
+ import WebView, { WebViewMessageEvent, WebViewNavigation } from 'react-native-webview';
6
6
  import Constant from '../../common/constants';
7
7
  import { putString } from '../../data/local';
8
- import { SafeAreaView } from 'react-native';
8
+ import { SafeAreaView } from 'react-native-safe-area-context';
9
9
 
10
10
  type AppChatComponentProps = {
11
11
  onBackButtonTapped: () => void
@@ -84,6 +84,30 @@ export default class AppChatComponent extends PureComponent<AppChatComponentProp
84
84
  console.log('onMessage', event.nativeEvent.data);
85
85
  }
86
86
 
87
+ _onShouldStartLoadWithRequest = (request: WebViewNavigation): boolean => {
88
+ const { url } = request
89
+ const chatBaseUrl = Constant.BASE_URL_WEBVIEW
90
+
91
+ if (url.startsWith(chatBaseUrl) || url === 'about:blank') {
92
+ return true
93
+ }
94
+
95
+ if (
96
+ url.startsWith('http://') ||
97
+ url.startsWith('https://') ||
98
+ url.startsWith('tel:') ||
99
+ url.startsWith('mailto:') ||
100
+ url.startsWith('sms:')
101
+ ) {
102
+ Linking.openURL(url).catch((err) =>
103
+ this._logInit(`[OPEN-URL-ERROR] ${err}`)
104
+ )
105
+ return false
106
+ }
107
+
108
+ return false
109
+ }
110
+
87
111
  _logInit(log: string) {
88
112
  if (AppChatStatic.isDebug) {
89
113
  console.log(`[MOBILE-CHAT-SDK-QONTAK][MOBILE-CHAT-COMPONENT] ${log}`);
@@ -127,8 +151,8 @@ export default class AppChatComponent extends PureComponent<AppChatComponentProp
127
151
  }
128
152
  return (
129
153
  <Fragment>
130
- <SafeAreaView style={{ flex: 0, backgroundColor: this.state.isOverlaid ? AppChatStatic.appChatTheme.bgColorThemeOverlaid : bgColorTheme }} />
131
- <SafeAreaView style={{ flex: 1, backgroundColor: this.state.isOverlaid ? Constant.WEBVIEW_BACKGROUND_COLOR_OVERLAID : Constant.WEBVIEW_BACKGROUND_COLOR }}>
154
+ <SafeAreaView edges={['top']} style={{ flex: 0, backgroundColor: this.state.isOverlaid ? AppChatStatic.appChatTheme.bgColorThemeOverlaid : bgColorTheme }} />
155
+ <SafeAreaView edges={['bottom', 'left', 'right']} style={{ flex: 1, backgroundColor: this.state.isOverlaid ? Constant.WEBVIEW_BACKGROUND_COLOR_OVERLAID : Constant.WEBVIEW_BACKGROUND_COLOR }}>
132
156
  <StatusBar
133
157
  barStyle={fontColor === 'black' || this.state.isOverlaid ? 'dark-content' : 'light-content'}
134
158
  backgroundColor={this.state.isOverlaid ? AppChatStatic.appChatTheme.bgColorThemeOverlaid : bgColorTheme}
@@ -151,14 +175,25 @@ export default class AppChatComponent extends PureComponent<AppChatComponentProp
151
175
  <ActivityIndicator size="large" />
152
176
  </View>}
153
177
  {AppChatStatic.initAppChatResult === 'SUCCESS' && <WebView
154
- onLoadStart={(event) => this._logInit(`ON-LOAD-START ${event}`)}
155
- onLoadEnd={(event) => this._logInit(`ON-LOAD-END ${event}`)}
178
+ onLoadStart={(event: any) => this._logInit(`ON-LOAD-START ${event}`)}
179
+ onLoadEnd={(event: any) => this._logInit(`ON-LOAD-END ${event}`)}
156
180
  bounces={false}
157
181
  overScrollMode='never'
158
182
  setBuiltInZoomControls={false}
159
183
  injectedJavaScriptBeforeContentLoaded={postMessageListener}
160
184
  source={{ uri: `${Constant.BASE_URL_WEBVIEW}${Constant.ENCRYPTED_PARAMS_KEY}${AppChatStatic.encryptedUrlParams}` }}
161
185
  onMessage={this._onMessage}
186
+ allowsInlineMediaPlayback={true}
187
+ mediaCapturePermissionGrantType='prompt'
188
+ onShouldStartLoadWithRequest={this._onShouldStartLoadWithRequest}
189
+ onOpenWindow={(syntheticEvent: any) => {
190
+ const { targetUrl } = syntheticEvent.nativeEvent
191
+ if (targetUrl) {
192
+ Linking.openURL(targetUrl).catch((err) =>
193
+ this._logInit(`[OPEN-WINDOW-ERROR] ${err}`)
194
+ )
195
+ }
196
+ }}
162
197
  style={{ flex: 1, backgroundColor: this.state.isOverlaid ? Constant.WEBVIEW_BACKGROUND_COLOR_OVERLAID : Constant.WEBVIEW_BACKGROUND_COLOR }} />}
163
198
  </SafeAreaView>
164
199
  </Fragment>
@@ -0,0 +1,10 @@
1
+ import type { TurboModule } from 'react-native';
2
+ import { TurboModuleRegistry } from 'react-native';
3
+
4
+ export interface Spec extends TurboModule {
5
+ putString(key: string, value: string): Promise<string>;
6
+ getString(key: string): Promise<string>;
7
+ getBundleIdOrPackageName(): Promise<string>;
8
+ }
9
+
10
+ export default TurboModuleRegistry.getEnforcing<Spec>('AppChat');
@@ -1,4 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <Workspace
3
- version = "1.0">
4
- </Workspace>