capacitor-plugin-vonage 0.0.9 → 0.1.1

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.
Files changed (26) hide show
  1. package/android/src/main/AndroidManifest.xml +0 -0
  2. package/android/src/main/java/com/managemyhealth/plugin/vonage/CustomToastUtils.java +28 -0
  3. package/android/src/main/java/com/managemyhealth/plugin/vonage/VideoCallActivity.java +125 -38
  4. package/android/src/main/java/com/managemyhealth/plugin/vonage/vonage.java +0 -0
  5. package/android/src/main/java/com/managemyhealth/plugin/vonage/vonagePlugin.java +0 -0
  6. package/android/src/main/res/.gitkeep +0 -0
  7. package/android/src/main/res/drawable/button_background.xml +0 -0
  8. package/android/src/main/res/drawable/button_background2.xml +0 -0
  9. package/android/src/main/res/drawable/callend.png +0 -0
  10. package/android/src/main/res/drawable/callstart.png +0 -0
  11. package/android/src/main/res/drawable/cameraoff.png +0 -0
  12. package/android/src/main/res/drawable/cameraonwhite.png +0 -0
  13. package/android/src/main/res/drawable/cameraswitch.png +0 -0
  14. package/android/src/main/res/drawable/circle_shape.xml +0 -0
  15. package/android/src/main/res/drawable/ic_launcher_background.xml +0 -0
  16. package/android/src/main/res/drawable/microphoneoff.png +0 -0
  17. package/android/src/main/res/drawable/microphoneonwhite.png +0 -0
  18. package/android/src/main/res/layout/custom_toast_green_layout.xml +18 -0
  19. package/android/src/main/res/layout/video_call_layout.xml +33 -11
  20. package/android/src/main/res/values/colors.xml +0 -0
  21. package/android/src/main/res/values/strings.xml +0 -0
  22. package/android/src/main/res.zip +0 -0
  23. package/ios/Plugin/VideoChatViewController.swift +50 -46
  24. package/ios/Plugin/vonagePlugin.swift +21 -17
  25. package/package.json +1 -1
  26. package/android/src/main/res/layout/activity_main.xml +0 -36
File without changes
@@ -0,0 +1,28 @@
1
+ package com.managemyhealth.plugin.vonage;
2
+
3
+ import android.content.Context;
4
+ import android.view.Gravity;
5
+ import android.view.LayoutInflater;
6
+ import android.view.View;
7
+ import android.widget.TextView;
8
+ import android.widget.Toast;
9
+
10
+ public class CustomToastUtils {
11
+
12
+ public static void showGreenToast(Context context, String message) {
13
+ LayoutInflater inflater = LayoutInflater.from(context);
14
+ View layout = inflater.inflate(R.layout.custom_toast_green_layout, null);
15
+
16
+ TextView text = layout.findViewById(R.id.toastView);
17
+ text.setText(message);
18
+
19
+ Toast toast = new Toast(context);
20
+ toast.setDuration(Toast.LENGTH_SHORT);
21
+ toast.setView(layout);
22
+
23
+ // Set toast position to top right corner
24
+ toast.setGravity(Gravity.TOP | Gravity.END, 0, 0);
25
+
26
+ toast.show();
27
+ }
28
+ }
@@ -3,6 +3,9 @@ package com.managemyhealth.plugin.vonage;
3
3
 
4
4
 
5
5
  import android.annotation.SuppressLint;
6
+ import android.app.Activity;
7
+ import android.app.Application;
8
+ import android.content.Context;
6
9
  import android.graphics.Color;
7
10
  import android.graphics.PorterDuff;
8
11
  import android.os.AsyncTask;
@@ -13,13 +16,16 @@ import android.graphics.BitmapFactory;
13
16
  import android.opengl.GLSurfaceView;
14
17
  import android.os.Bundle;
15
18
  import android.os.Handler;
19
+ import android.os.Looper;
16
20
  import android.util.Log;
17
21
  import android.view.Gravity;
22
+ import android.view.LayoutInflater;
18
23
  import android.view.View;
19
24
  import android.widget.Button;
20
25
  import android.widget.FrameLayout;
21
26
  import android.widget.ImageView;
22
27
  import android.widget.LinearLayout;
28
+ import android.widget.ProgressBar;
23
29
  import android.widget.TextView;
24
30
  import android.widget.Toast;
25
31
 
@@ -51,7 +57,7 @@ import pub.devrel.easypermissions.AfterPermissionGranted;
51
57
  import pub.devrel.easypermissions.EasyPermissions;
