capacitor-plugin-vonage 0.1.5 → 0.1.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.
@@ -50,6 +50,8 @@ import javax.annotation.Nullable;
50
50
  import pub.devrel.easypermissions.EasyPermissions;
51
51
  public class VideoCallActivity extends AppCompatActivity implements EasyPermissions.PermissionCallbacks, Application.ActivityLifecycleCallbacks {
52
52
  private static final String TAG = VideoCallActivity.class.getSimpleName();
53
+ private static Toast GlobalToast;
54
+ // public Integer streamCount =0;
53
55
  public Session session;
54
56
  private static Bridge staticBridge = null;
55
57
  private String dummyProfile = "https://www.gravatar.com/avatar/?d=mp";
@@ -60,6 +62,7 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
60
62
  String PUBLISHERNAME;
61
63
  String profilePicApiUrl;
62
64
  boolean isPatientOnline = false;
65
+ boolean enableVCConfig = false;
63
66
  boolean isMuted = false;
64
67
  boolean isCamOff = false;
65
68
  public boolean temptest = false;
@@ -84,6 +87,8 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
84
87
  public static Button admit;
85
88
  public static Button deny ;
86
89
  Boolean ISPROVIDER = false;
90
+ Boolean iscircleAvatarVisible = false;
91
+ Boolean onVideoDataReceived = false;
87
92
  Boolean isAppinBackground = false;
88
93
  private TextView timerTextView;
89
94
  private long startTime = 0;
@@ -173,6 +178,7 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
173
178
  ProviderViewLayout.setVisibility(View.VISIBLE);
174
179
  }
175
180
  circleAvatar.setVisibility(View.GONE); // Hide the view
181
+ iscircleAvatarVisible=false;
176
182
  patientStatus.setVisibility(View.GONE); // Hide the view
177
183
  publishernameView.setVisibility(View.GONE);// Hide the view
178
184
  admit.setVisibility(View.GONE);
@@ -200,6 +206,8 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
200
206
  ProviderViewLayout.setVisibility(View.VISIBLE);
201
207
  }
202
208
  circleAvatar.setVisibility(View.GONE); // Hide the view
209
+ iscircleAvatarVisible=false;
210
+
203
211
  patientStatus.setVisibility(View.GONE); // Hide the view
204
212
  publishernameView.setVisibility(View.GONE);// Hide the view
205
213
  admit.setVisibility(View.GONE);
@@ -230,27 +238,33 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
230
238
 
231
239
  }
232
240
  else if( stream.getStreamVideoType()==Stream.StreamVideoType.StreamVideoTypeCamera) {
233
- circleAvatar.setVisibility(View.VISIBLE); // Show the view
234
- publishernameView.setVisibility(View.VISIBLE);
241
+
235
242
  if (!ISPROVIDER) {
236
- if (session != null) {
237
- session.disconnect();
238
- }
239
- if (subscriber != null) {
240
- subscriber = null;
241
- subscriberViewContainer.removeAllViews();
242
- Intent resultIntent = new Intent();
243
- String resultcode = ISPROVIDER ? "999" : "888";
244
- resultIntent.putExtra("result_key", resultcode);
245
- setResult(RESULT_OK, resultIntent);
246
- finish();
247
- }
243
+ // if(streamCount==1){
244
+ circleAvatar.setVisibility(View.VISIBLE); // Show the view
245
+ iscircleAvatarVisible=true;
246
+ publishernameView.setVisibility(View.VISIBLE);
247
+ if (session != null) {
248
+ session.disconnect();
249
+ }
250
+ if (subscriber != null) {
251
+ subscriber = null;
252
+ subscriberViewContainer.removeAllViews();
253
+ Intent resultIntent = new Intent();
254
+ String resultcode = ISPROVIDER ? "999" : "888";
255
+ resultIntent.putExtra("result_key", resultcode);
256
+ setResult(RESULT_OK, resultIntent);
257
+ finish();
258
+ }
259
+ // }
248
260
  } else {
249
- if (subscriber != null) {
250
- subscriber = null;
251
- subscriberViewContainer.removeAllViews();
252
- showToast(SUBSCRIBERNAME + " left the call");
253
- }
261
+ // if(streamCount==1){
262
+ if (subscriber != null) {
263
+ subscriber = null;
264
+ subscriberViewContainer.removeAllViews();
265
+ showToast(SUBSCRIBERNAME + " left the call");
266
+ }
267
+ // }
254
268
  }
255
269
  }
