capacitor-plugin-vonage 0.0.5 → 0.0.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.
@@ -14,7 +14,7 @@ Pod::Spec.new do |s|
14
14
  s.ios.deployment_target = '13.0'
15
15
  s.dependency 'Capacitor'
16
16
  #s.dependency 'OpenTok','2.25.0'
17
- s.dependency 'OTXCFramework','2.26.1'
17
+ s.dependency 'OTXCFramework','2.26.2'
18
18
  s.swift_version = '5.1'
19
19
  s.static_framework = true
20
20
  end
@@ -49,6 +49,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
49
49
  var subscriberImg = UIImageView()
50
50
  var counter = 0
51
51
  var timer = Timer()
52
+ var activityView: UIActivityIndicatorView?
52
53
  override func viewDidLoad() {
53
54
 
54
55
  super.viewDidLoad()
@@ -56,6 +57,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
56
57
  self.view.backgroundColor = .white
57
58
  NotificationCenter.default.addObserver(self, selector: #selector(appMovedToBackground), name: UIApplication.willResignActiveNotification, object: nil)
58
59
  NotificationCenter.default.addObserver(self, selector: #selector(appMovedToForeground), name: UIApplication.willEnterForegroundNotification, object: nil)
60
+ showActivityIndicator()
59
61
  self.viewSetupMethod()
60
62
  // let jsonParam = videoCallParam.toJSON() as? [String:AnyObject] // can be any type here
61
63
  // print(jsonParam as Any)
@@ -113,13 +115,28 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
113
115
  // }
114
116
  // turnOnAndOffVideo()
115
117
  }
118
+ func showActivityIndicator() {
119
+ activityView = UIActivityIndicatorView(style: .large)
120
+ activityView?.center = self.view.center
121
+ activityView?.layer.zPosition = 20;
122
+ self.view.addSubview(activityView!)
123
+ activityView?.startAnimating()
124
+ }
125
+
126
+ func hideActivityIndicator(){
127
+ if (activityView != nil){
128
+ activityView?.stopAnimating()
129
+ }
130
+ }
116
131
  override func viewDidDisappear(_ animated: Bool) {
117
132
  print("viewDidDisappear")
118
133
  super.viewDidDisappear(animated)
119
134
  let userInfo = ["userInfo": ["isProvider": self.isProvider]]
120
135
  NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoEnded),object: nil,userInfo: userInfo)
136
+
121
137
  // NotificationCenter.default.removeObserver(self, name: NSNotification.Name("EndVideoCall"), object: nil)
122
138
  NotificationCenter.default.removeObserver(self)
139
+ NotificationCenter.default.post(name: NSNotification.Name("RemoveObservers"),object: nil,userInfo: userInfo)
123
140
  }
124
141
  @objc func appMovedToBackground() {
125
142
  print("App moved to background!")
@@ -136,13 +153,22 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
136
153
  }
137
154
  @objc func setPatientOnlineStatus(_ notification: Notification) {
138
155
  // let userinfo = notification.userInfo?["isOnline"] as? Bool
139
-
140
- if let isOnline = notification.userInfo?["isOnline"] as? Bool , !isCallInProgress {
141
- isPatientOnLine = isOnline
156
+ if(!isCallInProgress){
157
+ if let ispatientOnline = notification.userInfo?["isOnline"] as? Bool{
158
+ isPatientOnLine = ispatientOnline
159
+ }else{
160
+ isPatientOnLine = false
161
+ }
142
162
  DispatchQueue.main.async {
143
163
  self.patientStatusChanged()
144
164
  }
145
165
  }
166
+ // if let isOnline = notification.userInfo?["isOnline"] as? Bool , !isCallInProgress {
167
+ // isPatientOnLine = isOnline
168
+ // DispatchQueue.main.async {
169
+ // self.patientStatusChanged()
170
+ // }
171
+ // }
146
172
 
147
173
  }
148
174
  @objc func endVideoCall(_ notification: Notification){
@@ -155,8 +181,11 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
155
181
  timer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(timerAction), userInfo: nil, repeats: true)
156
182
  }
157
183
  func stopTimer(){
158
- timer.invalidate()
159
- counter = 0
184
+ if(timer.isValid){
185
+ timer.invalidate()
186
+ counter = 0
187
+ }
188
+
160
189
  }