52
58
 
53
59
 
54
- public class VideoCallActivity extends AppCompatActivity implements EasyPermissions.PermissionCallbacks {
60
+ public class VideoCallActivity extends AppCompatActivity implements EasyPermissions.PermissionCallbacks , Application.ActivityLifecycleCallbacks{
55
61
  private static final String TAG = VideoCallActivity.class.getSimpleName();
56
62
  private static final int PERMISSIONS_REQUEST_CODE = 124;
57
63
 
@@ -67,18 +73,23 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
67
73
  boolean isPatientOnline = false;
68
74
  boolean isMuted = false;
69
75
  boolean isCamOff = false;
76
+ private static boolean isCallinprogress = false;
70
77
  public boolean temptest = false;
71
78
  boolean isTimeron = false;
72
79
  boolean isEndall = false;
73
80
  private Subscriber subscriber;
74
81
  private FrameLayout publisherViewContainer;
75
82
  private LinearLayout ProviderViewLayout;
83
+ private LinearLayout main;
84
+ private ProgressBar progressBar;
76
85
  private FrameLayout subscriberViewContainer;
86
+ private TextView publisherNameTextView;
77
87
  private FloatingActionButton fabCameraOff;
78
88
  private ImageView imageViewEndcall;
79
89
  private ImageView imageViewMute;
80
90
  private ImageView imageViewCamOff;
81
91
  private ImageView circleAvatar;
92
+ private boolean isAppInForeground;
82
93
 
83
94
  private ImageView imageViewCamSwitch;
84
95
  public static Button sendNotifications ;
@@ -87,6 +98,7 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
87
98
  public static Button admit;
88
99
  public static Button deny ;
89
100
 
101
+
90
102
  private static final int LOG_INTERVAL_MILLIS = 1000; // Log every 100 milliseconds
91
103
 
92
104
  private final Handler handler = new Handler();
@@ -121,6 +133,7 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
121
133
  public void onStreamCreated(PublisherKit publisherKit, Stream stream) {
122
134
  Log.d(TAG, "onStreamCreated: Publisher Stream Created. Own stream " + stream.getStreamId());
123
135
 
136
+
124
137
  }
125
138
 
126
139
  @Override
@@ -138,6 +151,8 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
138
151
  private final Session.SessionListener sessionListener = new Session.SessionListener() {
139
152
  @Override
140
153
  public void onConnected(Session session) {
154
+ main.setVisibility(View.VISIBLE);
155
+ progressBar.setVisibility(View.INVISIBLE);
141
156
  publisher = new Publisher.Builder(VideoCallActivity.this).build();
142
157
  publisher.setPublisherListener(publisherListener);
143
158
  publisher.getRenderer().setStyle(BaseVideoRenderer.STYLE_VIDEO_SCALE, BaseVideoRenderer.STYLE_VIDEO_FILL);
@@ -145,6 +160,11 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
145
160
  try {
146
161
  if (Framelayout != null) {
147
162
  Framelayout.addView(publisher.getView());
163
+ LayoutInflater inflater = LayoutInflater.from(getApplicationContext());
164
+ View xmlDefinedView = inflater.inflate(R.layout.video_call_layout, Framelayout, false);
165
+ Framelayout.addView(xmlDefinedView);
166
+ publisherNameTextView.bringToFront();
167
+
148
168
  }
149
169
  } catch (Exception e) {}
150
170
  if (publisher.getView() instanceof GLSurfaceView) {
@@ -184,7 +204,7 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
184
204
  }
185
205
  @Override
186
206
  public void onStreamReceived(Session session, Stream stream) {
187
-
207
+ isCallinprogress = true;
188
208
  ProviderViewLayout = findViewById(R.id.providerViewLayout);
189
209
  if(ISPROVIDER) {
190
210
  ProviderViewLayout.setVisibility(View.VISIBLE);
@@ -300,6 +320,7 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
300
320
  @Override
301
321
  public void onDisconnected(SubscriberKit subscriberKit) {
302
322
  Log.d(TAG, "onDisconnected: Subscriber disconnected. Stream: " + subscriberKit.getStream().getStreamId());
323
+ showToast(SUBSCRIBERNAME+" left the call");
303
324
 
304
325
 
305
326
  }
@@ -346,6 +367,8 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
346
367
 
347
368
  setContentView(R.layout.video_call_layout);
348
369
  sendNotifications = findViewById(R.id.senddata);
370
+ main = findViewById(R.id.main);
371
+ progressBar = findViewById(R.id.progressBar);
349
372
 
350
373
  circleAvatar = findViewById(R.id.image_view);
351
374
 
@@ -371,7 +394,7 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
371
394
  ISPROVIDER = intent.getBooleanExtra("isProvider",false);
372
395
  publisherViewContainer = findViewById(R.id.publisher_container);
373
396
  subscriberViewContainer = findViewById(R.id.subscriber_container);
374
- TextView publisherNameTextView = findViewById(R.id.publisherName);
397
+ publisherNameTextView = findViewById(R.id.publisherName);
375
398
  publishernameView = findViewById(R.id.publisherNameView);
376
399
  TextView subscriberNameTextView = findViewById(R.id.subscriberName);
377
400
 
@@ -410,6 +433,7 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
410
433
  new urltoSource((ImageView) findViewById(R.id.image_view)).execute(dummyImage);
411
434
  initializeSession(API_KEY,SESSION_ID , TOKEN);
412
435
 
436
+
413
437
  }
414
438
 
415
439
 
@@ -621,6 +645,7 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
621
645
 
622
646
 
623
647
  private void initializeSession(String apiKey, String sessionId, String token) {
648
+ instance.isCallinprogress= false;
624
649
  Log.i(TAG, "initializeSession: " + "initializeSession");
625
650
  Log.i(TAG, "apiKey: " + apiKey);
626
651
  Log.i(TAG, "sessionId: " + sessionId);
@@ -657,20 +682,24 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
657
682
  // }
658
683
 
659
684
  private void showToast(String message) {
660
- try{
661
- Toast toast = Toast.makeText(this, message, Toast.LENGTH_LONG);
662
- View view = toast.getView();
663
- int color = Color.parseColor("#1fc600");
664
- int colorText = Color.parseColor("#ffffff");
665
- view.getBackground().setColorFilter(Color.GREEN, PorterDuff.Mode.SRC_IN);
666
- TextView text = view.findViewById(android.R.id.message);
667
- text.setTextColor(Color.BLACK);
668
- toast.setGravity(Gravity.TOP, 0, 0);
669
- toast.show();
670
- }catch(Exception e){
671
- Log.d("toastlogex",e.toString());
672
- }
685
+ // try{
686
+ // if(isAppInForeground()){
687
+ showGreenToast(getApplicationContext(),message);
688
+ // }
689
+ // Toast toast = Toast.makeText(this, message, Toast.LENGTH_LONG);
690
+ // View view = toast.getView();
691
+ // int color = Color.parseColor("#1fc600");
692
+ // int colorText = Color.parseColor("#ffffff");
693
+ // view.getBackground().setColorFilter(Color.GREEN, PorterDuff.Mode.SRC_IN);
694
+ // TextView text = view.findViewById(android.R.id.message);
695
+ // text.setTextColor(Color.BLACK);
696
+ // toast.setGravity(Gravity.TOP, 0, 0);
697
+ // toast.show();
698
+ // }catch(Exception e){
699
+ // Log.d("toastlogex",e.toString());
700
+ // }
673
701
  }
702
+
674
703
  private void finishWithMessage(String message) {
675
704
  Log.e(TAG, message);
676
705
  // Toast.makeText(this, message, Toast.LENGTH_LONG).show();
@@ -693,33 +722,54 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
693
722
  Log.d("patientStatusChanged2", String.valueOf(isOnline));
694
723
  Log.d("patientStatusChanged2", String.valueOf(isOnline));
695
724
 
696
- runOnUiThread(new Runnable() {
697
- @Override
698
- public void run() {
699
- temptest= isOnline;
700
- if(isOnline){
701
- Log.d("isOnline", String.valueOf(isOnline));
702
-
703
- patientStatus.setText("WAITING");
704
- sendNotifications.setVisibility(View.GONE);
705
- admit.setVisibility(View.VISIBLE);
706
- deny.setVisibility(View.VISIBLE);
707
- patientStatus.setBackgroundResource(R.color.waiting);
725
+ if(!instance.isCallinprogress){
726
+ runOnUiThread(new Runnable() {
727
+ @Override
728
+ public void run() {
729
+ temptest = isOnline;
730
+ if (isOnline) {
731
+ Log.d("isOnline", String.valueOf(isOnline));
732
+
733
+ patientStatus.setText("WAITING");
734
+ sendNotifications.setVisibility(View.GONE);
735
+ admit.setVisibility(View.VISIBLE);
736
+ deny.setVisibility(View.VISIBLE);
737
+ patientStatus.setBackgroundResource(R.color.waiting);
708
738
  // patientStatus.setBackgroundColor(getResources().getColor(R.color.waiting));
709
- }else{
710
- Log.d("OFFLINE", String.valueOf(isOnline));
711
- patientStatus.setText("OFFLINE");
712
- admit.setVisibility(View.GONE);
713
- deny.setVisibility(View.GONE);
714
- sendNotifications.setVisibility(View.VISIBLE);
715
- patientStatus.setText("OFFLINE");
716
- patientStatus.setBackgroundResource(R.color.offline);
739
+ } else {
740
+ Log.d("OFFLINE", String.valueOf(isOnline));
741
+ patientStatus.setText("OFFLINE");
742
+ admit.setVisibility(View.GONE);
743
+ deny.setVisibility(View.GONE);
744
+ sendNotifications.setVisibility(View.VISIBLE);
745
+ patientStatus.setText("OFFLINE");
746
+ patientStatus.setBackgroundResource(R.color.offline);
717
747
  // patientStatus.setBackgroundColor(getResources().getColor(R.color.offline));
748
+ }
749
+
750
+
718
751
  }
752
+ });
753
+ }
754
+ }
755
+ public static void showGreenToast(Context context, String message) {
756
+ LayoutInflater inflater = LayoutInflater.from(context);
757
+ View layout = inflater.inflate(R.layout.custom_toast_green_layout, null);
719
758
 
759
+ TextView text = layout.findViewById(R.id.toastView);
760
+ text.setText(message);
720
761
 
721
- }
722
- });
762
+ Toast toast = new Toast(context);
763
+ toast.setDuration(Toast.LENGTH_SHORT);
764
+ toast.setView(layout);
765
+
766
+ // Set toast position to top right corner
767
+ toast.setGravity(Gravity.TOP | Gravity.END, 0, 0);
768
+
769
+ toast.show();
770
+ }
771
+ private boolean isAppInForeground() {
772
+ return isAppInForeground;
723
773
  }
724
774
 
725
775
  public void notifyObservers(String value) {
@@ -727,6 +777,43 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
727
777
  temp.update(value);
728
778
  }
729
779
 
780
+ @Override
781
+ public void onActivityCreated(@NonNull Activity activity, @androidx.annotation.Nullable Bundle bundle) {
782
+
783
+ }
784
+
785
+ @Override
786
+ public void onActivityStarted(@NonNull Activity activity) {
787
+
788
+ }
789
+
790
+ @Override
791
+ public void onActivityResumed(@NonNull Activity activity) {
792
+ Log.d("isAppInForeground", String.valueOf(isAppInForeground));
793
+ isAppInForeground = true;
794
+ }
795
+
796
+ @Override
797
+ public void onActivityPaused(@NonNull Activity activity) {
798
+ Log.d("isAppInForeground", String.valueOf(isAppInForeground));
799
+ isAppInForeground = false;
800
+ }
801
+
802
+ @Override
803
+ public void onActivityStopped(@NonNull Activity activity) {
804
+
805
+ }
806
+
807
+ @Override
808
+ public void onActivitySaveInstanceState(@NonNull Activity activity, @NonNull Bundle bundle) {
809
+
810
+ }
811
+
812
+ @Override
813
+ public void onActivityDestroyed(@NonNull Activity activity) {
814
+
815
+ }
816
+
730
817
  private class urltoSource extends AsyncTask<String, Void, Bitmap> {
731
818
  ImageView imageView;
732
819
  public urltoSource(ImageView imageView) {
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,18 @@
1
+ <!-- custom_toast_green_layout.xml -->
2
+ <LinearLayout
3
+ xmlns:android="http://schemas.android.com/apk/res/android"
4
+ android:layout_width="wrap_content"
5
+ android:layout_height="wrap_content"
6
+ android:orientation="vertical"
7
+ android:padding="16dp"
8
+ android:background="#00FF00">
9
+
10
+ <TextView
11
+ android:id="@+id/toastView"
12
+ android:layout_width="wrap_content"
13
+ android:layout_height="wrap_content"
14
+ android:text="Custom Toast"
15
+ android:textColor="#0B6623"
16
+ android:textStyle="bold"
17
+ android:layout_gravity="center_horizontal"/>
18
+ </LinearLayout>
@@ -15,11 +15,25 @@
15
15
  android:layout_height="match_parent"
16
16
  >
17
17
 
18
+ <ProgressBar
19
+ android:id="@+id/progressBar"
20
+ style="?android:attr/progressBarStyleLarge"
21
+ android:layout_width="57dp"
22
+ android:layout_height="56dp"
23
+ android:layout_gravity="center"
24
+ android:visibility="visible"
25
+ app:layout_constraintBottom_toBottomOf="parent"
26
+ app:layout_constraintEnd_toEndOf="parent"
27
+ app:layout_constraintStart_toStartOf="@+id/main"
28
+ app:layout_constraintTop_toTopOf="parent" />
29
+
30
+
18
31
 
19
32
  <LinearLayout
20
33
  android:id="@+id/main"
21
34
  android:layout_width="match_parent"
22
35
  android:layout_height="match_parent"
36
+ android:visibility="invisible"
23
37
  >
24
38
 
25
39
 
@@ -70,22 +84,30 @@
70
84
  android:layout_height="120dp"
71
85
  android:layout_gravity="bottom|end"
72
86
  android:layout_marginEnd="16dp"
73
- android:layout_marginBottom="80dp"
87
+ android:layout_marginBottom="110dp"
74
88
  android:background="#9b9c98"
75
89
 
76
90
  android:padding="2dp" >
77
- <TextView
78
- android:id="@+id/subscriberName"
79
- android:layout_width="100dp"
80
- android:layout_height="wrap_content"
81
- android:layout_gravity="center_vertical|bottom"
82
- android:paddingBottom="6dp"
83
- android:text="@string/subscriber_name"
84
- android:textColor="@android:color/white"
85
- android:visibility="visible"
86
- android:textSize="12sp" />
91
+
92
+
87
93
 
88
94
  </FrameLayout>
95
+ <TextView
96
+ android:id="@+id/subscriberName"
97
+ android:layout_width="100dp"
98
+ android:layout_height="wrap_content"
99
+ android:layout_gravity="bottom|end"
100
+ android:paddingBottom="6dp"
101
+ android:layout_marginEnd="16dp"
102
+ android:layout_marginBottom="80dp"
103
+ android:maxLines="1"
104
+ android:ellipsize="end"
105
+ android:text="@string/subscriber_name"
106
+ android:textColor="@android:color/white"
107
+ android:visibility="visible"
108
+ android:gravity="center"
109
+ android:textSize="12sp" />
110
+
89
111
 
90
112
  <de.hdodenhof.circleimageview.CircleImageView
91
113
  xmlns:app="http://schemas.android.com/apk/res-auto"
File without changes
File without changes
File without changes
@@ -50,6 +50,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
50
50
  var counter = 0
51
51
  var timer : Timer?
52
52
  var activityView: UIActivityIndicatorView?
53
+ weak var delegate: VonageSDKInteractionDelegate?
53
54
  override func viewDidLoad() {
54
55
 
55
56
  super.viewDidLoad()
@@ -122,14 +123,13 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
122
123
  override func viewDidDisappear(_ animated: Bool) {
123
124
  print("viewDidDisappear")
124
125
  super.viewDidDisappear(animated)
125
- let userInfo = ["userInfo": ["isProvider": self.isProvider]]
126
- if(!isCallEnded){
127
- NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoEnded),object: nil,userInfo: userInfo)
128
-
129
- // NotificationCenter.default.removeObserver(self, name: NSNotification.Name("EndVideoCall"), object: nil)
130
-
131
- NotificationCenter.default.post(name: NSNotification.Name("RemoveObservers"),object: nil,userInfo: userInfo)
132
- }
126
+ // let userInfo = ["userInfo": ["isProvider": self.isProvider]]
127
+ // if(!isCallEnded){
128
+ //// NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoEnded),object: nil,userInfo: userInfo)
129
+ ////
130
+ //// NotificationCenter.default.post(name: NSNotification.Name("RemoveObservers"),object: nil,userInfo: userInfo)
131
+ // delegate?.videoCallEnded(userInfo)
132
+ // }
133
133
  NotificationCenter.default.removeObserver(self)
134
134
  }
135
135
  @objc func appMovedToBackground() {
@@ -370,14 +370,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
370
370
 
371
371
 
372
372
  }
373
- deinit{
374
- if(!isCallEnded){
375
- let userInfo = ["userInfo": ["isProvider": self.isProvider]]
376
- NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoEnded),object: nil,userInfo: userInfo)
377
- NotificationCenter.default.post(name: NSNotification.Name("RemoveObservers"),object: nil,userInfo: userInfo)
378
- }
379
-
380
- }
373
+
381
374
  func patientStatusChanged(){
382
375
  if(isProvider && isPatientOnLine){
383
376
  centerView.isHidden = false
@@ -414,8 +407,9 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
414
407
  subscriberStatusLabel.isHidden = false
415
408
  subscriberNameLabel.isHidden = false
416
409
  subscriberStatusLabel.text = "Please Wait.."
417
- let userInfo = ["userInfo": ["isProvider": isProvider]]
418
- NotificationCenter.default.post(name: NSNotification.Name("SendNotification"),object: nil,userInfo: userInfo)
410
+ let userInfo = ["isProvider": isProvider]
411
+ // NotificationCenter.default.post(name: NSNotification.Name("SendNotification"),object: nil,userInfo: userInfo)
412
+ delegate?.videoCallSendNotification(userInfo)
419
413
  // self.session?.disconnect(nil)
420
414
  // self.stopTimer()
421
415
  // self.dismiss(animated: true, completion: nil)
@@ -435,15 +429,17 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
435
429
  // self.session?.disconnect(nil)
436
430
  // self.stopTimer()
437
431
  // self.dismiss(animated: true, completion: nil)
438
- let userInfo = ["userInfo": ["isProvider": isProvider]]
439
- NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoStarted),object: nil,userInfo: userInfo)
432
+ let userInfo = ["isProvider": isProvider]
433
+ // NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoStarted),object: nil,userInfo: userInfo)
434
+ delegate?.videoCallStarted(userInfo)
440
435
  }
441
436
  @objc func denybuttonClicked() {
442
437
  print("deny button clicked")
443
438
  centerView.isHidden = true
444
- let userInfo = ["userInfo": ["isProvider": isProvider]]
439
+ let userInfo = ["isProvider": isProvider]
445
440
 
446
- NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoEnded),object: nil,userInfo: userInfo)
441
+ // NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoEnded),object: nil,userInfo: userInfo)
442
+ delegate?.videoCallEnded(userInfo)
447
443
  // self.session?.disconnect(nil)
448
444
  // self.stopTimer()
449
445
  // self.dismiss(animated: true, completion: nil)
@@ -453,8 +449,9 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
453
449
 
454
450
  @objc func callBtnbuttonClicked() {
455
451
 
456
- let userInfo = ["userInfo": ["isProvider": isProvider]]
457
- NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoEnded),object: nil,userInfo: userInfo)
452
+ let userInfo = ["isProvider": isProvider]
453
+ // NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoEnded),object: nil,userInfo: userInfo)
454
+ delegate?.videoCallEnded(userInfo)
458
455
  self.endVonageCall()
459
456
  }
460
457
 
@@ -515,7 +512,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
515
512
  hideActivityIndicator()
516
513
  localView.isHidden = false
517
514
  print("The client connected to the OpenTok session.")
518
- let userInfo = ["userInfo": ["isProvider": isProvider]]
515
+ let userInfo = ["isProvider": isProvider]
519
516
  // NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoStarted),object: nil,userInfo: userInfo)
520
517
  let settings = OTPublisherSettings()
521
518
  settings.cameraResolution = .high
@@ -553,11 +550,12 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
553
550
  func sessionDidDisconnect(_ session: OTSession) {
554
551
  print("The client disconnected from the OpenTok session.")
555
552
  // self.session?.disconnect(nil)
556
- if(!isCallEnded){
557
- let userInfo = ["userInfo": ["isProvider": self.isProvider]]
558
- NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoEnded),object: nil,userInfo: userInfo)
559
- }
560
- self.dismiss(animated: true, completion: nil)
553
+ // if(!isCallEnded){
554
+ // let userInfo = ["userInfo": ["isProvider": self.isProvider]]
555
+ // // NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoEnded),object: nil,userInfo: userInfo)
556
+ // delegate?.videoCallEnded(userInfo)
557
+ // }
558
+ // self.dismiss(animated: true, completion: nil)
561
559
  }
