omikit-plugin 3.1.4 → 3.1.6

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 CHANGED
@@ -361,7 +361,7 @@ We support 2 environments. So you need set correct key in Appdelegate.
361
361
  - Create OmiKit: OmiKit need userName, password, realm, host to init enviroment. ViHAT Group will provide informations for you. Please contact for my sale:
362
362
 
363
363
  ```
364
- import { initCall } from 'omikit-plugin';
364
+ import { initCallWithUserPassword } from 'omikit-plugin';
365
365
 
366
366
  const loginInfo = {
367
367
  userName: userName, //string
@@ -369,9 +369,9 @@ We support 2 environments. So you need set correct key in Appdelegate.
369
369
  realm: realm, //string
370
370
  isVideo: isVideo, //boolean: true/false
371
371
  host: host, //string
372
- fcmToken: fcmToken, //string
372
+ fcmToken: fcmToken, //string
373
373
  };
374
- const result = await initCall(loginInfo);
374
+ const result = await initCallWithUserPassword(loginInfo);
375
375
  //result is true then user login successfully.
376
376
  ```
377
377
 
@@ -104,7 +104,7 @@ dependencies {
104
104
  // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
105
105
  //noinspection GradleDynamicVersion
106
106
  // implementation "com.facebook.react:react-native"
107
- api 'vn.vihat.omicall:omi-sdk:2.0.37'
107
+ api 'vn.vihat.omicall:omi-sdk:2.0.39'
108
108
 
109
109
  implementation "com.facebook.react:react-native:+" // From node_modules
110
110
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
@@ -126,6 +126,8 @@ dependencies {
126
126
  implementation "com.google.code.gson:gson:2.8.9"
127
127
  implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2'
128
128
  implementation "androidx.security:security-crypto:1.1.0-alpha06"
129
+ implementation "com.github.voismart:crypto:0.1.0"
130
+
129
131
  implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.0"))
130
132
  implementation "com.github.bumptech.glide:glide:4.15.1"
131
133
  annotationProcessor "com.github.bumptech.glide:compiler:4.15.1"
@@ -184,7 +184,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
184
184
 
185
185
  private fun messageCall(type: Int): String {
186
186
  return when (type) {
187
- // 401 -> "INVALID_UUID"
187
+ // 0 -> "INVALID_UUID"
188
188
  // 1 -> "INVALID_PHONE_NUMBER"
189
189
  // 2 -> "SAME_PHONE_NUMBER_WITH_PHONE_REGISTER"
190
190
  // 3 -> "MAX_RETRY"
@@ -196,14 +196,14 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
196
196
  // 8 -> "START_CALL_SUCCESS"
197
197
  // 9 -> "HAVE_ANOTHER_CALL"
198
198
  200 -> "START_CALL_SUCCESS"
199
- 400 -> "AL"
199
+ 400 -> "ALREADY_IN_CALL"
200
200
  401 -> "INVALID_UUID"
201
201
  402 -> "INVALID_PHONE_NUMBER"
202
202
  403 -> "CAN_NOT_CALL_YOURSELF"
203
203
  404 -> "SWITCHBOARD_NOT_CONNECTED"
204
204
  405 -> "PERMISSION_DENIED"
205
205
  406 -> "PERMISSION_DENIED"
206
- 407 -> "COULD_NOT_REGISTER_ACCOUNT"
206
+ 407 -> "SWITCHBOARD_REGISTERING"
207
207
  else -> "HAVE_ANOTHER_CALL"
208
208
  }
209
209
  }
@@ -212,11 +212,8 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
212
212
  super.initialize()
213
213
  reactApplicationContext!!.addActivityEventListener(this)
214
214
  Handler(Looper.getMainLooper()).post {
215
- OmiClient(context = reactApplicationContext!!)
216
- OmiClient.getInstance(reactApplicationContext!!).addCallStateListener(this)
217
- OmiClient.getInstance(reactApplicationContext!!)
218
- OmiClient.isAppReady = true;
219
- OmiClient.getInstance(reactApplicationContext!!).addCallStateListener(this)
215
+ OmiClient.getInstance(reactApplicationContext!!).addCallStateListener(this)
216
+ OmiClient.isAppReady = true;
220
217
  }
221
218
  }
222
219
 
@@ -293,10 +290,12 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
293
290
  val host = data.getString("host")
294
291
  val isVideo = data.getBoolean("isVideo")
295
292
  val firebaseToken = data.getString("fcmToken") as String
296
- Log.d("dataOmi", "INIT_CALL_USER_PASSWORD $userName -- $password --$realm --$isVideo -- $host ")
293
+
294
+ Log.d("dataOmi", "INIT_CALL_USER_PASSWORD $userName -- $password --$realm --$isVideo -- $host")
295
+
297
296
  withContext(Dispatchers.Default) {
298
297
  try {
299
- if (userName != null && password != null && realm != null && host != null) {
298
+ if (userName != null && password != null && realm != null) {
300
299
  OmiClient.register(userName, password, realm , isVideo ?: true, firebaseToken, host)
301
300
  }
302
301
  } catch (_: Throwable) {
@@ -313,22 +312,22 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
313
312
  val usrName = data.getString("fullName")
314
313
  val usrUuid = data.getString("usrUuid")
315
314
  val apiKey = data.getString("apiKey")
316
- val isVideo = data.getBoolean("isVideo")
315
+ val isVideo = data.getBoolean("isVideo") ?: false
317
316
  val phone = data.getString("phone")
318
317
  val firebaseToken = data.getString("fcmToken") as String
319
- withContext(Dispatchers.Default) {
320
- try {
321
- if (usrName != null && usrUuid != null && apiKey != null) {
322
- loginResult = OmiClient.registerWithApiKey(
323
- apiKey = apiKey,
324
- userName = usrName,
325
- uuid = usrUuid,
326
- phone = phone ?: "",
327
- isVideo = isVideo,
328
- firebaseToken
329
- )
330
- }
331
- } catch (_: Throwable) {
318
+ withContext(Dispatchers.Default) {
319
+ try {
320
+ if (usrName != null && usrUuid != null && apiKey != null) {
321
+ loginResult = OmiClient.registerWithApiKey(
322
+ apiKey = apiKey,
323
+ userName = usrName,
324
+ uuid = usrUuid,
325
+ phone = phone ?: "",
326
+ isVideo = isVideo,
327
+ firebaseToken
328
+ )
329
+ }
330
+ } catch (_: Throwable) {
332
331
 
333
332
  }
334
333
  }
@@ -383,26 +382,23 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
383
382
  if (audio == PackageManager.PERMISSION_GRANTED) {
384
383
  currentActivity?.runOnUiThread {
385
384
  val phoneNumber = data.getString("phoneNumber") as String
386
- val isVideo = data.getBoolean("isVideo")
385
+ val isVideo = data.getBoolean("isVideo") ?: false ;
387
386
  val startCallResult = OmiClient.getInstance(reactApplicationContext!!).startCall(phoneNumber, isVideo)
388
- Log.d("dataOmi", "startCall ==>> ${startCallResult} ")
389
- Log.d("dataOmi", "startCall2 ==>> ${startCallResult.value} ")
390
387
  var statusCalltemp = startCallResult.value as Int;
391
388
  if(startCallResult.value == 200 ){
392
389
  statusCalltemp = 8
393
390
  }
394
- map.putString("status", statusCalltemp.toString())
395
- map.putString("_id", "")
396
- map.putString("message", messageCall(startCallResult.value) as String)
397
- Log.d("OMISDK", "=>> ON START CALL => $map")
391
+ map.putInt("status", statusCalltemp)
392
+ map.putString("_id", "")
393
+ map.putString("message", messageCall(startCallResult.value) as String)
398
394
  promise.resolve(map)
399
395
  }
400
396
  } else {
401
- map.putString("status","4")
402
- map.putString("_id", "")
403
- map.putString("message", messageCall(4) as String)
404
- Log.d("OMISDK", "=>> ON START CALL FAIL BECAUSE NEED PERMISSION => $map")
405
- promise.resolve(map)
397
+ map.putInt("status", 4)
398
+ map.putString("_id", "")
399
+ map.putString("message", messageCall(406) as String)
400
+ Log.d("OMISDK", "=>> ON START CALL FAIL BECAUSE NEED PERMISSION => $map")
401
+ promise.resolve(map)
406
402
  }
407
403
  }
408
404
 
@@ -1,4 +1,4 @@
1
- //
1
+ //
2
2
  // CallUtils.swift
3
3
  // OMICall Contact Center
4
4
  //
@@ -38,14 +38,21 @@ class CallManager {
38
38
  return currentCall
39
39
  }
40
40
 
41
- func transferCall(_ phoneNumber: String){
41
+ func transferCall(_ phoneNumber: String)-> Bool {
42
+ var result = false;
42
43
  do {
43
- if let callInfo = omiLib.getCurrentCall() {
44
- callInfo.blindTransferCall(withNumber: phoneNumber)
45
- }
44
+ if let callInfo = self.omiLib.getCurrentConfirmCall() {
45
+ dump(callInfo)
46
+ if callInfo.callState != .disconnected {
47
+ callInfo.blindTransferCall(withNumber: phoneNumber);
48
+ result = true
49
+ }
50
+ }
46
51
  } catch let error {
47
52
  print("ERROR_WHEN_TRANSFER_CALL_IOS: ", error)
48
53
  }
54
+ print("calllZiii 2 ==> \(result)")
55
+ return result
49
56
  }
50
57
 
51
58
 
@@ -79,6 +86,43 @@ class CallManager {
79
86
  }
80
87
  }
81
88
 
89
+ func convertDictionaryToJson(dictionary: [String: Any]) -> String? {
90
+ do {
91
+ let jsonData = try JSONSerialization.data(withJSONObject: dictionary, options: [])
92
+ if let jsonString = String(data: jsonData, encoding: .utf8) {
93
+ return jsonString
94
+ }
95
+ } catch {
96
+ print("Error converting dictionary to JSON: \(error.localizedDescription)")
97
+ }
98
+ return nil
99
+ }
100
+
101
+ private func messageCall(type: Int) -> String {
102
+ switch(type){
103
+ case 0:
104
+ return "INVALID_UUID"
105
+ case 1:
106
+ return "INVALID_PHONE_NUMBER"
107
+ case 2:
108
+ return "SAME_PHONE_NUMBER_WITH_PHONE_REGISTER"
109
+ case 3:
110
+ return "MAX_RETRY"
111
+ case 4:
112
+ return "PERMISSION_DENIED"
113
+ case 5:
114
+ return "COULD_NOT_FIND_END_POINT"
115
+ case 6:
116
+ return "REGISTER_ACCOUNT_FAIL"
117
+ case 7:
118
+ return "START_CALL_FAIL"
119
+ case 9:
120
+ return "HAVE_ANOTHER_CALL"
121
+ default:
122
+ return "START_CALL_SUCCESS"
123
+ }
124
+ }
125
+
82
126
  private func requestPermission(isVideo: Bool) {
83
127
  AVCaptureDevice.requestAccess(for: .audio) { _ in
84
128
  // print("request audio")
@@ -112,7 +156,7 @@ class CallManager {
112
156
  requestPermission(isVideo: isVideo)
113
157
  return true
114
158
  }
115
-
159
+
116
160
  func showMissedCall() {
117
161
  OmiClient.setMissedCall { call in
118
162
  UNUserNotificationCenter.current().getNotificationSettings { settings in
@@ -280,7 +324,7 @@ class CallManager {
280
324
  guestPhone = call.callerNumber ?? ""
281
325
  break
282
326
  case OMICallState.disconnected.rawValue:
283
- tempCallInfo = getCallInfo(call: call) ?? [:]
327
+ tempCallInfo = getCallInfo(call: call)
284
328
  if (videoManager != nil) {
285
329
  videoManager = nil
286
330
  }
@@ -321,29 +365,58 @@ class CallManager {
321
365
 
322
366
 
323
367
  /// Start call
324
- func startCall(_ phoneNumber: String, isVideo: Bool, completion: @escaping (_ : Int) -> Void) {
368
+ func startCall(_ phoneNumber: String, isVideo: Bool, completion: @escaping (_ : String) -> Void) {
325
369
  let secondsSinceCurrentTime = lastTimeCall.timeIntervalSinceNow
326
370
  guestPhone = phoneNumber
327
371
  OmiClient.startCall(phoneNumber, isVideo: isVideo) { status in
328
372
  DispatchQueue.main.async {
329
- completion(status.rawValue)
373
+ let callCurrent = self.omiLib.getCurrentCall()
374
+ var dataToSend: [String: Any] = [
375
+ "status": status.rawValue,
376
+ "_id": "",
377
+ "message": self.messageCall(type: status.rawValue)
378
+ ]
379
+ if(callCurrent != nil){
380
+ dataToSend["_id"] = String(describing: OmiCallModel(omiCall: callCurrent!).uuid)
381
+ }
382
+ if let jsonString = self.convertDictionaryToJson(dictionary: dataToSend) {
383
+ completion(jsonString)
384
+ } else {
385
+ completion("Conversion to JSON failed")
386
+ }
387
+ return
330
388
  }
331
389
  }
332
390
  }
333
391
 
334
392
  /// Start call
335
- func startCallWithUuid(_ uuid: String, isVideo: Bool, completion: @escaping (_ : Int) -> Void) {
393
+ func startCallWithUuid(_ uuid: String, isVideo: Bool, completion: @escaping (_ : String) -> Void) {
336
394
  let phoneNumber = OmiClient.getPhone(uuid)
337
395
  if let phone = phoneNumber {
338
396
  guestPhone = phoneNumber ?? ""
339
- OmiClient.startCall(phone, isVideo: isVideo) { status in
340
- DispatchQueue.main.async {
341
- completion(status.rawValue)
397
+ DispatchQueue.main.async {
398
+ OmiClient.startCall(phone, isVideo: isVideo) { statusCall in
399
+ let callCurrent = self.omiLib.getCurrentCall()
400
+ // completion(status.rawValue)
401
+ var dataToSend: [String: Any] = [
402
+ "status": statusCall.rawValue,
403
+ "_id": "",
404
+ "message": self.messageCall(type: statusCall.rawValue)
405
+ ]
406
+ if(callCurrent != nil){
407
+ dataToSend["_id"] = String(describing: OmiCallModel(omiCall: callCurrent!).uuid)
408
+ }
409
+ if let jsonString = self.convertDictionaryToJson(dictionary: dataToSend) {
410
+ completion(jsonString)
411
+ } else {
412
+ completion("Conversion to JSON failed")
413
+ }
414
+ return
415
+
342
416
  }
343
417
  }
344
418
  return
345
419
  }
346
- completion(OMIStartCallStatus.invalidUuid.rawValue)
347
420
  }
348
421
 
349
422
  func endAvailableCall() -> [String: Any] {
@@ -12,7 +12,7 @@ Pod::Spec.new do |s|
12
12
  s.authors = package["author"]
13
13
 
14
14
  s.platforms = { :ios => "11.0" }
15
- s.source = { :git => "https://github.com/stevennguyenn/omikit-plugin.git", :tag => "#{s.version}" }
15
+ s.source = { :git => "https://github.com/VIHATTeam/OMICALL-React-Native-SDK.git", :tag => "#{s.version}" }
16
16
 
17
17
  s.source_files = "ios/**/*.{h,m,mm,swift}"
18
18
 
@@ -32,5 +32,5 @@ Pod::Spec.new do |s|
32
32
  s.dependency "RCTTypeSafety"
33
33
  s.dependency "ReactCommon/turbomodule/core"
34
34
  end
35
- s.dependency "OmiKit", '1.5.85'
36
- end
35
+ s.dependency "OmiKit", '1.5.84'
36
+ end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omikit-plugin",
3
- "version": "3.1.4",
3
+ "version": "3.1.6",
4
4
  "description": "Omikit Plugin by ViHAT",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",