256
270
  }
@@ -271,16 +285,27 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
271
285
  };
272
286
  SubscriberKit.VideoListener videoListener = new SubscriberKit.VideoListener() {
273
287
  @Override
274
- public void onVideoDataReceived(SubscriberKit subscriberKit) {}
288
+ public void onVideoDataReceived(SubscriberKit subscriberKit) {
289
+ onVideoDataReceived=true;
290
+ }
275
291
  @Override
276
292
  public void onVideoDisabled(SubscriberKit subscriberKit, String s) {
293
+
294
+ onVideoDataReceived=false;
277
295
  showToast(SUBSCRIBERNAME + " video disabled");
278
296
  circleAvatar.setVisibility(View.VISIBLE); // Show the view
297
+ iscircleAvatarVisible=true;
298
+
279
299
  }
280
300
  @Override
281
301
  public void onVideoEnabled(SubscriberKit subscriberKit, String s) {
282
- showToast(SUBSCRIBERNAME + " video enabled");
283
- circleAvatar.setVisibility(View.GONE); // Hide the view
302
+ Log.d("onVideoEnabled",s);
303
+ if(s == "publishVideo"){
304
+ showToast(SUBSCRIBERNAME + " video enabled");
305
+ circleAvatar.setVisibility(View.GONE); // Hide the view
306
+ iscircleAvatarVisible = false;
307
+ }
308
+
284
309
  }
285
310
  @Override
286
311
  public void onVideoDisableWarning(SubscriberKit subscriberKit) {}
@@ -348,6 +373,7 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
348
373
  PUBLISHERNAME = intent.getStringExtra("publisherName");
349
374
  profilePicApiUrl = intent.getStringExtra("profilePicApiUrl");
350
375
  isPatientOnline = intent.getBooleanExtra("isPatientOnline",false);
376
+ enableVCConfig = intent.getBooleanExtra("enableVCConfig",false);
351
377
  ISPROVIDER = intent.getBooleanExtra("isProvider",false);
352
378
  publisherViewContainer = findViewById(R.id.publisher_container);
353
379
  subscriberViewContainer = findViewById(R.id.subscriber_container);
@@ -356,20 +382,27 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
356
382
  publisherNameTextView = findViewById(R.id.publisherName);
357
383
  publishernameView = findViewById(R.id.publisherNameView);
358
384
  TextView subscriberNameTextView = findViewById(R.id.subscriberName);
359
- if(ISPROVIDER){
360
- if (isPatientOnline) {
361
- patientStatus.setText("WAITING");
362
- sendNotifications.setVisibility(View.GONE);
363
- admit.setVisibility(View.VISIBLE);
364
- deny.setVisibility(View.VISIBLE);
365
- patientStatus.setBackgroundColor(getResources().getColor(R.color.waiting));
366
- } else {
367
- admit.setVisibility(View.GONE);
368
- deny.setVisibility(View.GONE);
369
- sendNotifications.setVisibility(View.VISIBLE);
370
- patientStatus.setText("OFFLINE");
371
- patientStatus.setBackgroundColor(getResources().getColor(R.color.offline));
385
+ if(enableVCConfig){
386
+ if (ISPROVIDER) {
387
+ if (isPatientOnline) {
388
+ patientStatus.setText("WAITING");
389
+ sendNotifications.setVisibility(View.GONE);
390
+ admit.setVisibility(View.VISIBLE);
391
+ deny.setVisibility(View.VISIBLE);
392
+ patientStatus.setBackgroundColor(getResources().getColor(R.color.waiting));
393
+ } else {
394
+ admit.setVisibility(View.GONE);
395
+ deny.setVisibility(View.GONE);
396
+ sendNotifications.setVisibility(View.VISIBLE);
397
+ patientStatus.setText("OFFLINE");
398
+ patientStatus.setBackgroundColor(getResources().getColor(R.color.offline));
399
+ }
372
400
  }
401
+ }else{
402
+ admit.setVisibility(View.GONE);
403
+ deny.setVisibility(View.GONE);
404
+ sendNotifications.setVisibility(View.GONE);
405
+ patientStatus.setVisibility(View.GONE);
373
406
  }
374
407
  publisherNameTextView.setText(SUBSCRIBERNAME);
375
408
  publishernameView.setText(SUBSCRIBERNAME);
@@ -556,53 +589,48 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
556
589
  }
557
590
  }
558
591
  public void patientStatusChanged(Boolean isOnline) {
559
- Log.d("patientStatusChanged", String.valueOf(isOnline));
560
- Log.d("patientStatusChanged2", String.valueOf(isOnline));
561
- Log.d("patientStatusChanged2", String.valueOf(isOnline));
562
- Log.d("patientStatusChanged2", String.valueOf(instance.ISPROVIDER));
563
592
 
564
- // if(instance.ISPROVIDER){
565
- Log.d("patientStatuISPROVIDER", String.valueOf(isOnline));
566
-
567
- runOnUiThread(new Runnable() {
568
- @Override
569
- public void run() {
570
- temptest = isOnline;
571
- if (isOnline) {
572
- Log.d("isOnline", String.valueOf(isOnline));
573
-
574
- patientStatus.setText("WAITING");
575
- sendNotifications.setVisibility(View.GONE);
576
- admit.setVisibility(View.VISIBLE);
577
- deny.setVisibility(View.VISIBLE);
578
- publishernameView.setVisibility(View.VISIBLE);
579
-
580
- patientStatus.setBackgroundResource(R.color.waiting);
581
- } else {
582
- Log.d("OFFLINE", String.valueOf(isOnline));
583
- patientStatus.setText("OFFLINE");
584
- admit.setVisibility(View.GONE);
585
- deny.setVisibility(View.GONE);
586
- publishernameView.setVisibility(View.VISIBLE);
587
- sendNotifications.setVisibility(View.VISIBLE);
588
- patientStatus.setText("OFFLINE");
589
- patientStatus.setBackgroundResource(R.color.offline);
593
+ if(enableVCConfig) {
594
+ if (subscriber == null) {
595
+ runOnUiThread(new Runnable() {
596
+ @Override
597
+ public void run() {
598
+ temptest = isOnline;
599
+ if (isOnline) {
600
+ patientStatus.setText("WAITING");
601
+ sendNotifications.setVisibility(View.GONE);
602
+ admit.setVisibility(View.VISIBLE);
603
+ deny.setVisibility(View.VISIBLE);
604
+ publishernameView.setVisibility(View.VISIBLE);
605
+ patientStatus.setBackgroundResource(R.color.waiting);
606
+ } else {
607
+ patientStatus.setText("OFFLINE");
608
+ admit.setVisibility(View.GONE);
609
+ deny.setVisibility(View.GONE);
610
+ publishernameView.setVisibility(View.VISIBLE);
611
+ sendNotifications.setVisibility(View.VISIBLE);
612
+ patientStatus.setText("OFFLINE");
613
+ patientStatus.setBackgroundResource(R.color.offline);
614
+ }
590
615
  }
616
+ });
617
+ }
591
618
 
592
-
593
- }
594
- });
595
- // }
619
+ }
596
620
  }
597
621
  public static void showGreenToast(Context context, String message) {
622
+ if(GlobalToast!=null){
623
+ GlobalToast.cancel();
624
+ }
598
625
  LayoutInflater inflater = LayoutInflater.from(context);
599
626
  View layout = inflater.inflate(R.layout.custom_toast_green_layout, null);
627
+
600
628
  TextView text = layout.findViewById(R.id.toastView);
601
629
  text.setText(message);
602
630
  Toast toast = new Toast(context);
603
631
  toast.setDuration(Toast.LENGTH_SHORT);
604
632
  toast.setView(layout);
605
- toast.setGravity(Gravity.TOP | Gravity.END, 0, 0);
633
+ toast.setGravity(Gravity.TOP | Gravity.END, 0, 10);
606
634
  int desiredWidth = isTablet(context) ? getScreenWidth(context) - dpToPx(context, 250) :
607
635
  getScreenWidth(context) - dpToPx(context, 100);
608
636
 
@@ -611,6 +639,7 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
611
639
  ViewGroup.LayoutParams params = new LinearLayout.LayoutParams(desiredWidth, ViewGroup.LayoutParams.WRAP_CONTENT);
612
640
  layout.setLayoutParams(params);
613
641
  toast.show();
642
+ GlobalToast =toast;
614
643
  }
615
644
  private static boolean isTablet(Context context) {
616
645
  return (context.getResources().getConfiguration().screenLayout &
@@ -128,6 +128,7 @@ public class vonagePlugin extends Plugin{
128
128
  final String SUBSCRIBERNAME = call.getString("subscriberName");
129
129
  final Boolean ISPROVIDER = call.getBoolean("isProvider");
130
130
  final Boolean isPatientOnline = call.getBoolean("isPatientOnline");
131
+ final Boolean enableVCConfig = call.getBoolean("enableVCConfig");
131
132
  final String profilePicApiUrl = call.getString("profilePhoto");
132
133
  showLog("profilePicApiUrl");
133
134
  showLog(profilePicApiUrl);
@@ -142,6 +143,7 @@ public class vonagePlugin extends Plugin{
142
143
  intent.putExtra("isProvider", ISPROVIDER);
143
144
  intent.putExtra("isPatientOnline", isPatientOnline);
144
145
  intent.putExtra("profilePicApiUrl", profilePicApiUrl);
146
+ intent.putExtra("enableVCConfig", enableVCConfig);
145
147
  intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_SINGLE_TOP);//|Intent.FLAG_ACTIVITY_NEW_TASK
146
148
  try {
147
149
  showLog("try======");
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <shape xmlns:android="http://schemas.android.com/apk/res/android" >
3
+ <solid android:color="#0B6623" />
4
+ <corners
5
+ android:bottomLeftRadius="20dp"
6
+ android:bottomRightRadius="20dp"
7
+ android:topLeftRadius="20dp"
8
+ android:topRightRadius="20dp" />
9
+ </shape>
@@ -25,12 +25,23 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
25
25
  var isPatientOnLine = true
26
26
  var isPatientFromWeb = true
27
27
  var videoCallParam = String()
28
+ var enableVCConfig = false
28
29
  var profilePicApiUrl = ""
29
- var session: OTSession?
30
- var publisher: OTPublisher?
30
+ // var session: OTSession?
31
+ //var publisher: OTPublisher?
31
32
  var subscriber: OTSubscriber?
32
33
  var screenTypesubscriber: OTSubscriber?
33
34
 
35
+ lazy var session: OTSession = {
36
+ return OTSession(apiKey: kApiKey, sessionId: kSessionId, delegate: self)!
37
+ }()
38
+ lazy var publisher: OTPublisher = {
39
+ let settings = OTPublisherSettings()
40
+ settings.name = UIDevice.current.name
41
+ return OTPublisher(delegate: self, settings: settings)!
42
+ }()
43
+ var error: OTError?
44
+
34
45
  var bottomView = UIView()
35
46
  var remoteView = UIView()
36
47
  var localView = UIView()
@@ -61,6 +72,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
61
72
  NotificationCenter.default.addObserver(self, selector: #selector(appMovedToForeground), name: UIApplication.willEnterForegroundNotification, object: nil)
62
73
  showActivityIndicator()
63
74
  UserDefaults.standard.set(isProvider, forKey: "isProvider")
75
+ self.connectToAnOpenTokSession()
64
76
  self.viewSetupMethod()
65
77
  // let jsonParam = videoCallParam.toJSON() as? [String:AnyObject] // can be any type here
66
78
  // print(jsonParam as Any)
@@ -98,7 +110,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
98
110
  // NSLog("Unable to change preferred sample rate because : \(String(describing: err?.localizedDescription))")
99
111
  // err = nil
100
112
  // }
101
- self.connectToAnOpenTokSession()
113
+
102
114
  // })
103
115
  }
104
116
  override func viewDidAppear(_ animated: Bool) {
@@ -157,7 +169,10 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
157
169
  isPatientOnLine = false
158
170
  }
159
171
  DispatchQueue.main.async {
160
- self.patientStatusChanged()
172
+ if(self.enableVCConfig){
173
+ self.patientStatusChanged()
174
+ }
175
+
161
176
  }
162
177
 
163
178
  // }
@@ -223,7 +238,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
223
238
 
224
239
  remoteView = UIView(frame: CGRect(x: 0, y: 0, width: screenWidth, height:screenHeight))
225
240
  remoteView.backgroundColor = .white//UIColor(red: 83/255, green: 83/255, blue: 83/255, alpha: 1.0)
226
- centerView.layer.zPosition = 1
241
+ centerView.layer.zPosition = 3
227
242
  centerView.frame = CGRect(x: 0, y: 0, width: 250, height: 400)
228
243
  // centerView.backgroundColor = .blue
229
244
  centerView.center.x = remoteView.center.x
@@ -284,6 +299,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
284
299
  adminBtn.layer.borderColor = UIColor(hex: "#60D2A7").cgColor
285
300
  adminBtn.layer.borderWidth = 2
286
301
  adminBtn.layer.cornerRadius = 10
302
+ adminBtn.layer.zPosition = 3
287
303
  adminBtn.setTitleColor(UIColor(hex: "#000000"), for: .normal)
288
304
  adminBtn.setTitle("ADMIT", for: .normal)
289
305
  adminBtn.titleLabel?.font = UIFont.boldSystemFont(ofSize: dynamicFontSize(UIDevice.current.userInterfaceIdiom == .pad ? 10 : 15))
@@ -295,6 +311,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
295
311
  sendNotificationBtn.layer.borderColor = UIColor(hex: "#60D2A7").cgColor
296
312
  sendNotificationBtn.layer.borderWidth = 2
297
313
  sendNotificationBtn.layer.cornerRadius = 10
314
+ sendNotificationBtn.layer.zPosition = 3
298
315
  sendNotificationBtn.setTitleColor(UIColor(hex: "#000000"), for: .normal)
299
316
  sendNotificationBtn.setTitle(isPatientFromWeb ? "SEND EMAIL NOTIFICATION" : "SEND NOTIFICATION", for: .normal)
300
317
  sendNotificationBtn.titleLabel?.font = UIFont.boldSystemFont(ofSize: dynamicFontSize(UIDevice.current.userInterfaceIdiom == .pad ? 7 : 15))
@@ -306,6 +323,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
306
323
  denyBtn.layer.borderColor = UIColor(hex: "#C4CBCF").cgColor
307
324
  denyBtn.layer.borderWidth = 2
308
325
  denyBtn.layer.cornerRadius = 10
326
+ denyBtn.layer.zPosition = 3
309
327
  denyBtn.setTitleColor(UIColor(hex: "#000000"), for: .normal)
310
328
  denyBtn.setTitle("DENY", for: .normal)
311
329
  denyBtn.titleLabel?.font = UIFont.boldSystemFont(ofSize: dynamicFontSize(UIDevice.current.userInterfaceIdiom == .pad ? 10 : 15))
@@ -319,10 +337,14 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
319
337
  centerView.addSubview(subscriberNameLabel)
320
338
  centerView.addSubview(sendNotificationBtn)
321
339
  //patientStatusChanged()
322
- centerView.isHidden = true
340
+ centerView.isHidden = false
341
+ adminBtn.isHidden = true
342
+ denyBtn.isHidden = true
343
+ sendNotificationBtn.isHidden = true
344
+ subscriberStatusLabel.isHidden = true
323
345
 
324
346
  // subscriberImg = UIImageView(image: <#T##UIImage?#>)
325
- remoteView.addSubview(centerView)
347
+ //remoteView.addSubview(centerView)
326
348
  remoteView.addSubview(timerLabel)
327
349
  remoteView.addSubview(subscriberLabel)
328
350
 
@@ -333,7 +355,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
333
355
  bottomView.center = CGPoint(x: self.view.frame.size.width / 2, y: self.view.frame.size.height - 50)
334
356
 
335
357
  self.view.addSubview(bottomView)
336
-
358
+ self.view.addSubview(centerView)
337
359
  localView = UIView(frame: CGRect(x: screenWidth - 140, y: screenHeight - 260, width: 120, height: 120))
338
360
  localView.backgroundColor = UIColor(red: 31/255, green: 33/255, blue: 36/255, alpha: 1.0)
339
361
  localView.layer.borderColor = UIColor(hex: "#9b9c98").cgColor
@@ -421,7 +443,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
421
443
  let userInfo = ["isProvider": isProvider]
422
444
  // NotificationCenter.default.post(name: NSNotification.Name("SendNotification"),object: nil,userInfo: userInfo)
423
445
  delegate?.videoCallSendNotification(userInfo)
424
- // self.session?.disconnect(nil)
446
+ // self.session.disconnect(nil)
425
447
  // self.stopTimer()
426
448
  // self.dismiss(animated: true, completion: nil)
427
449
  }
@@ -437,7 +459,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
437
459
  //subscriberStatusLabel.frame.width =
438
460
  // let userInfo = ["userInfo": ["isProvider": isProvider]]
439
461
  // NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoEnded),object: nil,userInfo: userInfo)
440
- // self.session?.disconnect(nil)
462
+ // self.session.disconnect(nil)
441
463
  // self.stopTimer()
442
464
  // self.dismiss(animated: true, completion: nil)
443
465
  let userInfo = ["isProvider": isProvider]
@@ -475,11 +497,11 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
475
497
  print("A stream was destroyed in the session.")
476
498
  if (self.isBackCameraFace) {
477
499
  print("A stream was destroyed in the session.1")
478
- self.publisher?.cameraPosition = .front
500
+ self.publisher.cameraPosition = .front
479
501
  self.isBackCameraFace = false
480
502
  } else {
481
503
  print("A stream was destroyed in the session.2")
482
- self.publisher?.cameraPosition = .back
504
+ self.publisher.cameraPosition = .back
483
505
  self.isBackCameraFace = true
484
506
  }
485
507
  }
@@ -489,11 +511,11 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
489
511
  }
490
512
  func turnOnAndOffVideo(){
491
513
  if (self.isVideoMute) {
492
- self.publisher?.publishVideo = true
514
+ self.publisher.publishVideo = true
493
515
  self.videoBtn.setImage(UIImage(named : "cameraOnWhite"), for: .normal)
494
516
  self.isVideoMute = false
495
517
  } else {
496
- self.publisher?.publishVideo = false
518
+ self.publisher.publishVideo = false
497
519
  self.videoBtn.setImage(UIImage(named:"cameraOff"), for: .normal)
498
520
  self.isVideoMute = true
499
521
  }
@@ -502,22 +524,22 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
502
524
  @objc func audioBtnbuttonClicked() {
503
525
  if (self.isAudioMute) {
504
526
 
505
- self.publisher?.publishAudio = true
527
+ self.publisher.publishAudio = true
506
528
  //self.publisher.del
507
529
  self.audioBtn.setImage(UIImage(named : "microphoneOnWhite"), for: .normal)
508
530
  self.isAudioMute = false
509
531
  } else {
510
- self.publisher?.publishAudio = false
532
+ self.publisher.publishAudio = false
511
533
  self.audioBtn.setImage(UIImage(named:"microphoneOff"), for: .normal)
512
534
  self.isAudioMute = true
513
535
  }
514
536
  }
515
537
 
516
538
  func connectToAnOpenTokSession() {
517
- session = OTSession(apiKey: kApiKey, sessionId: kSessionId, delegate: self)
539
+ //session = OTSession(apiKey: kApiKey, sessionId: kSessionId, delegate: self)
518
540
  //self.session = session
519
541
  var error: OTError?
520
- session?.connect(withToken: kToken, error: &error)
542
+ session.connect(withToken: kToken, error: &error)
521
543
  if error != nil {
522
544
  print(error!)
523
545
  }
@@ -558,14 +580,16 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
558
580
  localView.addSubview(publisherView)
559
581
  startTimer()
560
582
  DispatchQueue.main.async {
561
- self.patientStatusChanged()
583
+ if(self.enableVCConfig){
584
+ self.patientStatusChanged()
585
+ }
562
586
  }
563
587
 
564
588
  }
565
589
 
566
590
  func sessionDidDisconnect(_ session: OTSession) {
567
591
  print("The client disconnected from the OpenTok session.")
568
- // self.session?.disconnect(nil)
592
+ // self.session.disconnect(nil)
569
593
  // if(!isCallEnded){
570
594
  // let userInfo = ["userInfo": ["isProvider": self.isProvider]]
571
595
  // // NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoEnded),object: nil,userInfo: userInfo)
@@ -575,6 +599,22 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
575
599
  }
576
600
 
577
601
  func session(_ session: OTSession, didFailWithError error: OTError) {
602
+ hideActivityIndicator()
603
+ let alert = UIAlertController(title: "Error", message: "The client failed to connect to the OpenTok session", preferredStyle: .alert)
604
+ alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
605
+ switch action.style{
606
+ case .default:
607
+ print("default")
608
+
609
+ case .cancel:
610
+ print("cancel")
611
+
612
+ case .destructive:
613
+ print("destructive")
614
+
615
+ }
616
+ }))
617
+ self.present(alert, animated: true, completion: nil)
578
618
  print("The client failed to connect to the OpenTok session: \(error).")
579
619
  }
580
620
 
@@ -613,8 +653,8 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
613
653
  print("A stream was destroyed in the session.\(session.sessionId)")
614
654
  // var error = OTError()
615
655
  // let progressPointer = AutoreleasingUnsafeMutablePointer<OTError?>.init(&error)
616
- // if(session.sessionId == self.session?.sessionId){
617
- // self.session?.disconnect(nil)
656
+ // if(session.sessionId == self.session.sessionId){
657
+ // self.session.disconnect(nil)
618
658
  // self.dismiss(animated: true, completion: nil)
619
659
  // }
620
660
  if let subStream = subscriber?.stream, subStream.streamId == stream.streamId,!isProvider, stream.videoType != .screen {
@@ -642,15 +682,15 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
642
682
 
643
683
 
644
684
  }
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
- }
685
+ // func sessionDidBeginReconnecting(_ session:OTSession) {
686
+ // // Display a user interface notification.
687
+ // print("sessionDidBeginReconnecting \(session.sessionId)")
688
+ // }
689
+ //
690
+ // func sessionDidReconnect(_ session: OTSession) {
691
+ // // Adjust user interface.
692
+ // print("sessionDidReconnect \(session.sessionId)")
693
+ // }
654
694
  //Publisher methods