562
560
 
563
561
  func session(_ session: OTSession, didFailWithError error: OTError) {
@@ -569,10 +567,6 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
569
567
  guard let subscriber = subscriber else {
570
568
  return
571
569
  }
572
-
573
- if !stream.hasAudio {
574
- print("Stream audio \(stream.hasAudio)")
575
- }
576
570
  self.subscriber = subscriber
577
571
  var error: OTError?
578
572
  session.subscribe(subscriber, error: &error)
@@ -603,8 +597,9 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
603
597
  // }
604
598
  if let subStream = subscriber?.stream, subStream.streamId == stream.streamId,!isProvider, stream.videoType != .screen {
605
599
  // cleanupSubscriber()
606
- let userInfo = ["userInfo": ["isProvider": isProvider]]
607
- NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoEnded),object: nil,userInfo: userInfo)
600
+ let userInfo = ["isProvider": isProvider]
601
+ // NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoEnded),object: nil,userInfo: userInfo)
602
+ delegate?.videoCallEnded(userInfo)
608
603
  // self.session?.disconnect(nil)
609
604
  self.endVonageCall()
610
605
  //self.dismiss(animated: true, completion: nil)
@@ -648,6 +643,9 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
648
643
  subscriberNameLabel.isHidden = true
649
644
  timerLabel.textColor = .white
