omikit-plugin 2.1.3 → 2.2.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.
@@ -1,12 +1,17 @@
1
1
  package com.omikitplugin
2
2
 
3
3
  import android.Manifest
4
+ import android.app.Activity
4
5
  import android.content.Context
6
+ import android.content.Intent
7
+ import android.content.pm.PackageManager
5
8
  import android.hardware.camera2.CameraManager
6
9
  import android.os.Build
7
10
  import android.os.Handler
11
+ import android.os.Looper
8
12
  import android.util.Log
9
13
  import androidx.core.app.ActivityCompat
14
+ import androidx.core.content.ContextCompat
10
15
  import com.facebook.react.ReactActivity
11
16
  import com.facebook.react.bridge.*
12
17
  import com.facebook.react.modules.core.RCTNativeAppEventEmitter
@@ -19,10 +24,11 @@ import vn.vihat.omicall.omisdk.OmiAccountListener
19
24
  import vn.vihat.omicall.omisdk.OmiClient
20
25
  import vn.vihat.omicall.omisdk.OmiListener
21
26
  import vn.vihat.omicall.omisdk.utils.OmiSDKUtils
27
+ import vn.vihat.omicall.omisdk.utils.SipServiceConstants
22
28
 
23
29
 
24
30
  class OmikitPluginModule(reactContext: ReactApplicationContext?) :
25
- ReactContextBaseJavaModule(reactContext) {
31
+ ReactContextBaseJavaModule(reactContext), ActivityEventListener {
26
32
  private val mainScope = CoroutineScope(Dispatchers.Main)
27
33
 
28
34
  override fun getName(): String {
@@ -39,8 +45,24 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
39
45
  Log.d("omikit", "incomingReceived: ")
40
46
  }
41
47
 
42
- override fun onCallEnd() {
43
- sendEvent(CALL_END, null)
48
+ override fun onCallEnd(callInfo: Any?) {
49
+ if (callInfo is Map<*, *>) {
50
+ val call = callInfo as Map<*, *>
51
+ val map: WritableMap = WritableNativeMap()
52
+ val timeStartToAnswer = call["time_start_to_answer"] as Long?
53
+ val timeEnd = call["time_end"] as Long
54
+ map.putString("transaction_id", call["transaction_id"] as String)
55
+ map.putString("direction", call["direction"] as String)
56
+ map.putString("source_number", call["source_number"] as String)
57
+ map.putString("destination_number", call["destination_number"] as String)
58
+ map.putDouble("time_start_to_answer", (timeStartToAnswer ?: 0).toDouble())
59
+ map.putDouble("time_end", timeEnd.toDouble())
60
+ map.putString("sip_user", call["sip_user"] as String)
61
+ map.putString("disposition", call["disposition"] as String)
62
+ sendEvent(CALL_END, map)
63
+ } else {
64
+ sendEvent(CALL_END, null)
65
+ }
44
66
  }
45
67
 
46
68
  override fun onCallEstablished(
@@ -48,12 +70,15 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
48
70
  phoneNumber: String?,
49
71
  isVideo: Boolean?,
50
72
  startTime: Long,
73
+ transactionId: String?,
51
74
  ) {
52
- Handler().postDelayed({
75
+ OmiClient.instance.changeLocalCameraOrientation(0)
76
+ Handler(Looper.getMainLooper()).postDelayed({
53
77
  Log.d("OmikitReactNative", "onCallEstablished")
54
78
  val map: WritableMap = WritableNativeMap()
55
79
  map.putString("callerNumber", phoneNumber)
56
80
  map.putBoolean("isVideo", isVideo ?: true)
81
+ map.putString("transactionId", transactionId)
57
82
  sendEvent(CALL_ESTABLISHED, map)
58
83
  }, 500)
59
84
  }
@@ -79,7 +104,6 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
79
104
  }
80
105
 
81
106
  override fun onRinging() {
82
- // sendEvent("onRinging", null)
83
107
  }
84
108
 
85
109
  override fun onVideoSize(width: Int, height: Int) {
@@ -97,6 +121,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
97
121
 
98
122
  override fun initialize() {
99
123
  super.initialize()
124
+ reactApplicationContext!!.addActivityEventListener(this)
100
125
  }
101
126
 
102
127
  @ReactMethod
@@ -122,6 +147,8 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
122
147
  val incomingBackgroundColor = data.getString("incomingBackgroundColor")
123
148
  val incomingAcceptButtonImage = data.getString("incomingAcceptButtonImage")
124
149
  val incomingDeclineButtonImage = data.getString("incomingDeclineButtonImage")
150
+ val prefixMissedCallMessage = data.getString("prefixMissedCallMessage")
151
+ val missedCallTitle = data.getString("missedCallTitle")
125
152
  val backImage = data.getString("backImage")
126
153
  val userImage = data.getString("userImage")
127
154
  OmiClient.instance.configPushNotification(
@@ -135,6 +162,8 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
135
162
  incomingDeclineButtonImage = incomingDeclineButtonImage ?: "hangup",
136
163
  backImage = backImage ?: "ic_back",
137
164
  userImage = userImage ?: "calling_face",
165
+ prefixMissedCallMessage = prefixMissedCallMessage ?: "Cuộc gọi nhỡ từ",
166
+ missedCallTitle = prefixMissedCallMessage ?: "Cuộc gọi nhỡ"
138
167
  )
139
168
  promise.resolve(true)
140
169
  }
@@ -183,7 +212,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
183
212
  isVideo,
184
213
  )
185
214
  }
186
- } catch (_ : Throwable) {
215
+ } catch (_: Throwable) {
187
216
 
188
217
  }
189
218
  }
