capacitor-plugin-vonage 0.1.2 → 0.1.4

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.
@@ -8,7 +8,7 @@
8
8
  import UIKit
9
9
  import OpenTok
10
10
 
11
- class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDelegate,OTSubscriberDelegate {
11
+ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDelegate,OTSubscriberDelegate,CustomeAlertDelegate {
12
12
  var isCallEnded = false
13
13
  var kApiKey = ""
14
14
  var kSessionId = ""
@@ -29,6 +29,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
29
29
  var session: OTSession?
30
30
  var publisher: OTPublisher?
31
31
  var subscriber: OTSubscriber?
32
+ var screenTypesubscriber: OTSubscriber?
32
33
 
33
34
  var bottomView = UIView()
34
35
  var remoteView = UIView()
@@ -59,6 +60,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
59
60
  NotificationCenter.default.addObserver(self, selector: #selector(appMovedToBackground), name: UIApplication.willResignActiveNotification, object: nil)
60
61
  NotificationCenter.default.addObserver(self, selector: #selector(appMovedToForeground), name: UIApplication.willEnterForegroundNotification, object: nil)
61
62
  showActivityIndicator()
63
+ UserDefaults.standard.set(isProvider, forKey: "isProvider")
62
64
  self.viewSetupMethod()
63
65
  // let jsonParam = videoCallParam.toJSON() as? [String:AnyObject] // can be any type here
64
66
  // print(jsonParam as Any)
@@ -104,6 +106,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
104
106
  super.viewDidAppear(animated)
105
107
  NotificationCenter.default.addObserver(self, selector: #selector(deviceOrientationDidChange), name: UIDevice.orientationDidChangeNotification, object: nil)
106
108
  NotificationCenter.default.addObserver(self, selector: #selector(setPatientOnlineStatus), name: NSNotification.Name ("PatientOnlineStatus"), object: nil)
109
+ NotificationCenter.default.addObserver(self, selector: #selector(notificationSent), name: NSNotification.Name ("notificationSent"), object: nil)
107
110
  NotificationCenter.default.addObserver(self,selector:#selector(endVideoCall(_:)),name: NSNotification.Name ("EndVideoCall"),object: nil)
108
111
 
109
112
  }
@@ -147,7 +150,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
147
150
  }
148
151
  @objc func setPatientOnlineStatus(_ notification: Notification) {
149
152
  // let userinfo = notification.userInfo?["isOnline"] as? Bool
150
- if(!isCallInProgress){
153
+ // if(!isCallInProgress){
151
154
  if let ispatientOnline = notification.userInfo?["isOnline"] as? Bool{
152
155
  isPatientOnLine = ispatientOnline
153
156
  }else{
@@ -156,7 +159,8 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
156
159
  DispatchQueue.main.async {
157
160
  self.patientStatusChanged()
158
161
  }
159
- }
162
+
163
+ // }
160
164
  // if let isOnline = notification.userInfo?["isOnline"] as? Bool , !isCallInProgress {
161
165
  // isPatientOnLine = isOnline
162
166
  // DispatchQueue.main.async {
@@ -165,6 +169,9 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
165
169
  // }
166
170
 
167
171
  }
172
+ @objc func notificationSent(_ notification: Notification) {
173
+ self.showToast(message: "Notification has been sent")
174
+ }
168
175
  @objc func endVideoCall(_ notification: Notification){
169
176
  print("end video call called")
170
177
  endVonageCall()
@@ -379,6 +386,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
379
386
  sendNotificationBtn.isHidden = true
380
387
  adminBtn.isHidden = false
381
388
  denyBtn.isHidden = false
389
+ subscriberStatusLabel.isHidden = false
382
390
  subscriberStatusLabel.text = "WAITING"
383
391
  subscriberStatusLabel.backgroundColor = UIColor(hex: "#DFF6ED")
384
392
  subscriberNameLabel.isHidden = false
@@ -387,6 +395,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
387
395
  sendNotificationBtn.isHidden = false
388
396
  adminBtn.isHidden = true
389
397
  denyBtn.isHidden = true
398
+ subscriberStatusLabel.isHidden = false
390
399
  subscriberStatusLabel.text = "OFFLINE"
391
400
  subscriberStatusLabel.backgroundColor = UIColor(hex: "#ffd6ca")
392
401
  subscriberNameLabel.isHidden = false
@@ -437,18 +446,23 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
437
446
  }
438
447
  @objc func denybuttonClicked() {
439
448
  print("deny button clicked")
449
+ // centerView.isHidden = true
450
+ // let userInfo = ["isProvider": isProvider]
451
+ // delegate?.videoCallEnded(userInfo)
452
+ // self.endVonageCall()
453
+ //delegate?.videoCallShowAlert()
454
+ let customAlert = CustomAlertViewController(nibName: "CustomAlertViewController", bundle: Bundle(for: CustomAlertViewController.self))
455
+ customAlert.isModalInPresentation = true
456
+ customAlert.delegate = self
457
+ customAlert.modalPresentationStyle = .popover
458
+ self.present(customAlert, animated: true)
459
+ }
460
+ func btnYesClicked() {
440
461
  centerView.isHidden = true
441
- let userInfo = ["isProvider": isProvider]
442
-
443
- // NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoEnded),object: nil,userInfo: userInfo)
462
+ let userInfo:[String:Any] = ["isProvider": isProvider,"message":"deny"]
444
463
  delegate?.videoCallEnded(userInfo)
445
- // self.session?.disconnect(nil)
446
- // self.stopTimer()
447
- // self.dismiss(animated: true, completion: nil)
448
- // NotificationCenter.default.post(name: NSNotification.Name("RemoveObservers"),object: nil,userInfo: userInfo)
449
464
  self.endVonageCall()
450
465
  }
451
-
452
466
  @objc func callBtnbuttonClicked() {
453
467
 
454
468
  let userInfo = ["isProvider": isProvider]
@@ -565,11 +579,11 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
565
579
  }
566
580
 
567
581
  func session(_ session: OTSession, streamCreated stream: OTStream) {
568
- subscriber = OTSubscriber(stream: stream, delegate: self)
582
+ var subscriber = OTSubscriber(stream: stream, delegate: self)
569
583
  guard let subscriber = subscriber else {
570
584
  return
571
585
  }
572
- self.subscriber = subscriber
586
+ //self.subscriber = subscriber
573
587
  var error: OTError?
574
588
  session.subscribe(subscriber, error: &error)
575
589
  guard error == nil else {
@@ -585,6 +599,10 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
585
599
  subscriberView.frame = UIScreen.main.bounds
586
600
  if(stream.videoType == .screen){
587
601
  subscriberView.accessibilityValue = "from screen"
602
+ subscriber.viewScaleBehavior = .fit
603
+ self.screenTypesubscriber = subscriber
604
+ }else{
605
+ self.subscriber = subscriber
588
606
  }
589
607
  timerLabel.textColor = .white
590
608
  publisherLabel.textColor = .white
@@ -624,7 +642,15 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
624
642
 
625
643
 
626
644
  }
627
-
645
+ func sessionDidBeginReconnecting(_ session:OTSession) {
646
+ // Display a user interface notification.
647
+ print("sessionDidBeginReconnecting \(session.sessionId)")
648
+ }
649
+
650
+ func sessionDidReconnect(_ session: OTSession) {
651
+ // Adjust user interface.
652
+ print("sessionDidReconnect \(session.sessionId)")
653
+ }
628
654
  //Publisher methods
629
655
  func publisher(_ publisher: OTPublisherKit, didFailWithError error: OTError) {
630
656
  print("The publisher failed: \(error)")
@@ -789,11 +815,12 @@ extension UIViewController {
789
815
 
790
816
  func showToast(message : String) {
791
817
  DispatchQueue.main.async {
792
- let toastLabel = UILabel(frame: CGRect(x: 100, y: 40, width: self.view.frame.size.width - 100, height: 50))
818
+ let spacing = UIDevice.current.userInterfaceIdiom == .pad ? 250 : 100
819
+ let toastLabel = UILabel(frame: CGRect(x: spacing, y: 40, width: Int(self.view.frame.size.width) - spacing, height: 50))
793
820
  // toastLabel.center.x = self.view.center.x
794
821
  toastLabel.backgroundColor = UIColor(hex: "#0B6623")//UIColor.white.withAlphaComponent(0.6)
795
822
  toastLabel.textColor = .white//UIColor.black
796
- toastLabel.font = .systemFont(ofSize: 12.0)
823
+ toastLabel.font = .systemFont(ofSize: 14.0)
797
824
  toastLabel.textAlignment = .center;
798
825
  toastLabel.text = message
799
826
  toastLabel.alpha = 1.0
@@ -8,4 +8,5 @@ CAP_PLUGIN(vonagePlugin, "vonage",
8
8
  CAP_PLUGIN_METHOD(openVideoCallWindow, CAPPluginReturnPromise);
9
9
  CAP_PLUGIN_METHOD(endVideoCall, CAPPluginReturnPromise);
10
10
  CAP_PLUGIN_METHOD(setPatientOnlineStatus, CAPPluginReturnPromise);
11
+ CAP_PLUGIN_METHOD(setSendNotificationStatus, CAPPluginReturnPromise);
11
12
  )
@@ -12,7 +12,9 @@ public class vonagePlugin: CAPPlugin,VonageSDKInteractionDelegate {
12
12
  let sessionId = call.getString("sessionId") ?? ""
13
13
  let apiKey = call.getString("apiKey") ?? ""
14
14
  let token = call.getString("token") ?? ""
15
-
15
+ print("token: \(token)")
16
+ print("apiKey: \(apiKey)")
17
+ print("sessionId: \(sessionId)")
16
18
  let publisherName = call.getString("publisherName") ?? ""
17
19
  let subscriberName = call.getString("subscriberName") ?? ""
18
20
  let isProvider = call.getBool("isProvider") ?? false //profilePicApiUrl
@@ -49,6 +51,14 @@ public class vonagePlugin: CAPPlugin,VonageSDKInteractionDelegate {
49
51
 
50
52
  call.resolve(["value": "setPatientOnlineStatus"])
51
53
  }
54
+ @objc func setSendNotificationStatus(_ call: CAPPluginCall) {
55
+
56
+ let isSuccess = call.getBool("isSuccess") ?? false
57
+
58
+ NotificationCenter.default.post(name: NSNotification.Name("notificationSent"),object: nil,userInfo: ["isSuccess":isSuccess])
59
+
60
+ call.resolve(["value": "setSendNotificationStatus"])
61
+ }
52
62
  @objc func endVideoCall(_ call: CAPPluginCall) {
53
63
  NotificationCenter.default.post(name: NSNotification.Name("EndVideoCall"),object: nil,userInfo: nil)
54
64
  call.resolve(["value": "Video call ended."])
@@ -106,3 +116,6 @@ func videoCallStarted(_ data: [String: Any])
106
116
  func videoCallEnded(_ data: [String: Any])
107
117
  func videoCallSendNotification(_ data: [String: Any])
108
118
  }
119
+ protocol CustomeAlertDelegate: AnyObject {
120
+ func btnYesClicked()
121
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capacitor-plugin-vonage",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "opentok sdk capacitor plugin",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",