161
190
  @objc func timerAction() {
162
191
  counter += 1
@@ -194,7 +223,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
194
223
  //subscriberLabel.backgroundColor = UIColor(red: 31/255, green: 33/255, blue: 36/255, alpha: 1.0)
195
224
  subscriberLabel.textColor = .white//UIColor(hex: "#000000")
196
225
  subscriberLabel.textAlignment = .left
197
- subscriberLabel.font = subscriberLabel.font.withSize(dynamicFontSize(15))
226
+ subscriberLabel.font = subscriberLabel.font.withSize(dynamicFontSize(UIDevice.current.userInterfaceIdiom == .pad ? 10 : 15))
198
227
  subscriberLabel.layer.zPosition = 1;
199
228
 
200
229
  timerLabel = UILabel(frame: CGRect(x: 30, y: Int(screenHeight) - 155, width: Int(remoteView.frame.size.width - 140), height: 40))
@@ -202,7 +231,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
202
231
  //subscriberLabel.backgroundColor = UIColor(red: 31/255, green: 33/255, blue: 36/255, alpha: 1.0)
203
232
  timerLabel.textColor = .black//UIColor(hex: "#000000")
204
233
  timerLabel.textAlignment = .left
205
- timerLabel.font = timerLabel.font.withSize(dynamicFontSize(15))
234
+ timerLabel.font = timerLabel.font.withSize(dynamicFontSize(UIDevice.current.userInterfaceIdiom == .pad ? 10 : 15))
206
235
  timerLabel.layer.zPosition = 1;
207
236
  let dummmyUrl = "https://www.gravatar.com/avatar/?d=mp"
208
237
  let url = URL(string: profilePicApiUrl.count > 10 ? profilePicApiUrl : dummmyUrl)!
@@ -220,6 +249,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
220
249
  subscriberImg.frame = CGRect(x: (centerView.frame.width / 2) - 90, y: 0, width: 180, height: 180)
221
250
  subscriberImg.layer.cornerRadius = 90
222
251
  subscriberImg.clipsToBounds = true
252
+ subscriberImg.contentMode = .scaleAspectFill
223
253
  //subscriberImg.center = CGPoint(x: self.view.frame.size.width / 2, y: 0)
224
254
  //subscriberImg.center.x = remoteView.center.x - 70
225
255
  //subscriberImg.center.y = centerView.center.y - 100
@@ -236,7 +266,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
236
266
  subscriberNameLabel.backgroundColor = .clear
237
267
  subscriberNameLabel.textColor = UIColor(hex: "#000000")
238
268
  subscriberNameLabel.textAlignment = .center
239
- subscriberNameLabel.font = UIFont.boldSystemFont(ofSize: dynamicFontSize(20))
269
+ subscriberNameLabel.font = UIFont.boldSystemFont(ofSize: dynamicFontSize(UIDevice.current.userInterfaceIdiom == .pad ? 10 : 20 ))
240
270
 
241
271
  adminBtn = UIButton(frame: CGRect(x: (centerView.frame.width/2) - 10 - 100, y: 275, width: 100, height: 50))
242
272
  adminBtn.backgroundColor = UIColor(hex: "#DFF6ED")
@@ -245,18 +275,18 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
245
275
  adminBtn.layer.cornerRadius = 10
246
276
  adminBtn.setTitleColor(UIColor(hex: "#000000"), for: .normal)
247
277
  adminBtn.setTitle("ADMIT", for: .normal)
248
- adminBtn.titleLabel?.font = UIFont.boldSystemFont(ofSize: dynamicFontSize(15))
278
+ adminBtn.titleLabel?.font = UIFont.boldSystemFont(ofSize: dynamicFontSize(UIDevice.current.userInterfaceIdiom == .pad ? 10 : 15))
249
279
  // adminBtn.setBackgroundImage(UIImage(named: "callEnd"), for: .normal)
250
280
  adminBtn.addTarget(self, action:#selector(self.adminbuttonClicked), for: .touchUpInside)
251
-
252
- sendNotificationBtn = UIButton(frame: CGRect(x: (centerView.frame.width/2) - 110, y: 275, width: 220, height: 50))
281
+ let sendBtnWidth = UIDevice.current.userInterfaceIdiom == .pad ? 270 : 220
282
+ sendNotificationBtn = UIButton(frame: CGRect(x: (Int(centerView.frame.width)/2) - (sendBtnWidth/2), y: 275, width: sendBtnWidth, height: 50))
253
283
  sendNotificationBtn.backgroundColor = UIColor(hex: "#DFF6ED")
254
284
  sendNotificationBtn.layer.borderColor = UIColor(hex: "#60D2A7").cgColor
255
285
  sendNotificationBtn.layer.borderWidth = 2
256
286
  sendNotificationBtn.layer.cornerRadius = 10
257
287
  sendNotificationBtn.setTitleColor(UIColor(hex: "#000000"), for: .normal)
258
288
  sendNotificationBtn.setTitle(isPatientFromWeb ? "SEND EMAIL NOTIFICATION" : "SEND NOTIFICATION", for: .normal)
259
- sendNotificationBtn.titleLabel?.font = UIFont.boldSystemFont(ofSize: dynamicFontSize(15))
289
+ sendNotificationBtn.titleLabel?.font = UIFont.boldSystemFont(ofSize: dynamicFontSize(UIDevice.current.userInterfaceIdiom == .pad ? 7 : 15))
260
290
  // adminBtn.setBackgroundImage(UIImage(named: "callEnd"), for: .normal)
261
291
  sendNotificationBtn.addTarget(self, action:#selector(self.sendNotificationbuttonClicked), for: .touchUpInside)
262
292
 
@@ -267,7 +297,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
267
297
  denyBtn.layer.cornerRadius = 10
268
298
  denyBtn.setTitleColor(UIColor(hex: "#000000"), for: .normal)
269
299
  denyBtn.setTitle("DENY", for: .normal)
270
- denyBtn.titleLabel?.font = UIFont.boldSystemFont(ofSize: dynamicFontSize(15))
300
+ denyBtn.titleLabel?.font = UIFont.boldSystemFont(ofSize: dynamicFontSize(UIDevice.current.userInterfaceIdiom == .pad ? 10 : 15))
271
301
  // adminBtn.setBackgroundImage(UIImage(named: "callEnd"), for: .normal)
272
302
  denyBtn.addTarget(self, action:#selector(self.denybuttonClicked), for: .touchUpInside)
273
303
 
@@ -298,6 +328,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
298
328
 
299
329
  localView.layer.cornerRadius = 10;
300
330
  localView.clipsToBounds = true
331
+ localView.isHidden = true
301
332
 
302
333
  publisherLabel = UILabel(frame: CGRect(x: 0, y: Int(localView.frame.size.height - 40.0), width: Int(localView.frame.size.width), height: 40))
303
334
  publisherLabel.text = publisherName
@@ -305,29 +336,29 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
305
336
  publisherLabel.textColor = .white//UIColor(hex: "#000000")
306
337
  publisherLabel.textAlignment = .center
307
338
  publisherLabel.layer.zPosition = 1;
308
- publisherLabel.font = publisherLabel.font.withSize(dynamicFontSize(15))
339
+ publisherLabel.font = publisherLabel.font.withSize(dynamicFontSize(UIDevice.current.userInterfaceIdiom == .pad ? 10 : 15))
309
340
  localView.addSubview(publisherLabel)
310
341
  self.view.addSubview(localView)
311
342
 
312
- callBtn = UIButton(frame: CGRect(x: 0, y: 0, width: 60, height: 60))
343
+ callBtn = UIButton(frame: CGRect(x: 240, y: 0, width: 60, height: 60))
313
344
  callBtn.backgroundColor = .clear
314
345
  callBtn.setBackgroundImage(UIImage(named: "callEnd"), for: .normal)
315
346
  callBtn.addTarget(self, action:#selector(self.callBtnbuttonClicked), for: .touchUpInside)
316
347
  bottomView.addSubview(callBtn)
317
348
 
318
- camaraBtn = UIButton(frame: CGRect(x: 80, y: 0, width: 60, height: 60))
349
+ camaraBtn = UIButton(frame: CGRect(x: 0, y: 0, width: 60, height: 60))
319
350
  camaraBtn.backgroundColor = .clear
320
351
  camaraBtn.setBackgroundImage(UIImage(named: "cameraSwitch"), for: .normal)
321
352
  camaraBtn.addTarget(self, action:#selector(self.camaraBtnbuttonClicked), for: .touchUpInside)
322
353
  bottomView.addSubview(camaraBtn)
323
354
 
324
- videoBtn = UIButton(frame: CGRect(x: 160, y: 0, width: 60, height: 60))
355
+ videoBtn = UIButton(frame: CGRect(x: 80, y: 0, width: 60, height: 60))
325
356
  videoBtn.backgroundColor = .clear
326
357
  videoBtn.setBackgroundImage(UIImage(named: "cameraOnWhite"), for: .normal)
327
358
  videoBtn.addTarget(self, action:#selector(self.videoBtnbuttonClicked), for: .touchUpInside)
328
359
  bottomView.addSubview(videoBtn)
329
360
 
330
- audioBtn = UIButton(frame: CGRect(x: 240, y: 0, width: 60, height: 60))
361
+ audioBtn = UIButton(frame: CGRect(x: 160, y: 0, width: 60, height: 60))
331
362
  audioBtn.backgroundColor = .clear
332
363
  audioBtn.setBackgroundImage(UIImage(named: "microphoneOnWhite"), for: .normal)
333
364
  audioBtn.addTarget(self, action:#selector(self.audioBtnbuttonClicked), for: .touchUpInside)
@@ -339,6 +370,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
339
370
  if(!isCallEnded){
340
371
  let userInfo = ["userInfo": ["isProvider": self.isProvider]]
341
372
  NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoEnded),object: nil,userInfo: userInfo)
373
+ NotificationCenter.default.post(name: NSNotification.Name("RemoveObservers"),object: nil,userInfo: userInfo)
342
374
  }
343
375
 
344
376
  }
@@ -406,19 +438,19 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
406
438
  print("deny button clicked")
407
439
  centerView.isHidden = true
408
440
  let userInfo = ["userInfo": ["isProvider": isProvider]]
441
+
409
442
  NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoEnded),object: nil,userInfo: userInfo)
410
443
  self.session?.disconnect(nil)
411
444
  self.stopTimer()
412
445
  self.dismiss(animated: true, completion: nil)
446
+ NotificationCenter.default.post(name: NSNotification.Name("RemoveObservers"),object: nil,userInfo: userInfo)
413
447
  }
414
448
 
415
449
  @objc func callBtnbuttonClicked() {
416
450
 
417
451
  let userInfo = ["userInfo": ["isProvider": isProvider]]
418
452
  NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoEnded),object: nil,userInfo: userInfo)
419
- self.session?.disconnect(nil)
420
- self.stopTimer()
421
- self.dismiss(animated: true, completion: nil)
453
+ self.endVonageCall()
422
454
  }
