@moxtradeveloper/react-native-moxo-module 9.8.6 → 9.9.7
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/android/build.gradle +1 -1
- package/android/gradle.properties +3 -3
- package/android/src/main/java/com/moxomodule/MoxoModuleModule.kt +106 -0
- package/ios/MoxoModule.m +4 -0
- package/ios/MoxoModule.swift +22 -0
- package/package.json +21 -5
- package/react-native-moxo-module.podspec +1 -1
- package/src/index.tsx +23 -0
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:9.
|
|
151
|
+
implementation "com.moxtra:mep-sdk:9.9.7"
|
|
152
152
|
// From node_modules
|
|
153
153
|
}
|
|
154
154
|
|
|
@@ -7,8 +7,10 @@ import com.facebook.react.bridge.*
|
|
|
7
7
|
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
8
8
|
import com.moxtra.mepsdk.MEPClient
|
|
9
9
|
import com.moxtra.mepsdk.MEPClientDelegate
|
|
10
|
+
import com.moxtra.mepsdk.data.MEPStartMeetOptions
|
|
10
11
|
import com.moxtra.sdk.LinkConfig
|
|
11
12
|
import com.moxtra.sdk.common.ApiCallback
|
|
13
|
+
import org.json.JSONArray
|
|
12
14
|
import org.json.JSONException
|
|
13
15
|
import org.json.JSONObject
|
|
14
16
|
|
|
@@ -316,6 +318,55 @@ class MoxoModuleModule(reactContext: ReactApplicationContext) :
|
|
|
316
318
|
}
|
|
317
319
|
}
|
|
318
320
|
|
|
321
|
+
@ReactMethod
|
|
322
|
+
fun startMeet(topic: String, options: ReadableMap?, promise: Promise?) {
|
|
323
|
+
Log.d(TAG, "startMeet called with topic: $topic, options:" + options?.toString())
|
|
324
|
+
if (topic.isNullOrEmpty()) {
|
|
325
|
+
promise?.reject("-1", "Topic is empty!")
|
|
326
|
+
return
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
var callback: ApiCallback<String> = object : ApiCallback<String> {
|
|
330
|
+
override fun onCompleted(sessionId: String) {
|
|
331
|
+
Log.d(TAG, "startMeet success ...")
|
|
332
|
+
val jsonObject = JSONObject()
|
|
333
|
+
with(jsonObject) {
|
|
334
|
+
put("session_id", sessionId)
|
|
335
|
+
}
|
|
336
|
+
promise?.resolve(json2WritableNativeMap(jsonObject))
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
override fun onError(errorCode: Int, errorMsg: String?) {
|
|
340
|
+
Log.w(TAG, "startMeet failed with $errorCode and $errorMsg ...")
|
|
341
|
+
promise?.reject(errorCode.toString(), "startMeet failed with $errorCode and $errorMsg")
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
//map to MEPStartMeetOptions
|
|
346
|
+
var mepStartMeetOptions = MEPStartMeetOptions()
|
|
347
|
+
mepStartMeetOptions.topic = topic
|
|
348
|
+
|
|
349
|
+
var mapValues = options?.entryIterator;
|
|
350
|
+
while (mapValues?.hasNext() == true) {
|
|
351
|
+
var mapEntry = mapValues.next()
|
|
352
|
+
when (mapEntry.key) {
|
|
353
|
+
"chat_id" -> mepStartMeetOptions.chatID = mapEntry.value.toString()
|
|
354
|
+
"auto_join_audio" -> mepStartMeetOptions.setAutoJoinAudio(mapEntry.value as Boolean)
|
|
355
|
+
"auto_start_video" -> mepStartMeetOptions.setAutoStartVideo(mapEntry.value as Boolean)
|
|
356
|
+
"auto_recording" -> mepStartMeetOptions.isAutoRecordingEnabled = mapEntry.value as Boolean
|
|
357
|
+
"instant_call" -> mepStartMeetOptions.setInstantCall(mapEntry.value as Boolean)
|
|
358
|
+
"unique_ids" -> {
|
|
359
|
+
val ids = mapEntry.value
|
|
360
|
+
if (ids is ReadableNativeArray) {
|
|
361
|
+
ids.toArrayList().also { mepStartMeetOptions.uniqueIDs = it as ArrayList<String> }
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
MEPClient.startMeet(mepStartMeetOptions, callback)
|
|
368
|
+
}
|
|
369
|
+
|
|
319
370
|
private fun json2Intent(jsonObject: JSONObject?): Intent {
|
|
320
371
|
var intent = Intent()
|
|
321
372
|
var keys = jsonObject?.keys();
|
|
@@ -341,6 +392,61 @@ class MoxoModuleModule(reactContext: ReactApplicationContext) :
|
|
|
341
392
|
return intent
|
|
342
393
|
}
|
|
343
394
|
|
|
395
|
+
private fun json2WritableNativeMap(jsonObject: JSONObject?): WritableNativeMap {
|
|
396
|
+
val writableMap = WritableNativeMap()
|
|
397
|
+
jsonObject?.let {
|
|
398
|
+
for (key in jsonObject.keys()) {
|
|
399
|
+
when (val value = jsonObject.get(key)) {
|
|
400
|
+
is JSONObject -> {
|
|
401
|
+
writableMap.putMap(key, json2WritableNativeMap(value))
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
is JSONArray -> {
|
|
405
|
+
writableMap.putArray(key, json2WritableNativeArray(value))
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
is String -> {
|
|
409
|
+
writableMap.putString(key, value)
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
is Boolean -> {
|
|
413
|
+
writableMap.putBoolean(key, value)
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
is Double -> {
|
|
417
|
+
writableMap.putDouble(key, value)
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
is Int -> {
|
|
421
|
+
writableMap.putInt(key, value)
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
is Long -> {
|
|
425
|
+
writableMap.putDouble(key, value.toDouble());
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
else -> {
|
|
429
|
+
writableMap.putString(key, value.toString())
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
return writableMap
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
private fun json2WritableNativeArray(jsonArray: JSONArray?): WritableNativeArray {
|
|
438
|
+
val writableArray = WritableNativeArray()
|
|
439
|
+
jsonArray?.let {
|
|
440
|
+
for (i in 0 until jsonArray.length()) {
|
|
441
|
+
val jsonObject = jsonArray.get(i)
|
|
442
|
+
if (jsonObject is JSONObject) {
|
|
443
|
+
writableArray.pushMap(json2WritableNativeMap(jsonObject))
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
return writableArray
|
|
448
|
+
}
|
|
449
|
+
|
|
344
450
|
companion object {
|
|
345
451
|
const val NAME = "MoxoModule"
|
|
346
452
|
}
|
package/ios/MoxoModule.m
CHANGED
|
@@ -16,6 +16,10 @@ RCT_EXTERN_METHOD(openChat:(NSString *)chatId
|
|
|
16
16
|
RCT_EXTERN_METHOD(openRelation:(NSDictionary *)user
|
|
17
17
|
withResolver:(RCTPromiseResolveBlock)resolve
|
|
18
18
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
19
|
+
RCT_EXTERN_METHOD(startMeet:(NSString *)topic
|
|
20
|
+
options:(NSDictionary *)options
|
|
21
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
22
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
19
23
|
RCT_EXTERN_METHOD(getUnreadMessageCount:(NSDictionary *)options
|
|
20
24
|
withResolver:(RCTPromiseResolveBlock)resolve
|
|
21
25
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
package/ios/MoxoModule.swift
CHANGED
|
@@ -102,6 +102,28 @@ class MoxoModule: RCTEventEmitter, MEPClientDelegate {
|
|
|
102
102
|
let ret = MEPClient.sharedInstance().getUnreadMessageCount()
|
|
103
103
|
resolve(ret)
|
|
104
104
|
}
|
|
105
|
+
|
|
106
|
+
@objc(startMeet:options:withResolver:withRejecter:)
|
|
107
|
+
func startMeet(topic: String, options:Dictionary<String, Any>,resolve:@escaping RCTPromiseResolveBlock, reject:@escaping RCTPromiseRejectBlock) {
|
|
108
|
+
DispatchQueue.main.async {
|
|
109
|
+
let meetOption = MEPStartMeetOptions()
|
|
110
|
+
meetOption.topic = topic
|
|
111
|
+
meetOption.chatID = options["chat_id"] as? String ?? nil
|
|
112
|
+
meetOption.uniqueIDs = options["unique_ids"] as? Array ?? nil
|
|
113
|
+
meetOption.autoJoinAudio = options["auto_join_audio"] as? Bool ?? true
|
|
114
|
+
meetOption.autoStartVideo = options["auto_start_video"] as? Bool ?? false
|
|
115
|
+
meetOption.autoRecording = options["auto_recording"] as? Bool ?? false
|
|
116
|
+
meetOption.instantCall = options["instant_call"] as? Bool ?? false
|
|
117
|
+
MEPClient.sharedInstance().startMeet(withOption: meetOption) { error, meetId in
|
|
118
|
+
if let err = error as? NSError {
|
|
119
|
+
reject("\(err.code)", err.localizedDescription, error)
|
|
120
|
+
} else {
|
|
121
|
+
let ret = ["session_id": meetId]
|
|
122
|
+
resolve(ret)
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
105
127
|
|
|
106
128
|
//MARK: Notification
|
|
107
129
|
@objc(registerNotification:withResolver:withRejecter:)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moxtradeveloper/react-native-moxo-module",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.9.7",
|
|
4
4
|
"description": "Plugin for adding Moxtra services to react-native Apps.",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@react-native-community/eslint-config": "^3.0.2",
|
|
60
|
+
"@release-it/conventional-changelog": "^5.0.0",
|
|
60
61
|
"@types/jest": "^28.1.2",
|
|
61
62
|
"@types/react": "~17.0.21",
|
|
62
63
|
"@types/react-native": "0.70.0",
|
|
@@ -70,12 +71,10 @@
|
|
|
70
71
|
"react": "18.1.0",
|
|
71
72
|
"react-native": "0.70.6",
|
|
72
73
|
"react-native-builder-bob": "^0.20.0",
|
|
74
|
+
"release-it": "^15.0.0",
|
|
73
75
|
"typedoc": "^0.24.8",
|
|
74
76
|
"typescript": "^4.5.2"
|
|
75
77
|
},
|
|
76
|
-
"overrides": {
|
|
77
|
-
"semver": "^7.5.3"
|
|
78
|
-
},
|
|
79
78
|
"resolutions": {
|
|
80
79
|
"@types/react": "17.0.21"
|
|
81
80
|
},
|
|
@@ -99,6 +98,23 @@
|
|
|
99
98
|
"@commitlint/config-conventional"
|
|
100
99
|
]
|
|
101
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
|
+
},
|
|
102
118
|
"eslintConfig": {
|
|
103
119
|
"root": true,
|
|
104
120
|
"extends": [
|
|
@@ -143,4 +159,4 @@
|
|
|
143
159
|
]
|
|
144
160
|
]
|
|
145
161
|
}
|
|
146
|
-
}
|
|
162
|
+
}
|
|
@@ -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 'MEPSDKDylib', '~> 9.
|
|
20
|
+
s.dependency 'MEPSDKDylib', '~> 9.9.7'
|
|
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
|
package/src/index.tsx
CHANGED
|
@@ -149,3 +149,26 @@ export function showMeetRinger(sessionId:string): Promise<object> {
|
|
|
149
149
|
return MoxoModule.showMeetRinger(sessionId);
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
+
/**
|
|
153
|
+
* Start meet with options.
|
|
154
|
+
*
|
|
155
|
+
* @param topic Topic of meeting
|
|
156
|
+
* @param options Start meet options.
|
|
157
|
+
* {
|
|
158
|
+
* "unique_ids": ["unique_id_a", "unique_id_b", ...], //user unique id array
|
|
159
|
+
* "chat_id":"chat_id", //id of chat where this meeting will start
|
|
160
|
+
* "auto_join_audio": true/false, //default is true
|
|
161
|
+
* "auto_start_video": true/false, //default is false
|
|
162
|
+
* "auto_recording": true/false, //default is false
|
|
163
|
+
* "instant_call": true/false //default is false, set to true to enable call UI with dialer tone when start a meeting with only one user.
|
|
164
|
+
* //this option only works when unique_ids got only one user, and autoJoinAudio set to true.
|
|
165
|
+
* }
|
|
166
|
+
* @returns session id if start meet successfully:
|
|
167
|
+
* {
|
|
168
|
+
* "session_id": "255576178"
|
|
169
|
+
* }
|
|
170
|
+
*/
|
|
171
|
+
export function startMeet(topic: string, options?: object): Promise<object> {
|
|
172
|
+
return MoxoModule.startMeet(topic, options);
|
|
173
|
+
}
|
|
174
|
+
|