capacitor-plugin-vonage 0.0.9 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/AndroidManifest.xml +0 -0
- package/android/src/main/java/com/managemyhealth/plugin/vonage/CustomToastUtils.java +28 -0
- package/android/src/main/java/com/managemyhealth/plugin/vonage/VideoCallActivity.java +112 -34
- package/android/src/main/java/com/managemyhealth/plugin/vonage/vonage.java +0 -0
- package/android/src/main/java/com/managemyhealth/plugin/vonage/vonagePlugin.java +0 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/android/src/main/res/drawable/button_background.xml +0 -0
- package/android/src/main/res/drawable/button_background2.xml +0 -0
- package/android/src/main/res/drawable/callend.png +0 -0
- package/android/src/main/res/drawable/callstart.png +0 -0
- package/android/src/main/res/drawable/cameraoff.png +0 -0
- package/android/src/main/res/drawable/cameraonwhite.png +0 -0
- package/android/src/main/res/drawable/cameraswitch.png +0 -0
- package/android/src/main/res/drawable/circle_shape.xml +0 -0
- package/android/src/main/res/drawable/ic_launcher_background.xml +0 -0
- package/android/src/main/res/drawable/microphoneoff.png +0 -0
- package/android/src/main/res/drawable/microphoneonwhite.png +0 -0
- package/android/src/main/res/layout/custom_toast_green_layout.xml +18 -0
- package/android/src/main/res/layout/video_call_layout.xml +18 -11
- package/android/src/main/res/values/colors.xml +0 -0
- package/android/src/main/res/values/strings.xml +0 -0
- package/android/src/main/res.zip +0 -0
- package/ios/Plugin/VideoChatViewController.swift +37 -38
- package/ios/Plugin/vonagePlugin.swift +21 -17
- package/package.json +1 -1
- 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,8 +16,10 @@ 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;
|
@@ -51,7 +56,7 @@ import pub.devrel.easypermissions.AfterPermissionGranted;
|
|
51
56
|
import pub.devrel.easypermissions.EasyPermissions;
|
52
57
|
|
53
58
|
|
54
|
-
public class VideoCallActivity extends AppCompatActivity implements EasyPermissions.PermissionCallbacks {
|
59
|
+
public class VideoCallActivity extends AppCompatActivity implements EasyPermissions.PermissionCallbacks , Application.ActivityLifecycleCallbacks{
|
55
60
|
private static final String TAG = VideoCallActivity.class.getSimpleName();
|
56
61
|
private static final int PERMISSIONS_REQUEST_CODE = 124;
|
57
62
|
|
@@ -67,6 +72,7 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
67
72
|
boolean isPatientOnline = false;
|
68
73
|
boolean isMuted = false;
|
69
74
|
boolean isCamOff = false;
|
75
|
+
boolean isCallinprogress = false;
|
70
76
|
public boolean temptest = false;
|
71
77
|
boolean isTimeron = false;
|
72
78
|
boolean isEndall = false;
|
@@ -74,11 +80,13 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
74
80
|
private FrameLayout publisherViewContainer;
|
75
81
|
private LinearLayout ProviderViewLayout;
|
76
82
|
private FrameLayout subscriberViewContainer;
|
83
|
+
private TextView publisherNameTextView;
|
77
84
|
private FloatingActionButton fabCameraOff;
|
78
85
|
private ImageView imageViewEndcall;
|
79
86
|
private ImageView imageViewMute;
|
80
87
|
private ImageView imageViewCamOff;
|
81
88
|
private ImageView circleAvatar;
|
89
|
+
private boolean isAppInForeground;
|
82
90
|
|
83
91
|
private ImageView imageViewCamSwitch;
|
84
92
|
public static Button sendNotifications ;
|
@@ -87,6 +95,7 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
87
95
|
public static Button admit;
|
88
96
|
public static Button deny ;
|
89
97
|
|
98
|
+
|
90
99
|
private static final int LOG_INTERVAL_MILLIS = 1000; // Log every 100 milliseconds
|
91
100
|
|
92
101
|
private final Handler handler = new Handler();
|
@@ -121,6 +130,7 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
121
130
|
public void onStreamCreated(PublisherKit publisherKit, Stream stream) {
|
122
131
|
Log.d(TAG, "onStreamCreated: Publisher Stream Created. Own stream " + stream.getStreamId());
|
123
132
|
|
133
|
+
|
124
134
|
}
|
125
135
|
|
126
136
|
@Override
|
@@ -145,6 +155,11 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
145
155
|
try {
|
146
156
|
if (Framelayout != null) {
|
147
157
|
Framelayout.addView(publisher.getView());
|
158
|
+
LayoutInflater inflater = LayoutInflater.from(getApplicationContext());
|
159
|
+
View xmlDefinedView = inflater.inflate(R.layout.video_call_layout, Framelayout, false);
|
160
|
+
Framelayout.addView(xmlDefinedView);
|
161
|
+
publisherNameTextView.bringToFront();
|
162
|
+
|
148
163
|
}
|
149
164
|
} catch (Exception e) {}
|
150
165
|
if (publisher.getView() instanceof GLSurfaceView) {
|
@@ -184,7 +199,7 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
184
199
|
}
|
185
200
|
@Override
|
186
201
|
public void onStreamReceived(Session session, Stream stream) {
|
187
|
-
|
202
|
+
isCallinprogress = true;
|
188
203
|
ProviderViewLayout = findViewById(R.id.providerViewLayout);
|
189
204
|
if(ISPROVIDER) {
|
190
205
|
ProviderViewLayout.setVisibility(View.VISIBLE);
|
@@ -371,7 +386,7 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
371
386
|
ISPROVIDER = intent.getBooleanExtra("isProvider",false);
|
372
387
|
publisherViewContainer = findViewById(R.id.publisher_container);
|
373
388
|
subscriberViewContainer = findViewById(R.id.subscriber_container);
|
374
|
-
|
389
|
+
publisherNameTextView = findViewById(R.id.publisherName);
|
375
390
|
publishernameView = findViewById(R.id.publisherNameView);
|
376
391
|
TextView subscriberNameTextView = findViewById(R.id.subscriberName);
|
377
392
|
|
@@ -410,6 +425,7 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
410
425
|
new urltoSource((ImageView) findViewById(R.id.image_view)).execute(dummyImage);
|
411
426
|
initializeSession(API_KEY,SESSION_ID , TOKEN);
|
412
427
|
|
428
|
+
|
413
429
|
}
|
414
430
|
|
415
431
|
|
@@ -658,19 +674,23 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
658
674
|
|
659
675
|
private void showToast(String message) {
|
660
676
|
try{
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
view.
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
677
|
+
if(isAppInForeground()){
|
678
|
+
showGreenToast(getApplicationContext(),message);
|
679
|
+
}
|
680
|
+
// Toast toast = Toast.makeText(this, message, Toast.LENGTH_LONG);
|
681
|
+
// View view = toast.getView();
|
682
|
+
// int color = Color.parseColor("#1fc600");
|
683
|
+
// int colorText = Color.parseColor("#ffffff");
|
684
|
+
// view.getBackground().setColorFilter(Color.GREEN, PorterDuff.Mode.SRC_IN);
|
685
|
+
// TextView text = view.findViewById(android.R.id.message);
|
686
|
+
// text.setTextColor(Color.BLACK);
|
687
|
+
// toast.setGravity(Gravity.TOP, 0, 0);
|
688
|
+
// toast.show();
|
670
689
|
}catch(Exception e){
|
671
690
|
Log.d("toastlogex",e.toString());
|
672
691
|
}
|
673
692
|
}
|
693
|
+
|
674
694
|
private void finishWithMessage(String message) {
|
675
695
|
Log.e(TAG, message);
|
676
696
|
// Toast.makeText(this, message, Toast.LENGTH_LONG).show();
|
@@ -693,33 +713,54 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
693
713
|
Log.d("patientStatusChanged2", String.valueOf(isOnline));
|
694
714
|
Log.d("patientStatusChanged2", String.valueOf(isOnline));
|
695
715
|
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
716
|
+
if(!isCallinprogress){
|
717
|
+
runOnUiThread(new Runnable() {
|
718
|
+
@Override
|
719
|
+
public void run() {
|
720
|
+
temptest = isOnline;
|
721
|
+
if (isOnline) {
|
722
|
+
Log.d("isOnline", String.valueOf(isOnline));
|
723
|
+
|
724
|
+
patientStatus.setText("WAITING");
|
725
|
+
sendNotifications.setVisibility(View.GONE);
|
726
|
+
admit.setVisibility(View.VISIBLE);
|
727
|
+
deny.setVisibility(View.VISIBLE);
|
728
|
+
patientStatus.setBackgroundResource(R.color.waiting);
|
708
729
|
// patientStatus.setBackgroundColor(getResources().getColor(R.color.waiting));
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
730
|
+
} else {
|
731
|
+
Log.d("OFFLINE", String.valueOf(isOnline));
|
732
|
+
patientStatus.setText("OFFLINE");
|
733
|
+
admit.setVisibility(View.GONE);
|
734
|
+
deny.setVisibility(View.GONE);
|
735
|
+
sendNotifications.setVisibility(View.VISIBLE);
|
736
|
+
patientStatus.setText("OFFLINE");
|
737
|
+
patientStatus.setBackgroundResource(R.color.offline);
|
717
738
|
// patientStatus.setBackgroundColor(getResources().getColor(R.color.offline));
|
739
|
+
}
|
740
|
+
|
741
|
+
|
718
742
|
}
|
743
|
+
});
|
744
|
+
}
|
745
|
+
}
|
746
|
+
public static void showGreenToast(Context context, String message) {
|
747
|
+
LayoutInflater inflater = LayoutInflater.from(context);
|
748
|
+
View layout = inflater.inflate(R.layout.custom_toast_green_layout, null);
|
719
749
|
|
750
|
+
TextView text = layout.findViewById(R.id.toastView);
|
751
|
+
text.setText(message);
|
720
752
|
|
721
|
-
|
722
|
-
|
753
|
+
Toast toast = new Toast(context);
|
754
|
+
toast.setDuration(Toast.LENGTH_SHORT);
|
755
|
+
toast.setView(layout);
|
756
|
+
|
757
|
+
// Set toast position to top right corner
|
758
|
+
toast.setGravity(Gravity.TOP | Gravity.END, 0, 0);
|
759
|
+
|
760
|
+
toast.show();
|
761
|
+
}
|
762
|
+
private boolean isAppInForeground() {
|
763
|
+
return isAppInForeground;
|
723
764
|
}
|
724
765
|
|
725
766
|
public void notifyObservers(String value) {
|
@@ -727,6 +768,43 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
727
768
|
temp.update(value);
|
728
769
|
}
|
729
770
|
|
771
|
+
@Override
|
772
|
+
public void onActivityCreated(@NonNull Activity activity, @androidx.annotation.Nullable Bundle bundle) {
|
773
|
+
|
774
|
+
}
|
775
|
+
|
776
|
+
@Override
|
777
|
+
public void onActivityStarted(@NonNull Activity activity) {
|
778
|
+
|
779
|
+
}
|
780
|
+
|
781
|
+
@Override
|
782
|
+
public void onActivityResumed(@NonNull Activity activity) {
|
783
|
+
Log.d("isAppInForeground", String.valueOf(isAppInForeground));
|
784
|
+
isAppInForeground = true;
|
785
|
+
}
|
786
|
+
|
787
|
+
@Override
|
788
|
+
public void onActivityPaused(@NonNull Activity activity) {
|
789
|
+
Log.d("isAppInForeground", String.valueOf(isAppInForeground));
|
790
|
+
isAppInForeground = false;
|
791
|
+
}
|
792
|
+
|
793
|
+
@Override
|
794
|
+
public void onActivityStopped(@NonNull Activity activity) {
|
795
|
+
|
796
|
+
}
|
797
|
+
|
798
|
+
@Override
|
799
|
+
public void onActivitySaveInstanceState(@NonNull Activity activity, @NonNull Bundle bundle) {
|
800
|
+
|
801
|
+
}
|
802
|
+
|
803
|
+
@Override
|
804
|
+
public void onActivityDestroyed(@NonNull Activity activity) {
|
805
|
+
|
806
|
+
}
|
807
|
+
|
730
808
|
private class urltoSource extends AsyncTask<String, Void, Bitmap> {
|
731
809
|
ImageView imageView;
|
732
810
|
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
|
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>
|
@@ -70,22 +70,29 @@
|
|
70
70
|
android:layout_height="120dp"
|
71
71
|
android:layout_gravity="bottom|end"
|
72
72
|
android:layout_marginEnd="16dp"
|
73
|
-
android:layout_marginBottom="
|
73
|
+
android:layout_marginBottom="110dp"
|
74
74
|
android:background="#9b9c98"
|
75
75
|
|
76
76
|
android:padding="2dp" >
|
77
|
-
|
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" />
|
77
|
+
|
87
78
|
|
88
79
|
</FrameLayout>
|
80
|
+
<TextView
|
81
|
+
android:id="@+id/subscriberName"
|
82
|
+
android:layout_width="100dp"
|
83
|
+
android:layout_height="wrap_content"
|
84
|
+
android:layout_gravity="bottom|end"
|
85
|
+
android:paddingBottom="6dp"
|
86
|
+
android:layout_marginEnd="16dp"
|
87
|
+
android:layout_marginBottom="80dp"
|
88
|
+
android:maxLines="1"
|
89
|
+
android:ellipsize="end"
|
90
|
+
android:text="@string/subscriber_name"
|
91
|
+
android:textColor="@android:color/white"
|
92
|
+
android:visibility="visible"
|
93
|
+
android:gravity="center"
|
94
|
+
android:textSize="12sp" />
|
95
|
+
|
89
96
|
|
90
97
|
<de.hdodenhof.circleimageview.CircleImageView
|
91
98
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
File without changes
|
File without changes
|
package/android/src/main/res.zip
CHANGED
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
|
-
|
130
|
-
|
131
|
-
|
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
|
-
|
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
|
@@ -415,7 +408,8 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
|
|
415
408
|
subscriberNameLabel.isHidden = false
|
416
409
|
subscriberStatusLabel.text = "Please Wait.."
|
417
410
|
let userInfo = ["userInfo": ["isProvider": isProvider]]
|
418
|
-
NotificationCenter.default.post(name: NSNotification.Name("SendNotification"),object: nil,userInfo: userInfo)
|
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)
|
@@ -436,14 +430,16 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
|
|
436
430
|
// self.stopTimer()
|
437
431
|
// self.dismiss(animated: true, completion: nil)
|
438
432
|
let userInfo = ["userInfo": ["isProvider": isProvider]]
|
439
|
-
NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoStarted),object: nil,userInfo: userInfo)
|
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
439
|
let userInfo = ["userInfo": ["isProvider": isProvider]]
|
445
440
|
|
446
|
-
|
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)
|
@@ -454,7 +450,8 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
|
|
454
450
|
@objc func callBtnbuttonClicked() {
|
455
451
|
|
456
452
|
let userInfo = ["userInfo": ["isProvider": isProvider]]
|
457
|
-
|
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
|
|
@@ -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
|
-
|
559
|
-
|
560
|
-
|
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)
|
@@ -590,6 +584,9 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
|
|
590
584
|
if(stream.videoType == .screen){
|
591
585
|
subscriberView.accessibilityValue = "from screen"
|
592
586
|
}
|
587
|
+
adminBtn.isHidden = true
|
588
|
+
denyBtn.isHidden = true
|
589
|
+
sendNotificationBtn.isHidden = true
|
593
590
|
remoteView.addSubview(subscriberView)
|
594
591
|
}
|
595
592
|
|
@@ -604,7 +601,8 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
|
|
604
601
|
if let subStream = subscriber?.stream, subStream.streamId == stream.streamId,!isProvider, stream.videoType != .screen {
|
605
602
|
// cleanupSubscriber()
|
606
603
|
let userInfo = ["userInfo": ["isProvider": isProvider]]
|
607
|
-
|
604
|
+
// NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoEnded),object: nil,userInfo: userInfo)
|
605
|
+
delegate?.videoCallEnded(userInfo)
|
608
606
|
// self.session?.disconnect(nil)
|
609
607
|
self.endVonageCall()
|
610
608
|
//self.dismiss(animated: true, completion: nil)
|
@@ -684,26 +682,27 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
|
|
684
682
|
isCallEnded = true
|
685
683
|
let userInfo = ["userInfo": ["isProvider": self.isProvider]]
|
686
684
|
|
687
|
-
|
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
|
-
|
694
|
-
|
691
|
+
//let userInfo = ["userInfo": ["isProvider": self.isProvider]]
|
692
|
+
// NotificationCenter.default.post(name: NSNotification.Name("RemoveObservers"),object: nil,userInfo: userInfo)
|
693
|
+
// DispatchQueue.main.async {
|
695
694
|
print("video ended called")
|
696
695
|
// self.publisher?.publishVideo = false
|
697
|
-
self.publisher?.videoCapture?.stop()
|
696
|
+
// self.publisher?.videoCapture?.stop()
|
698
697
|
// self.publisher?.publishAudio = false
|
699
698
|
self.session?.disconnect(nil)
|
700
|
-
|
701
|
-
self.cleanupPublisher()
|
699
|
+
// self.cleanupSubscriber()
|
700
|
+
//self.cleanupPublisher()
|
702
701
|
self.stopTimer()
|
703
702
|
self.dismiss(animated: true) {
|
704
703
|
print("video ended")
|
705
704
|
}
|
706
|
-
}
|
705
|
+
//}
|
707
706
|
}
|
708
707
|
fileprivate func cleanupSubscriber() {
|
709
708
|
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
|
-
|
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,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>
|