423
455
 
424
456
  @objc func camaraBtnbuttonClicked() {
@@ -453,6 +485,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
453
485
  if (self.isAudioMute) {
454
486
 
455
487
  self.publisher?.publishAudio = true
488
+ //self.publisher.del
456
489
  self.audioBtn.setImage(UIImage(named : "microphoneOnWhite"), for: .normal)
457
490
  self.isAudioMute = false
458
491
  } else {
@@ -474,6 +507,8 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
474
507
 
475
508
  //session methods
476
509
  func sessionDidConnect(_ session: OTSession) {
510
+ hideActivityIndicator()
511
+ localView.isHidden = false
477
512
  print("The client connected to the OpenTok session.")
478
513
  let userInfo = ["userInfo": ["isProvider": isProvider]]
479
514
  // NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoStarted),object: nil,userInfo: userInfo)
@@ -562,8 +597,9 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
562
597
  // cleanupSubscriber()
563
598
  let userInfo = ["userInfo": ["isProvider": isProvider]]
564
599
  NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoEnded),object: nil,userInfo: userInfo)
565
- self.session?.disconnect(nil)
566
- self.dismiss(animated: true, completion: nil)
600
+ // self.session?.disconnect(nil)
601
+ self.endVonageCall()
602
+ //self.dismiss(animated: true, completion: nil)
567
603
  }