655
695
  func publisher(_ publisher: OTPublisherKit, didFailWithError error: OTError) {
656
696
  print("The publisher failed: \(error)")
@@ -725,14 +765,14 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
725
765
  // NotificationCenter.default.post(name: NSNotification.Name("RemoveObservers"),object: nil,userInfo: userInfo)
726
766
  // DispatchQueue.main.async {
727
767
  print("video ended called")
728
- // self.publisher?.publishVideo = false
729
- // self.publisher?.videoCapture?.stop()
730
- // self.publisher?.publishAudio = false
768
+ // self.publisher.publishVideo = false
769
+ // self.publisher.videoCapture?.stop()
770
+ // self.publisher.publishAudio = false
731
771
 
732
772
  // self.cleanupSubscriber()
733
773
  //self.cleanupPublisher()
734
774
  var error: OTError?
735
- self.session?.disconnect(&error)
775
+ self.session.disconnect(&error)
736
776
  if error != nil {
737
777
  print(error!)
738
778
  }
@@ -745,13 +785,13 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
745
785
  timerLabel.textColor = .black
746
786
  publisherLabel.textColor = .black
747
787
  subscriber?.view?.removeFromSuperview()
748
- subscriber = nil
788
+ //subscriber = nil
749
789
  remoteView.backgroundColor = .white
750
790
  }