650
645
  isCallInProgress = true
646
+ adminBtn.isHidden = true
647
+ denyBtn.isHidden = true
648
+ sendNotificationBtn.isHidden = true
651
649
  if(subscriber.stream?.videoType != .screen){
652
650
  showToast(message: "\(subscriberName) is joined the call")
653
651
  }
@@ -684,26 +682,32 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
684
682
  isCallEnded = true
685
683
  let userInfo = ["userInfo": ["isProvider": self.isProvider]]
686
684
 
687
- NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoEnded),object: nil,userInfo: userInfo)
685
+ // NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoEnded),object: nil,userInfo: userInfo)
686
+ delegate?.videoCallEnded(userInfo)
688
687
  endVonageCall()
689
688
  }
690
689
  fileprivate func endVonageCall(){
691
690
  isCallEnded = true
692
- let userInfo = ["userInfo": ["isProvider": self.isProvider]]
693
- NotificationCenter.default.post(name: NSNotification.Name("RemoveObservers"),object: nil,userInfo: userInfo)
694
- DispatchQueue.main.async {
691
+ self.stopTimer()
692
+ //let userInfo = ["userInfo": ["isProvider": self.isProvider]]
693
+ // NotificationCenter.default.post(name: NSNotification.Name("RemoveObservers"),object: nil,userInfo: userInfo)
694
+ // DispatchQueue.main.async {
695
695
  print("video ended called")
696
696
  // self.publisher?.publishVideo = false
697
- self.publisher?.videoCapture?.stop()
697
+ // self.publisher?.videoCapture?.stop()
698
698
  // self.publisher?.publishAudio = false
699
- self.session?.disconnect(nil)
700
- self.cleanupSubscriber()
701
- self.cleanupPublisher()
702
- self.stopTimer()
699
+
700
+ // self.cleanupSubscriber()
701
+ //self.cleanupPublisher()
702
+ var error: OTError?
703
+ self.session?.disconnect(&error)
704
+ if error != nil {
705
+ print(error!)
706
+ }
703
707
  self.dismiss(animated: true) {
704
708
  print("video ended")
705
709
  }
706
- }
710
+ //}
707
711
  }
