@moxtradeveloper/react-native-moxo-module 8.9.5 → 8.12.2
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 +18 -3
- package/README.md +77 -24
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/moxomodule/MoxoModuleModule.kt +2 -2
- package/ios/MoxoModule.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/MoxoModule.xcodeproj/project.xcworkspace/xcuserdata/john.hu.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/MoxoModule.xcodeproj/xcuserdata/john.hu.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/package.json +3 -5
- package/react-native-moxo-module.podspec +1 -1
package/LICENSE
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
4
|
-
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
|
|
3
|
+
Copyright (c) 2023 Moxo
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,17 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
[ [Introduce](#introduce) • [Preparation](#preparation) • [Installation](#installation) • [Initialization](#initialization) • [Sample Code](#sample-code) • [API Doc](#api-doc)]
|
|
4
|
+
|
|
5
|
+
## Introduce
|
|
6
|
+
|
|
7
|
+
**react-native-moxo-module** is a [moxo sdk](https://www.moxo.com/platform/sdks) react-native wrapper. Provide Moxo OneStop capabilities to your mobile app built on [React Native](https://reactnative.dev/)
|
|
8
|
+
|
|
9
|
+
### Supported Platforms
|
|
10
|
+
|
|
11
|
+
* iOS 13.0+
|
|
12
|
+
* Android 4.4+
|
|
13
|
+
|
|
14
|
+
## Preparation
|
|
15
|
+
|
|
16
|
+
Below sdk or tools are required before start to use react-native-moxo-module.
|
|
17
|
+
|
|
18
|
+
* Node.js v14+
|
|
19
|
+
* Watchman
|
|
20
|
+
|
|
21
|
+
### Android
|
|
22
|
+
|
|
23
|
+
* Android Studio
|
|
24
|
+
* Android SDK v19+
|
|
25
|
+
|
|
26
|
+
### iOS
|
|
27
|
+
|
|
28
|
+
* Xcode v14.1+
|
|
29
|
+
* Cocoapod v1.11.0+
|
|
30
|
+
|
|
31
|
+
For more react-native set up details, please ref to [react native official site](https://reactnative.dev/docs/environment-setup)
|
|
3
32
|
|
|
4
33
|
## Installation
|
|
5
34
|
|
|
6
35
|
```sh
|
|
7
|
-
npm install react-native-moxo-module
|
|
36
|
+
npm install @moxtradeveloper/react-native-moxo-module
|
|
8
37
|
```
|
|
9
|
-
#### Supported platforms
|
|
10
|
-
iOS: iOS 13, Xcode 14
|
|
11
|
-
|
|
12
|
-
Android:
|
|
13
38
|
|
|
14
39
|
### iOS Specific Steps
|
|
40
|
+
|
|
15
41
|
* Add moxo cocoapod repo as source into Podfile under your iOS project.
|
|
16
42
|
* Change pod deployment platform to iOS 13
|
|
17
43
|
|
|
@@ -30,13 +56,13 @@ install! 'cocoapods', :deterministic_uuids => false
|
|
|
30
56
|
# Rest of the file.....
|
|
31
57
|
```
|
|
32
58
|
|
|
33
|
-
##
|
|
34
|
-
```js
|
|
35
|
-
import * as moxo from 'react-native-moxo-module';
|
|
59
|
+
## Initialization
|
|
36
60
|
|
|
37
|
-
|
|
38
|
-
|
|
61
|
+
### Login
|
|
62
|
+
|
|
63
|
+
Before login, we need to get access token, by Moxo RestAPI:
|
|
39
64
|
|
|
65
|
+
```js
|
|
40
66
|
// Get access token
|
|
41
67
|
const response = await fetch('https://myenv.moxo.com/v1/core/oauth/token', {
|
|
42
68
|
method: 'POST',
|
|
@@ -53,22 +79,50 @@ const response = await fetch('https://myenv.moxo.com/v1/core/oauth/token', {
|
|
|
53
79
|
})
|
|
54
80
|
const json = await response.json();
|
|
55
81
|
token = json.access_token
|
|
82
|
+
```
|
|
56
83
|
|
|
84
|
+
Import plugin before use, then initialize moxo sdk and login with access token:
|
|
85
|
+
|
|
86
|
+
```js
|
|
87
|
+
import * as moxo from 'react-native-moxo-module';
|
|
88
|
+
// Setup domain
|
|
89
|
+
moxo.setup('myenv.moxo.com')
|
|
57
90
|
//Login and show moxo engagement platform window
|
|
58
|
-
moxo.link(token).then((
|
|
91
|
+
moxo.link(token).then((result)=>{
|
|
59
92
|
if (result)
|
|
60
|
-
|
|
93
|
+
console.log(`Link success`)
|
|
61
94
|
}).catch((err=>{
|
|
62
95
|
console.log(`Link failed!:${err}`);
|
|
63
96
|
}))
|
|
64
97
|
```
|
|
98
|
+
|
|
99
|
+
### Show MEP window
|
|
100
|
+
|
|
101
|
+
After login successful, we can show MEP window directly.
|
|
102
|
+
|
|
103
|
+
```js
|
|
104
|
+
moxo.showMEPWindow();
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Sample Code
|
|
108
|
+
|
|
109
|
+
### Open existing chat
|
|
110
|
+
|
|
111
|
+
If user is logged in, call open chat API to open existing chat. If not logged in or chat does not exists, API will return error with error code and error message.
|
|
112
|
+
|
|
113
|
+
```js
|
|
114
|
+
moxo.openChat('CBSmiUUjyIJP7gR8YIpiagvH', '')
|
|
115
|
+
```
|
|
116
|
+
|
|
65
117
|
### Notification
|
|
118
|
+
|
|
66
119
|
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.
|
|
67
120
|
|
|
68
121
|
#### Register notification
|
|
69
|
-
|
|
122
|
+
|
|
123
|
+
Through react-native-notifications registerRemoteNotifications(), post user agreement, notification will be enabled for your app.
|
|
70
124
|
Call registerRemoteNotificationsRegistered() to get a device token.
|
|
71
|
-
Then pass token to moxo function
|
|
125
|
+
Then pass token to moxo function ``registerNotification()`` will register notification to Moxo server.
|
|
72
126
|
|
|
73
127
|
```js
|
|
74
128
|
Notifications.registerRemoteNotifications();
|
|
@@ -84,7 +138,8 @@ Then pass token to moxo function ```registerNotification()``` will register noti
|
|
|
84
138
|
```
|
|
85
139
|
|
|
86
140
|
#### Handle notification
|
|
87
|
-
|
|
141
|
+
|
|
142
|
+
For example, once notification received, and user tapped notification, react-native-notifications function registerNotificationOpened will be triggered with notification payload data. Then pass payload to moxo function ``parseNotification()`` like below:
|
|
88
143
|
|
|
89
144
|
```js
|
|
90
145
|
Notifications.events().registerNotificationOpened((notification: Notification, completion: () => void, action?: NotificationActionResponse) => {
|
|
@@ -101,10 +156,10 @@ For example, once notification received, and user tapped notification, react-nat
|
|
|
101
156
|
});
|
|
102
157
|
```
|
|
103
158
|
|
|
104
|
-
If is a Moxo notification, then callback of the
|
|
159
|
+
If is a Moxo notification, then callback of the ``parseNotification()`` would be triggered with info parameter. Usually info contains 'chat_id' or 'meet_id', depends one which kind of notification you received.
|
|
105
160
|
To do more, you can invoke function openChat(chat_id) to open target chat directly.
|
|
106
161
|
|
|
107
|
-
#### Sample notification payload
|
|
162
|
+
#### Sample notification payload
|
|
108
163
|
|
|
109
164
|
##### iOS
|
|
110
165
|
|
|
@@ -135,7 +190,7 @@ To do more, you can invoke function openChat(chat_id) to open target chat direct
|
|
|
135
190
|
}
|
|
136
191
|
```
|
|
137
192
|
|
|
138
|
-
##### Android
|
|
193
|
+
##### Android
|
|
139
194
|
|
|
140
195
|
```json
|
|
141
196
|
[
|
|
@@ -172,8 +227,6 @@ To do more, you can invoke function openChat(chat_id) to open target chat direct
|
|
|
172
227
|
}]
|
|
173
228
|
```
|
|
174
229
|
|
|
175
|
-
##
|
|
176
|
-
|
|
177
|
-
ISC
|
|
230
|
+
## API Doc
|
|
178
231
|
|
|
179
|
-
|
|
232
|
+
[API doc](https://htmlpreview.github.io/?https://github.com/Moxtra/react-native-moxo-module/blob/main/docs/index.html)
|
package/android/build.gradle
CHANGED
|
@@ -148,7 +148,7 @@ dependencies {
|
|
|
148
148
|
//noinspection GradleDynamicVersion
|
|
149
149
|
implementation "com.facebook.react:react-native:+"
|
|
150
150
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
151
|
-
implementation "com.moxtra:mep-sdk:8.
|
|
151
|
+
implementation "com.moxtra:mep-sdk:8.12.2"
|
|
152
152
|
// From node_modules
|
|
153
153
|
}
|
|
154
154
|
|
|
@@ -185,8 +185,8 @@ class MoxoModuleModule(reactContext: ReactApplicationContext) :
|
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
@ReactMethod
|
|
188
|
-
fun
|
|
189
|
-
Log.d(TAG, "
|
|
188
|
+
fun removeListeners(count: Integer) {
|
|
189
|
+
Log.d(TAG, "removeListeners called...")
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
@ReactMethod
|
|
Binary file
|
package/ios/MoxoModule.xcodeproj/xcuserdata/john.hu.xcuserdatad/xcschemes/xcschememanagement.plist
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>SchemeUserState</key>
|
|
6
|
+
<dict>
|
|
7
|
+
<key>MoxoModule.xcscheme_^#shared#^_</key>
|
|
8
|
+
<dict>
|
|
9
|
+
<key>orderHint</key>
|
|
10
|
+
<integer>0</integer>
|
|
11
|
+
</dict>
|
|
12
|
+
</dict>
|
|
13
|
+
</dict>
|
|
14
|
+
</plist>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moxtradeveloper/react-native-moxo-module",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.12.2",
|
|
4
4
|
"description": "Plugin for adding Moxtra services to react-native Apps.",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -49,21 +49,18 @@
|
|
|
49
49
|
"author": "john.hu <john.hu@moxo.com>",
|
|
50
50
|
"license": "ISC",
|
|
51
51
|
"bugs": {
|
|
52
|
-
|
|
52
|
+
"url": "https://www.moxtra.com"
|
|
53
53
|
},
|
|
54
54
|
"homepage": "https://www.moxtra.com",
|
|
55
55
|
"publishConfig": {
|
|
56
56
|
"registry": "https://registry.npmjs.org/"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@arkweid/lefthook": "^0.7.7",
|
|
60
|
-
"@commitlint/config-conventional": "^17.0.2",
|
|
61
59
|
"@react-native-community/eslint-config": "^3.0.2",
|
|
62
60
|
"@release-it/conventional-changelog": "^5.0.0",
|
|
63
61
|
"@types/jest": "^28.1.2",
|
|
64
62
|
"@types/react": "~17.0.21",
|
|
65
63
|
"@types/react-native": "0.70.0",
|
|
66
|
-
"commitlint": "^17.0.2",
|
|
67
64
|
"del-cli": "^5.0.0",
|
|
68
65
|
"eslint": "^8.4.1",
|
|
69
66
|
"eslint-config-prettier": "^8.5.0",
|
|
@@ -75,6 +72,7 @@
|
|
|
75
72
|
"react-native": "0.70.6",
|
|
76
73
|
"react-native-builder-bob": "^0.20.0",
|
|
77
74
|
"release-it": "^15.0.0",
|
|
75
|
+
"typedoc": "^0.24.8",
|
|
78
76
|
"typescript": "^4.5.2"
|
|
79
77
|
},
|
|
80
78
|
"resolutions": {
|
|
@@ -17,7 +17,7 @@ Pod::Spec.new do |s|
|
|
|
17
17
|
s.public_header_files = 'ios/*.h'
|
|
18
18
|
s.swift_version = '5.0'
|
|
19
19
|
s.dependency "React-Core"
|
|
20
|
-
s.dependency 'MEPSDK', '~> 8.
|
|
20
|
+
s.dependency 'MEPSDK', '~> 8.12.1'
|
|
21
21
|
|
|
22
22
|
# Don't install the dependencies when we run `pod install` in the old architecture.
|
|
23
23
|
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
|