751
791
 
752
792
  fileprivate func cleanupPublisher() {
753
- publisher?.view?.removeFromSuperview()
754
- publisher = nil
793
+ publisher.view?.removeFromSuperview()
794
+ //publisher = nil
755
795
  }
756
796
  func someImageViewConstraints() {
757
797
  subscriberImg.widthAnchor.constraint(equalToConstant: 180).isActive = true
@@ -822,12 +862,13 @@ func showToast(message : String) {
822
862
  toastLabel.textColor = .white//UIColor.black
823
863
  toastLabel.font = .systemFont(ofSize: 14.0)
824
864
  toastLabel.textAlignment = .center;
865
+ toastLabel.baselineAdjustment = .alignCenters
825
866
  toastLabel.text = message
826
867
  toastLabel.alpha = 1.0
827
868
  toastLabel.layer.cornerRadius = 10;
828
869
  toastLabel.clipsToBounds = true
829
870
  self.view.addSubview(toastLabel)
830
- UIView.animate(withDuration: 5.0, delay: 0.2, options: .curveEaseOut, animations: {
871
+ UIView.animate(withDuration: 4.0, delay: 0.2, options: .curveEaseOut, animations: {
831
872
  toastLabel.alpha = 0.0
832
873
  }, completion: {(isCompleted) in
833
874
  toastLabel.removeFromSuperview()
@@ -12,14 +12,12 @@ 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
- print("token: \(token)")
16
- print("apiKey: \(apiKey)")
17
- print("sessionId: \(sessionId)")
18
15
  let publisherName = call.getString("publisherName") ?? ""
19
16
  let subscriberName = call.getString("subscriberName") ?? ""
20
17
  let isProvider = call.getBool("isProvider") ?? false //profilePicApiUrl
21
18
  let isPatientOnline = call.getBool("isPatientOnline") ?? false
22
19
  let profilePhoto = call.getString("profilePhoto") ?? ""
20
+ let enableVCConfig = call.getBool("enableVCConfig") ?? false
23
21
  DispatchQueue.main.async {
24
22
  let vc = VideoChatViewController()
25
23
  vc.kApiKey = apiKey
@@ -30,7 +28,7 @@ public class vonagePlugin: CAPPlugin,VonageSDKInteractionDelegate {
30
28
  vc.isProvider = isProvider
31
29
  vc.isPatientOnLine = isPatientOnline
32
30
  vc.profilePicApiUrl = profilePhoto
33
- // vc.videoCallParam = value
31
+ vc.enableVCConfig = enableVCConfig
34
32
  vc.modalPresentationStyle = .fullScreen
35
33
  vc.delegate = self
36
34
  self.bridge?.viewController?.present(vc, animated: true, completion: nil)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capacitor-plugin-vonage",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "opentok sdk capacitor plugin",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",