708
712
  fileprivate func cleanupSubscriber() {
709
713
  subscriber?.view?.removeFromSuperview()
@@ -6,7 +6,7 @@ import Capacitor
6
6
  * here: https://capacitorjs.com/docs/plugins/ios
7
7
  */
8
8
  @objc(vonagePlugin)
9
- public class vonagePlugin: CAPPlugin {
9
+ public class vonagePlugin: CAPPlugin,VonageSDKInteractionDelegate {
10
10
  @objc func openVideoCallWindow(_ call: CAPPluginCall) {
11
11
 
12
12
  let sessionId = call.getString("sessionId") ?? ""
@@ -30,24 +30,14 @@ public class vonagePlugin: CAPPlugin {
30
30
  vc.profilePicApiUrl = profilePhoto
31
31
  // vc.videoCallParam = value
32
32
  vc.modalPresentationStyle = .fullScreen
33
+ vc.delegate = self
33
34
  self.bridge?.viewController?.present(vc, animated: true, completion: nil)
34
35
  }
35
- NotificationCenter.default.addObserver(self,selector:#selector(videoEnded(_:)),name: NSNotification.Name (NotificationNames.videoEnded),object: nil)
36
- NotificationCenter.default.addObserver(self,selector:#selector(videoStarted(_:)),name: NSNotification.Name (NotificationNames.videoStarted),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)
39
- // if let visibleViewCtrl = UIApplication.topViewController() {
40
- // // do whatever you want with your `visibleViewCtrl`
41
- // print(visibleViewCtrl)
42
- // DispatchQueue.main.async(execute: {
43
- // let vc = VideoChatViewController()
44
- // vc.kApiKey = apiKey
45
- // vc.kToken = token
46
- // vc.kSessionId = sessionId
47
- // // vc.videoCallParam = value
48
- // vc.modalPresentationStyle = .fullScreen
49
- // visibleViewCtrl.present(vc, animated: true, completion: nil)})
50
- // }
36
+ // NotificationCenter.default.addObserver(self,selector:#selector(videoEnded(_:)),name: NSNotification.Name (NotificationNames.videoEnded),object: nil)
37
+ // NotificationCenter.default.addObserver(self,selector:#selector(videoStarted(_:)),name: NSNotification.Name (NotificationNames.videoStarted),object: nil)
38
+ // NotificationCenter.default.addObserver(self,selector:#selector(sendNotification(_:)),name: NSNotification.Name ("SendNotification"),object: nil)
39
+ // NotificationCenter.default.addObserver(self,selector:#selector(removeObservers(_:)),name: NSNotification.Name ("RemoveObservers"),object: nil)
40
+
51
41
 
52
42
  call.resolve(["value": "Video call initiated"])
53
43
  }
@@ -78,6 +68,15 @@ public class vonagePlugin: CAPPlugin {
78
68
  @objc func removeObservers(_ notification: Notification){
79
69
  NotificationCenter.default.removeObserver(self)
80
70
  }
71
+ func videoCallStarted(_ data: [String: Any]){
72
+ self.notifyListeners(NotificationNames.videoStarted, data: data)
73
+ }
74
+ func videoCallEnded(_ data: [String: Any]){
75
+ self.notifyListeners(NotificationNames.videoEnded, data: data)
76
+ }
77
+ func videoCallSendNotification(_ data: [String: Any]){
78
+ self.notifyListeners("SendNotification", data: data)
79
+ }
81
80
  }
82
81
  extension UIApplication {
83
82
  class func topViewController(base: UIViewController? = UIApplication.shared.keyWindow?.rootViewController) -> UIViewController? {
@@ -102,3 +101,8 @@ struct NotificationNames {
102
101
  static let videoStarted = "VideoCallStarted"
103
102
  static let videoEnded = "VideoCallEnded"
104
103
  }
104
+ protocol VonageSDKInteractionDelegate: AnyObject {
105
+ func videoCallStarted(_ data: [String: Any])
106
+ func videoCallEnded(_ data: [String: Any])
107
+ func videoCallSendNotification(_ data: [String: Any])
108
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capacitor-plugin-vonage",
3
- "version": "0.0.9",
3
+ "version": "0.1.1",
4
4
  "description": "opentok sdk capacitor plugin",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -1,36 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
- xmlns:app="http://schemas.android.com/apk/res-auto"
4
- xmlns:tools="http://schemas.android.com/tools"
5
- android:layout_width="match_parent"
6
- android:layout_height="match_parent"
7
- tools:context=".VideoCallActivity">
8
-
9
- <FrameLayout
10
- android:layout_width="fill_parent"
11
- android:layout_height="fill_parent"
12
- app:layout_constraintBottom_toBottomOf="parent"
13
- app:layout_constraintEnd_toEndOf="parent"
14
- app:layout_constraintStart_toStartOf="parent"
15
- android:background="#DDDDDD"
16
- app:layout_constraintTop_toTopOf="parent">
17
-
18
- <FrameLayout
19
- android:id="@+id/subscriber_container"
20
- android:layout_width="fill_parent"
21
- android:layout_height="fill_parent" />
22
-
23
- <FrameLayout
24
- android:id="@+id/publisher_container"
25
- android:layout_width="90dp"
26
- android:layout_height="120dp"
27
- android:layout_gravity="bottom|end"
28
- android:layout_marginEnd="16dp"
29
- android:layout_marginRight="16dp"
30
- android:layout_marginBottom="16dp"
31
- android:background="#FFFFFF"
32
- android:padding="2dp" />
33
-
34
- </FrameLayout>
35
-
36
- </androidx.constraintlayout.widget.ConstraintLayout>