@moxtradeveloper/react-native-moxo-module 10.11.2 → 10.13.1
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 -1
- package/android/build.gradle +31 -137
- package/android/gradle.properties +3 -5
- package/android/src/main/java/com/moxomodule/MoxoModuleModule.kt +218 -330
- package/android/src/main/java/com/moxomodule/MoxoModulePackage.kt +17 -9
- package/ios/MoxoModule.h +5 -0
- package/ios/MoxoModule.mm +123 -0
- package/ios/MoxoModuleImpl.swift +153 -0
- package/package.json +39 -55
- package/react-native-moxo-module.podspec +6 -21
- package/scripts/download-mepsdk.js +19 -9
- package/src/NativeMoxoModule.ts +30 -0
- package/src/index.tsx +63 -53
- package/android/src/main/AndroidManifest.xml +0 -4
- package/ios/MoxoModule-Bridging-Header.h +0 -4
- package/ios/MoxoModule.m +0 -39
- package/ios/MoxoModule.swift +0 -183
- package/ios/MoxoModule.xcodeproj/project.pbxproj +0 -287
- package/ios/MoxoModuleBridge.h +0 -17
- package/ios/MoxoModuleBridge.m +0 -13
- package/scripts/bootstrap.js +0 -29
package/README.md
CHANGED
|
@@ -10,8 +10,9 @@ Moxo is an AI workflow automation platform for business operations.
|
|
|
10
10
|
|
|
11
11
|
### Supported Platforms
|
|
12
12
|
|
|
13
|
-
* iOS 15.
|
|
13
|
+
* iOS 15.6+
|
|
14
14
|
* Android 7+
|
|
15
|
+
* React Native 0.80+ with the New Architecture
|
|
15
16
|
|
|
16
17
|
## Preparation
|
|
17
18
|
|
|
@@ -24,11 +25,33 @@ Below sdk or tools are required before start to use react-native-moxo-module.
|
|
|
24
25
|
|
|
25
26
|
* Android Studio
|
|
26
27
|
* Android SDK API 24+ (Android 7.0)
|
|
28
|
+
* compileSdk 37+
|
|
29
|
+
* Android Gradle Plugin 9.1+
|
|
30
|
+
* Kotlin 2.3+. The React Native template defaults to Kotlin 2.2, so pin the Kotlin Gradle plugin in `android/build.gradle`:
|
|
31
|
+
|
|
32
|
+
```groovy
|
|
33
|
+
buildscript {
|
|
34
|
+
dependencies {
|
|
35
|
+
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:2.3.20")
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
* Jetifier, because some of the SDK's dependencies still use the Android Support Library. Add this to `android/gradle.properties`:
|
|
41
|
+
|
|
42
|
+
```properties
|
|
43
|
+
android.enableJetifier=true
|
|
44
|
+
```
|
|
27
45
|
|
|
28
46
|
### iOS
|
|
29
47
|
|
|
30
48
|
* Xcode v26+
|
|
31
49
|
* Cocoapod v1.16.2+
|
|
50
|
+
* Deployment target 15.6+. The React Native template defaults to 15.1, so raise it in `ios/Podfile` and set the app target's iOS Deployment Target to 15.6 in Xcode:
|
|
51
|
+
|
|
52
|
+
```ruby
|
|
53
|
+
platform :ios, '15.6'
|
|
54
|
+
```
|
|
32
55
|
|
|
33
56
|
For more react-native set up details, please ref to [react native official site](https://reactnative.dev/docs/environment-setup)
|
|
34
57
|
|
|
@@ -96,6 +119,19 @@ If user is logged in, call open chat API to open existing chat. If not logged in
|
|
|
96
119
|
moxo.openChat('CBSmiUUjyIJP7gR8YIpiagvH', '')
|
|
97
120
|
```
|
|
98
121
|
|
|
122
|
+
### Events
|
|
123
|
+
|
|
124
|
+
Event callbacks return a subscription. Call `remove()` on it when you no longer need the callback.
|
|
125
|
+
|
|
126
|
+
```js
|
|
127
|
+
const subscription = moxo.onUnreadMessageCountUpdated((count) => {
|
|
128
|
+
console.log(`Unread messages: ${count}`);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
// Later
|
|
132
|
+
subscription.remove();
|
|
133
|
+
```
|
|
134
|
+
|
|
99
135
|
### Notification
|
|
100
136
|
|
|
101
137
|
To enable notification feature, you'll need to integrate a notification module first, here we take [react-native-notifications](https://www.npmjs.com/package/react-native-notifications) for example, which can help to get device token and notification payload.
|
package/android/build.gradle
CHANGED
|
@@ -1,169 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['MoxoModule_kotlinVersion']
|
|
4
|
-
|
|
5
|
-
repositories {
|
|
6
|
-
google()
|
|
7
|
-
mavenCentral()
|
|
8
|
-
maven() {
|
|
9
|
-
url "https://mxrepo.moxo.com/repository/customer-maven-releases/"
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
dependencies {
|
|
14
|
-
classpath 'com.android.tools.build:gradle:3.5.3'
|
|
15
|
-
// noinspection DifferentKotlinGradleVersion
|
|
16
|
-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
17
|
-
}
|
|
1
|
+
def getExtOrDefault(name) {
|
|
2
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['MoxoModule_' + name]
|
|
18
3
|
}
|
|
19
4
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
google()
|
|
23
|
-
mavenCentral()
|
|
24
|
-
jcenter()
|
|
25
|
-
maven() {
|
|
26
|
-
url "https://mxrepo.moxo.com/repository/customer-maven-releases/"
|
|
27
|
-
}
|
|
28
|
-
}
|
|
5
|
+
def getExtOrIntegerDefault(name) {
|
|
6
|
+
return getExtOrDefault(name).toInteger()
|
|
29
7
|
}
|
|
30
8
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
9
|
+
// AGP 9 compiles Kotlin itself unless the app opts out with android.builtInKotlin=false.
|
|
10
|
+
def builtInKotlin = (project.findProperty('android.builtInKotlin') ?: 'true').toString().toBoolean()
|
|
34
11
|
|
|
35
12
|
apply plugin: 'com.android.library'
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (isNewArchitectureEnabled()) {
|
|
39
|
-
apply plugin: 'com.facebook.react'
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
def getExtOrDefault(name) {
|
|
43
|
-
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['MoxoModule_' + name]
|
|
13
|
+
if (!builtInKotlin) {
|
|
14
|
+
apply plugin: 'org.jetbrains.kotlin.android'
|
|
44
15
|
}
|
|
16
|
+
apply plugin: 'com.facebook.react'
|
|
45
17
|
|
|
46
|
-
|
|
47
|
-
|
|
18
|
+
// The app has to resolve mep-sdk and its dependencies from the Moxo repository.
|
|
19
|
+
rootProject.allprojects {
|
|
20
|
+
repositories {
|
|
21
|
+
maven {
|
|
22
|
+
url = 'https://mxrepo.moxo.com/repository/customer-maven-releases/'
|
|
23
|
+
}
|
|
24
|
+
}
|
|
48
25
|
}
|
|
49
26
|
|
|
50
27
|
android {
|
|
51
|
-
|
|
52
|
-
|
|
28
|
+
namespace = 'com.moxomodule'
|
|
29
|
+
compileSdk = getExtOrIntegerDefault('compileSdkVersion')
|
|
53
30
|
|
|
54
31
|
defaultConfig {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
32
|
+
minSdk = getExtOrIntegerDefault('minSdkVersion')
|
|
33
|
+
targetSdk = getExtOrIntegerDefault('targetSdkVersion')
|
|
58
34
|
}
|
|
35
|
+
|
|
59
36
|
buildTypes {
|
|
60
37
|
release {
|
|
61
|
-
minifyEnabled false
|
|
38
|
+
minifyEnabled = false
|
|
62
39
|
}
|
|
63
40
|
}
|
|
64
41
|
|
|
65
|
-
|
|
42
|
+
lint {
|
|
66
43
|
disable 'GradleCompatible'
|
|
67
44
|
}
|
|
68
45
|
|
|
69
46
|
compileOptions {
|
|
70
|
-
sourceCompatibility JavaVersion.VERSION_17
|
|
71
|
-
targetCompatibility JavaVersion.VERSION_17
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
kotlinOptions {
|
|
75
|
-
jvmTarget = "17"
|
|
47
|
+
sourceCompatibility = JavaVersion.VERSION_17
|
|
48
|
+
targetCompatibility = JavaVersion.VERSION_17
|
|
76
49
|
}
|
|
77
|
-
|
|
78
|
-
buildFeatures {
|
|
79
|
-
buildConfig true
|
|
80
|
-
}
|
|
81
50
|
}
|
|
82
51
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
def found = false
|
|
88
|
-
def defaultDir = null
|
|
89
|
-
def androidSourcesName = 'React Native sources'
|
|
90
|
-
|
|
91
|
-
if (rootProject.ext.has('reactNativeAndroidRoot')) {
|
|
92
|
-
defaultDir = rootProject.ext.get('reactNativeAndroidRoot')
|
|
93
|
-
} else {
|
|
94
|
-
defaultDir = new File(
|
|
95
|
-
projectDir,
|
|
96
|
-
'/../../../node_modules/react-native/android'
|
|
97
|
-
)
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
if (defaultDir.exists()) {
|
|
101
|
-
maven {
|
|
102
|
-
url defaultDir.toString()
|
|
103
|
-
name androidSourcesName
|
|
52
|
+
if (!builtInKotlin) {
|
|
53
|
+
kotlin {
|
|
54
|
+
compilerOptions {
|
|
55
|
+
jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17
|
|
104
56
|
}
|
|
105
|
-
|
|
106
|
-
logger.info(":${project.name}:reactNativeAndroidRoot ${defaultDir.canonicalPath}")
|
|
107
|
-
found = true
|
|
108
|
-
} else {
|
|
109
|
-
def parentDir = rootProject.projectDir
|
|
110
|
-
|
|
111
|
-
1.upto(5, {
|
|
112
|
-
if (found) return true
|
|
113
|
-
parentDir = parentDir.parentFile
|
|
114
|
-
|
|
115
|
-
def androidSourcesDir = new File(
|
|
116
|
-
parentDir,
|
|
117
|
-
'node_modules/react-native'
|
|
118
|
-
)
|
|
119
|
-
|
|
120
|
-
def androidPrebuiltBinaryDir = new File(
|
|
121
|
-
parentDir,
|
|
122
|
-
'node_modules/react-native/android'
|
|
123
|
-
)
|
|
124
|
-
|
|
125
|
-
if (androidPrebuiltBinaryDir.exists()) {
|
|
126
|
-
maven {
|
|
127
|
-
url androidPrebuiltBinaryDir.toString()
|
|
128
|
-
name androidSourcesName
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
logger.info(":${project.name}:reactNativeAndroidRoot ${androidPrebuiltBinaryDir.canonicalPath}")
|
|
132
|
-
found = true
|
|
133
|
-
} else if (androidSourcesDir.exists()) {
|
|
134
|
-
maven {
|
|
135
|
-
url androidSourcesDir.toString()
|
|
136
|
-
name androidSourcesName
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
logger.info(":${project.name}:reactNativeAndroidRoot ${androidSourcesDir.canonicalPath}")
|
|
140
|
-
found = true
|
|
141
|
-
}
|
|
142
|
-
})
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
if (!found) {
|
|
146
|
-
throw new GradleException(
|
|
147
|
-
"${project.name}: unable to locate React Native android sources. " +
|
|
148
|
-
"Ensure you have you installed React Native as a dependency in your project and try again."
|
|
149
|
-
)
|
|
150
57
|
}
|
|
151
58
|
}
|
|
152
59
|
|
|
153
|
-
def kotlin_version = getExtOrDefault('kotlinVersion')
|
|
154
|
-
|
|
155
60
|
dependencies {
|
|
156
|
-
|
|
157
|
-
implementation
|
|
158
|
-
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
159
|
-
implementation "com.moxtra:mep-sdk:10.11.1"
|
|
160
|
-
// From node_modules
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
if (isNewArchitectureEnabled()) {
|
|
164
|
-
react {
|
|
165
|
-
jsRootDir = file("../src/")
|
|
166
|
-
libraryName = "MoxoModule"
|
|
167
|
-
codegenJavaPackageName = "com.moxomodule"
|
|
168
|
-
}
|
|
61
|
+
implementation 'com.facebook.react:react-android'
|
|
62
|
+
implementation 'com.moxtra:mep-sdk:10.13.1'
|
|
169
63
|
}
|