@@ -213,7 +242,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
213
242
  "",
214
243
  deviceTokenAndroid,
215
244
  )
216
- } catch (_ : Throwable) {
245
+ } catch (_: Throwable) {
217
246
 
218
247
  }
219
248
  }
@@ -223,28 +252,46 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
223
252
 
224
253
  @ReactMethod
225
254
  fun startCall(data: ReadableMap, promise: Promise) {
226
- currentActivity?.runOnUiThread {
227
- val phoneNumber = data.getString("phoneNumber") as String
228
- val isVideo = data.getBoolean("isVideo")
229
- OmiClient.instance.startCall(phoneNumber, isVideo)
230
- promise.resolve(true)
255
+ val audio: Int =
256
+ ContextCompat.checkSelfPermission(
257
+ reactApplicationContext!!,
258
+ Manifest.permission.RECORD_AUDIO
259
+ )
260
+ if (audio == PackageManager.PERMISSION_GRANTED) {
261
+ currentActivity?.runOnUiThread {
262
+ val phoneNumber = data.getString("phoneNumber") as String
263
+ val isVideo = data.getBoolean("isVideo")
264
+ OmiClient.instance.startCall(phoneNumber, isVideo)
265
+ promise.resolve(true)
266
+ }
267
+ } else {
268
+ promise.resolve(false)
231
269
  }
232
270
  }
233
271
 
234
272
  @ReactMethod
235
273
  fun startCallWithUuid(data: ReadableMap, promise: Promise) {
236
- mainScope.launch {
237
- var callResult = false
238
- withContext(Dispatchers.Default) {
239
- try {
240
- val uuid = data.getString("usrUuid") as String
241
- val isVideo = data.getBoolean("isVideo")
242
- callResult = OmiClient.instance.startCallWithUuid(uuid = uuid, isVideo = isVideo)
243
- } catch (_ : Throwable) {
274
+ val audio: Int =
275
+ ContextCompat.checkSelfPermission(
276
+ reactApplicationContext!!,
277
+ Manifest.permission.RECORD_AUDIO
278
+ )
279
+ if (audio == PackageManager.PERMISSION_GRANTED) {
280
+ mainScope.launch {
281
+ var callResult = false
282
+ withContext(Dispatchers.Default) {
283
+ try {
284
+ val uuid = data.getString("usrUuid") as String
285
+ val isVideo = data.getBoolean("isVideo")
286
+ callResult = OmiClient.instance.startCallWithUuid(uuid = uuid, isVideo = isVideo)
287
+ } catch (_: Throwable) {
244
288
 
289
+ }
245
290
  }
291
+ promise.resolve(callResult)
246
292
  }
247
- promise.resolve(callResult)
293
+ } else {
294
+ promise.resolve(false)
248
295
  }
249
296
  }
250
297
 
@@ -259,19 +306,35 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
259
306
  @ReactMethod
260
307
  fun endCall(promise: Promise) {
261
308
  currentActivity?.runOnUiThread {
262
- OmiClient.instance.hangUp()
263
- promise.resolve(true)
309
+ val callInfo = OmiClient.instance.hangUp()
310
+ if (callInfo is Map<*, *>) {
311
+ val call = callInfo as Map<*, *>
312
+ val map: WritableMap = WritableNativeMap()
313
+ val timeStartToAnswer = call["time_start_to_answer"] as Long?
314
+ val timeEnd = call["time_end"] as Long
315
+ map.putString("transaction_id", call["transaction_id"] as String)
316
+ map.putString("direction", call["direction"] as String)
317
+ map.putString("source_number", call["source_number"] as String)
318
+ map.putString("destination_number", call["destination_number"] as String)
319
+ map.putDouble("time_start_to_answer", (timeStartToAnswer ?: 0).toDouble())
320
+ map.putDouble("time_end", timeEnd.toDouble())
321
+ map.putString("sip_user", call["sip_user"] as String)
322
+ map.putString("disposition", call["disposition"] as String)
323
+ sendEvent(CALL_END, map)
324
+ } else {
325
+ promise.resolve(null)
326
+ }
264
327
  }
265
328
  }
266
329
 
267
330
  @ReactMethod
268
331
  fun toggleMute(promise: Promise) {
269
332
  mainScope.launch {
270
- var newStatus : Boolean? = null
333
+ var newStatus: Boolean? = null
271
334
  withContext(Dispatchers.Default) {
272
335
  try {
273
336
  newStatus = OmiClient.instance.toggleMute()
274
- } catch (_ : Throwable) {
337
+ } catch (_: Throwable) {
275
338
 
276
339
  }
277
340
  }
@@ -357,7 +420,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
357
420
  withContext(Dispatchers.Default) {
358
421
  try {
359
422
  OmiClient.instance.logout()
360
- } catch (_ : Throwable) {
423
+ } catch (_: Throwable) {
361
424
 
362
425
  }
363
426
  }
@@ -365,6 +428,80 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
365
428
  }
366
429
  }
367
430
 
431
+ @ReactMethod
432
+ fun getCurrentUser(promise: Promise) {
433
+ mainScope.launch {
434
+ var callResult: Any? = null
435
+ withContext(Dispatchers.Default) {
436
+ try {
437
+ callResult = OmiClient.instance.getCurrentUser()
438
+ } catch (_: Throwable) {
439
+
440
+ }
441
+ }
442
+ if (callResult != null && callResult is Map<*, *>) {
443
+ val call = callResult as Map<*, *>
444
+ val map: WritableMap = WritableNativeMap()
445
+ map.putString("extension", call["extension"] as String?)
446
+ map.putString("uuid", call["uuid"] as String?)
447
+ map.putString("full_name", call["full_name"] as String?)
448
+ map.putString("avatar_url", call["avatar_url"] as String?)
449
+ promise.resolve(map)
450
+ } else {
451
+ promise.resolve(null);
452
+ }
453
+ }
454
+ }
455
+
456
+ @ReactMethod
457
+ fun getGuestUser(promise: Promise) {
458
+ mainScope.launch {
459
+ var callResult: Any? = null
460
+ withContext(Dispatchers.Default) {
461
+ try {
462
+ callResult = OmiClient.instance.getIncomingCallUser()
463
+ } catch (_: Throwable) {
464
+
465
+ }
466
+ }
467
+ if (callResult != null && callResult is Map<*, *>) {
468
+ val call = callResult as Map<*, *>
469
+ val map: WritableMap = WritableNativeMap()
470
+ map.putString("extension", call["extension"] as String?)
471
+ map.putString("uuid", call["uuid"] as String?)
472
+ map.putString("full_name", call["full_name"] as String?)
473
+ map.putString("avatar_url", call["avatar_url"] as String?)
474
+ promise.resolve(map)
475
+ } else {
476
+ promise.resolve(null);
477
+ }
478
+ }
479
+ }
480
+
481
+ @ReactMethod
482
+ fun getUserInfo(phone: Any, promise: Promise) {
483
+ mainScope.launch {
484
+ var callResult: Any? = null
485
+ withContext(Dispatchers.Default) {
486
+ try {
487
+ callResult = OmiClient.instance.getUserInfo(phone as String)
488
+ } catch (_: Throwable) {
489
+ }
490
+ }
491
+ if (callResult != null && callResult is Map<*, *>) {
492
+ val call = callResult as Map<*, *>
493
+ val map: WritableMap = WritableNativeMap()
494
+ map.putString("extension", call["extension"] as String?)
495
+ map.putString("uuid", call["uuid"] as String?)
496
+ map.putString("full_name", call["full_name"] as String?)
497
+ map.putString("avatar_url", call["avatar_url"] as String?)
498
+ promise.resolve(map)
499
+ } else {
500
+ promise.resolve(null);
501
+ }
502
+ }
503
+ }
504
+
368
505
  companion object {
369
506
  const val NAME = "OmikitPlugin"
370
507
  fun onDestroy() {
@@ -390,7 +527,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
390
527
  }
391
528
  }
392
529
 
393
- private fun requestPermission(isVideo : Boolean) {
530
+ private fun requestPermission(isVideo: Boolean) {
394
531
  var permissions = arrayOf(
395
532
  Manifest.permission.USE_SIP,
396
533
  Manifest.permission.CALL_PHONE,
@@ -415,4 +552,18 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
415
552
  reactApplicationContext!!.getSystemService(Context.CAMERA_SERVICE) as CameraManager
416
553
  OmiClient.instance.setCameraManager(cm)
417
554
  }
555
+
556
+ override fun onActivityResult(p0: Activity?, p1: Int, p2: Int, p3: Intent?) {
557
+
558
+ }
559
+
560
+ override fun onNewIntent(p0: Intent?) {
561
+ if (p0 != null && p0.hasExtra(SipServiceConstants.PARAM_NUMBER)) {
562
+ //do your Stuff
563
+ val map: WritableMap = WritableNativeMap()
564
+ map.putString("callerNumber", p0.getStringExtra(SipServiceConstants.PARAM_NUMBER) ?: "")
565
+ map.putBoolean("isVideo", p0.getBooleanExtra(SipServiceConstants.PARAM_IS_VIDEO, false))
566
+ sendEvent(CLICK_MISSED_CALL, map)
567
+ }
568
+ }
418
569
  }
@@ -21,6 +21,9 @@ const val SET_OUTPUT = "SET_OUTPUT"
21
21
  const val JOIN_CALL = "JOIN_CALL"
22
22
  const val START_CALL_WITH_UUID = "START_CALL_WITH_UUID"
23
23
  const val LOG_OUT = "LOG_OUT"
24
+ const val GET_CURRENT_USER = "GET_CURRENT_USER"
25
+ const val GET_GUEST_USER = "GET_GUEST_USER"
26
+ const val GET_USER_INFO = "GET_USER_INFO"
24
27
 
25
28
  //LISTENER
26
29
  const val CALL_ESTABLISHED = "CALL_ESTABLISHED"
@@ -29,3 +32,4 @@ const val INCOMING_RECEIVED = "INCOMING_RECEIVED"
29
32
  const val VIDEO = "VIDEO"
30
33
  const val SPEAKER = "SPEAKER"
31
34
  const val MUTED = "MUTED"
35
+ const val CLICK_MISSED_CALL = "CLICK_MISSED_CALL"
@@ -18,6 +18,8 @@ class CallManager {
18
18
  private let omiLib = OMISIPLib.sharedInstance()
19
19
  var videoManager: OMIVideoViewManager?
20
20
  var isSpeaker = false
21
+ private var guestPhone : String = ""
22
+ private var lastStatusCall : String?
21
23
 
22
24
  /// Get instance
23
25
  static func shareInstance() -> CallManager {
@@ -87,9 +89,50 @@ class CallManager {
87
89
  name: NSNotification.Name.OMICallDealloc,
88
90
  object: nil
89
91
  )
92
+ self.showMissedCall()
90
93
  }
91
94
  }
92
95
 
96
+ func configNotification(data: [String: Any]) {
97
+ if let title = data["missedCallTitle"] as? String, let message = data["prefixMissedCallMessage"] as? String {
98
+ let user = UserDefaults.standard
99
+ user.set(title, forKey: "missedCallTitle")
100
+ user.set(message, forKey: "prefixMissedCallMessage")
101
+ }
102
+ }
103
+
104
+ func showMissedCall() {
105
+ OmiClient.setMissedCall { call in
106
+ UNUserNotificationCenter.current().getNotificationSettings { settings in
107
+ switch settings.authorizationStatus {
108
+ case .notDetermined:
109
+ break
110
+ case .authorized, .provisional:
111
+ let user = UserDefaults.standard
112
+ let title = user.string(forKey: "missedCallTitle") ?? ""
113
+ let message = user.string(forKey: "prefixMissedCallMessage") ?? ""
114
+ let content = UNMutableNotificationContent()
115
+ content.title = title
116
+ content.body = "\(message) \(call.callerNumber!)"
117
+ content.sound = .default
118
+ content.userInfo = [
119
+ "omisdkCallerNumber": call.callerNumber,
120
+ "omisdkIsVideo": call.isVideo,
121
+ ]
122
+ let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 1, repeats: false)
123
+ //getting the notification request
124
+ let id = Int.random(in: 0..<10000000)
125
+ let request = UNNotificationRequest(identifier: "\(id)", content: content, trigger: trigger)
126
+ //adding the notification to notification center
127
+ UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)
128
+ default:
129
+ break // Do nothing
130
+ }
131
+ }
132
+ }
133
+ }
134
+
135
+
93
136
  func registerVideoEvent() {
94
137
  DispatchQueue.main.async {
95
138
  NotificationCenter.default.addObserver(CallManager.instance!,
@@ -134,8 +177,11 @@ class CallManager {
134
177
  if (self.videoManager != nil) {
135
178
  self.videoManager = nil
136
179
  }
180
+ let callInfo = self.getCallInfo(call: call)
181
+ self.lastStatusCall = nil
182
+ self.guestPhone = ""
137
183
  DispatchQueue.main.async {
138
- OmikitPlugin.instance.sendEvent(withName: CALL_END, body: [:])
184
+ OmikitPlugin.instance.sendEvent(withName: CALL_END, body: callInfo)
139
185
  }
140
186
  }
141
187
  }
@@ -170,6 +216,7 @@ class CallManager {
170
216
  videoManager = OMIVideoViewManager.init()
171
217
  }
172
218
  isSpeaker = call.isVideo
219
+ lastStatusCall = "answered"
173
220
  OmikitPlugin.instance.sendEvent(withName: CALL_ESTABLISHED, body: ["isVideo": call.isVideo, "callerNumber": call.callerNumber])
174
221
  OmikitPlugin.instance.sendMuteStatus()
175
222
  OmikitPlugin.instance.sendSpeakerStatus()
@@ -180,22 +227,19 @@ class CallManager {
180
227
  } else if (!call.userDidHangUp) {
181
228
  NSLog("Call remotly ended, in DISCONNECTED state, with UUID: \(call.uuid)")
182
229
  }
230
+ let callInfo = getCallInfo(call: call)
183
231
  if (videoManager != nil) {
184
232
  videoManager = nil
185
233
  }
234
+ lastStatusCall = nil
235
+ guestPhone = ""
186
236
  print(call.uuid.uuidString)
187
- OmikitPlugin.instance.sendEvent(withName: CALL_END, body: [:])
237
+ OmikitPlugin.instance.sendEvent(withName: CALL_END, body: callInfo)
188
238
  break
189
239
  case .incoming:
240
+ guestPhone = call.callerNumber ?? ""
190
241
  OmikitPlugin.instance.sendEvent(withName: INCOMING_RECEIVED, body: ["isVideo": call.isVideo, "callerNumber": call.callerNumber ?? ""])
191
242
  break
192
- case .muted:
193
- print("muteddddddd")
194
- break
195
- case .hold:
196
- print("holdddddddd")
197
- break
198
-
199
243
  default:
200
244
  NSLog("Default call state")
201
245
  break
@@ -204,30 +248,41 @@ class CallManager {
204
248
 
205
249
  /// Start call
206
250
  func startCall(_ phoneNumber: String, isVideo: Bool) -> Bool {
207
- if (isVideo) {
208
- return OmiClient.startVideoCall(phoneNumber)
251
+ guestPhone = phoneNumber
252
+ let auth = AVAudioSession.sharedInstance().recordPermission
253
+ if (auth == .granted) {
254
+ if (isVideo) {
255
+ return OmiClient.startVideoCall(phoneNumber)
256
+ }
257
+ return OmiClient.startCall(phoneNumber)
209
258
  }
210
- return OmiClient.startCall(phoneNumber)
259
+ return false
211
260
  }
212
261
 
213
262
  /// Start call
214
263
  func startCallWithUuid(_ uuid: String, isVideo: Bool) -> Bool {
215
- let phoneNumber = OmiClient.getPhone(uuid)
216
- if let phone = phoneNumber {
217
- if (isVideo) {
218
- return OmiClient.startVideoCall(phone)
264
+ let auth = AVAudioSession.sharedInstance().recordPermission
265
+ if (auth == .granted) {
266
+ let phoneNumber = OmiClient.getPhone(uuid)
267
+ if let phone = phoneNumber {
268
+ guestPhone = phoneNumber ?? ""
269
+ if (isVideo) {
270
+ return OmiClient.startVideoCall(phone)
271
+ }
272
+ return OmiClient.startCall(phone)
219
273
  }
220
- return OmiClient.startCall(phone)
221
274
  }
222
275
  return false
223
276
  }
224
277
 
225
- func endAvailableCall() {
278
+ func endAvailableCall() -> [String: Any] {
226
279
  guard let call = getAvailableCall() else {
227
280
  OmikitPlugin.instance.sendEvent(withName: CALL_END, body: [:])
228
- return
281
+ return [:]
229
282
  }
283
+ let callInfo = getCallInfo(call: call)
230
284
  omiLib.callManager.end(call)
285
+ return callInfo
231
286
  }
232
287
 
233
288
  func endAllCalls() {
@@ -279,6 +334,23 @@ class CallManager {
279
334
  OmiClient.logout()
280
335
  }
281
336
 
337
+ func getCurrentUser(completion: @escaping (([String: Any]) -> Void)) {
338
+ let prefs = UserDefaults.standard
339
+ if let user = prefs.value(forKey: "User") as? String {
340
+ getUserInfo(phone: user, completion: completion)
341
+ }
342
+ }
343
+
344
+ func getGuestUser(completion: @escaping (([String: Any]) -> Void)) {
345
+ getUserInfo(phone: guestPhone, completion: completion)
346
+ }
347
+
348
+ func getUserInfo(phone: String, completion: @escaping (([String: Any]) -> Void)) {
349
+ if let account = OmiClient.getAccountInfo(phone) as? [String: Any] {
350
+ completion(account)
351
+ }
352
+ }
353
+
282
354
  func inputs() -> [[String: String]] {
283
355
  let inputs = AVAudioSession.sharedInstance().availableInputs ?? []
284
356
  let results = inputs.map { item in
@@ -353,28 +425,35 @@ class CallManager {
353
425
  }
354
426
  }
355
427
 
356
- func getLocalPreviewView(callback: @escaping (UIView) -> Void) {
357
- guard let videoManager = videoManager else { return }
358
- videoManager.localView {previewView in
359
- DispatchQueue.main.async {
360
- if (previewView != nil) {
361
- previewView!.contentMode = .scaleAspectFill
362
- callback(previewView!)
363
- }
364
- }
365
- }
428
+ func getLocalPreviewView(frame: CGRect) -> UIView? {
429
+ guard let videoManager = videoManager else { return nil}
430
+ return videoManager.createView(forVideoLocal: frame)
366
431
  }
367
432
 
368
- func getRemotePreviewView(callback: @escaping (UIView) -> Void) {
369
- guard let videoManager = videoManager else { return }
370
- videoManager.remoteView { previewView in
371
- DispatchQueue.main.async {
372
- if (previewView != nil) {
373
- previewView!.contentMode = .scaleAspectFill
374
- callback(previewView!)
375
- }
376
- }
377
- }
433
+ func getRemotePreviewView(frame: CGRect) -> UIView? {
434
+ guard let videoManager = videoManager else { return nil }
435
+ return videoManager.createView(forVideoRemote: frame)
436
+ }
437
+
438
+ private func getCallInfo(call: OMICall) -> [String: Any] {
439
+ var direction = "outbound"
440
+ if (guestPhone.count < 10) {
441
+ direction = "inbound"
442
+ }
443
+ let prefs = UserDefaults.standard
444
+ let user = prefs.value(forKey: "User") as? String
445
+ let status = call.callState == .confirmed ? "answered" : "no_answered"
446
+ let timeEnd = Int(Date().timeIntervalSince1970)
447
+ return [
448
+ "transaction_id" : call.omiId,
449
+ "direction" : direction,
450
+ "source_number" : user,
451
+ "destination_number" : guestPhone,
452
+ "time_start_to_answer" : call.createDate,
453
+ "time_end" : timeEnd,
454
+ "sip_user": user,
455
+ "disposition" : lastStatusCall == nil ? "no_answered" : "answered",
456
+ ]
378
457
  }
379
458
  }
380
459
 
@@ -29,6 +29,11 @@ let SET_OUTPUT = "SET_OUTPUT"
29
29
  let JOIN_CALL = "JOIN_CALL"
30
30
  let START_CALL_WITH_UUID = "START_CALL_WITH_UUID"
31
31
  let LOG_OUT = "LOG_OUT"
32
+ let REGISTER_VIDEO_EVENT = "REGISTER_VIDEO_EVENT"
33
+ let REMOVE_VIDEO_EVENT = "REMOVE_VIDEO_EVENT"
34
+ let GET_CURRENT_USER = "GET_CURRENT_USER"
35
+ let GET_GUEST_USER = "GET_GUEST_USER"
36
+ let GET_USER_INFO = "GET_USER_INFO"
32
37
 
33
38
  //LISTENER
34
39
  let CALL_ESTABLISHED = "CALL_ESTABLISHED"
@@ -39,5 +44,5 @@ let SPEAKER = "SPEAKER"
39
44
  let MUTED = "MUTED"
40
45
  let LOCAL_VIDEO_READY = "LOCAL_VIDEO_READY"
41
46
  let REMOTE_VIDEO_READY = "REMOTE_VIDEO_READY"
42
-
47
+ let CLICK_MISSED_CALL = "CLICK_MISSED_CALL"
43
48
 
@@ -0,0 +1,17 @@
1
+ //
2
+ // OmikitNotification.h
3
+ // Pods
4
+ //
5
+ // Created by PRO 2019 16' on 20/04/2023.
6
+ //
7
+
8
+ #ifndef OmikitNotification_h
9
+ #define OmikitNotification_h
10
+
11
+
12
+ #endif /* OmikitNotification_h */
13
+
14
+ @interface OmikitNotification
15
+ + (void)didRecieve:(NSDictionary*) userInfo;
16
+
17
+ @end
@@ -0,0 +1,15 @@
1
+ //
2
+ // OmikitNotification.m
3
+ // DoubleConversion
4
+ //
5
+ // Created by PRO 2019 16' on 20/04/2023.
6
+ //
7
+
8
+ #import <Foundation/Foundation.h>
9
+ #import "omikit_plugin-Swift.h"
10
+
11
+ @implementation OmikitNotification : NSObject
12
+ + (void)didRecieve:(NSDictionary*) userInfo{
13
+ [[OmikitPlugin instance] didReceiveWithData:userInfo];
14
+ }
15
+ @end
@@ -6,9 +6,9 @@ RCT_EXTERN_METHOD(startServices:
6
6
  (RCTPromiseResolveBlock)resolve
7
7
  withRejecter:(RCTPromiseRejectBlock)reject)
8
8
 
9
- RCT_EXTERN_METHOD(configPushNotification:
10
- (RCTPromiseResolveBlock)resolve
11
- withRejecter:(RCTPromiseRejectBlock)reject)
9
+ RCT_EXTERN_METHOD(configPushNotification:(id)data
10
+ withResolver:(RCTPromiseResolveBlock)resolve
11
+ withRejecter:(RCTPromiseRejectBlock)reject)
12
12
 
13
13
  RCT_EXTERN_METHOD(getInitialCall:
14
14
  (RCTPromiseResolveBlock)resolve
@@ -69,6 +69,15 @@ RCT_EXTERN_METHOD(registerVideoEvent:
69
69
  RCT_EXTERN_METHOD(removeVideoEvent:
70
70
  (RCTPromiseResolveBlock)resolve
71
71
  withRejecter:(RCTPromiseRejectBlock)reject)
72
+ RCT_EXTERN_METHOD(getCurrentUser:
73
+ (RCTPromiseResolveBlock)resolve
74
+ withRejecter:(RCTPromiseRejectBlock)reject)
75
+ RCT_EXTERN_METHOD(getGuestUser:
76
+ (RCTPromiseResolveBlock)resolve
77
+ withRejecter:(RCTPromiseRejectBlock)reject)
78
+ RCT_EXTERN_METHOD(getUserInfo: (id)data
79
+ withResolver:(RCTPromiseResolveBlock)resolve
80
+ withRejecter:(RCTPromiseRejectBlock)reject)
72
81
 
73
82
  + (BOOL)requiresMainQueueSetup
74
83
  {