568
604
  if(stream.videoType != .screen){
569
605
  subscriberImg.isHidden = false
@@ -639,18 +675,28 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
639
675
  @IBAction func endCallAction(_ sender: Any) {
640
676
  isCallEnded = true
641
677
  let userInfo = ["userInfo": ["isProvider": self.isProvider]]
678
+
642
679
  NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoEnded),object: nil,userInfo: userInfo)
643
680
  endVonageCall()
644
681
  }
645
682
  fileprivate func endVonageCall(){
646
683
  isCallEnded = true
684
+ let userInfo = ["userInfo": ["isProvider": self.isProvider]]
685
+ NotificationCenter.default.post(name: NSNotification.Name("RemoveObservers"),object: nil,userInfo: userInfo)
647
686
  DispatchQueue.main.async {
687
+ print("video ended called")
688
+ self.session?.disconnect(nil)
689
+
690
+ // self.publisher?.publishVideo = false
691
+ self.publisher?.videoCapture?.stop()
692
+ // self.publisher?.publishAudio = false
648
693
 
649
694
  self.cleanupSubscriber()
650
695
  self.cleanupPublisher()
651
- self.session?.disconnect(nil)
652
696
  self.stopTimer()
653
- // self.dismiss(animated: true, completion: nil)
697
+ self.dismiss(animated: true) {
698
+ print("video ended")
699
+ }
654
700
  }
655
701
  }
656
702
  fileprivate func cleanupSubscriber() {
@@ -34,7 +34,8 @@ public class vonagePlugin: CAPPlugin {
34
34
  }
35
35
  NotificationCenter.default.addObserver(self,selector:#selector(videoEnded(_:)),name: NSNotification.Name (NotificationNames.videoEnded),object: nil)
36
36
  NotificationCenter.default.addObserver(self,selector:#selector(videoStarted(_:)),name: NSNotification.Name (NotificationNames.videoStarted),object: nil)
37
- NotificationCenter.default.addObserver(self,selector:#selector(videoStarted(_:)),name: NSNotification.Name ("SendNotification"),object: nil)
37
+ NotificationCenter.default.addObserver(self,selector:#selector(sendNotification(_:)),name: NSNotification.Name ("SendNotification"),object: nil)
38
+ NotificationCenter.default.addObserver(self,selector:#selector(removeObservers(_:)),name: NSNotification.Name ("RemoveObservers"),object: nil)
38
39
  // if let visibleViewCtrl = UIApplication.topViewController() {
39
40
  // // do whatever you want with your `visibleViewCtrl`
40
41
  // print(visibleViewCtrl)
@@ -64,15 +65,18 @@ public class vonagePlugin: CAPPlugin {
64
65
  }
65
66
  @objc func videoEnded(_ notification: Notification){
66
67
  self.notifyListeners(NotificationNames.videoEnded, data: notification.userInfo?["userInfo"] as? [String: Any] ?? [:])
67
- NotificationCenter.default.removeObserver(self, name: NSNotification.Name(NotificationNames.videoEnded), object: nil)
68
+ // NotificationCenter.default.removeObserver(self, name: NSNotification.Name(NotificationNames.videoEnded), object: nil)
68
69
  }
69
70
  @objc func videoStarted(_ notification: Notification){
70
71
  self.notifyListeners(NotificationNames.videoStarted, data: notification.userInfo?["userInfo"] as? [String: Any] ?? [:])
71
- NotificationCenter.default.removeObserver(self, name: NSNotification.Name(NotificationNames.videoStarted), object: nil)
72
+ // NotificationCenter.default.removeObserver(self, name: NSNotification.Name(NotificationNames.videoStarted), object: nil)
72
73
  }
73
74
  @objc func sendNotification(_ notification: Notification){
74
75
  self.notifyListeners("SendNotification", data: notification.userInfo?["userInfo"] as? [String: Any] ?? [:])
75
- NotificationCenter.default.removeObserver(self, name: NSNotification.Name("SendNotification"), object: nil)
76
+ // NotificationCenter.default.removeObserver(self, name: NSNotification.Name("SendNotification"), object: nil)
77
+ }
78
+ @objc func removeObservers(_ notification: Notification){
79
+ NotificationCenter.default.removeObserver(self)
76
80
  }
77
81
  }
78
82
  extension UIApplication {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capacitor-plugin-vonage",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "opentok sdk capacitor plugin",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",