capacitor-plugin-vonage 0.0.3 → 0.0.5

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/README.md CHANGED
@@ -16,7 +16,8 @@ npx cap sync
16
16
  * [`echo(...)`](#echo)
17
17
  * [`openVideoCallWindow(...)`](#openvideocallwindow)
18
18
  * [`endVideoCall()`](#endvideocall)
19
- * [`addListener([eventName: 'VideoCallEnded', listenerFunc: (info: any) => void] | [eventName: 'VideoCallStarted', listenerFunc: (info: any) => void], ...)`](#addlistenereventname-videocallended-listenerfunc-info-any--void--eventname-videocallstarted-listenerfunc-info-any--void)
19
+ * [`setPatientOnlineStatus(...)`](#setpatientonlinestatus)
20
+ * [`addListener([eventName: 'VideoCallEnded', listenerFunc: (info: any) => void] | [eventName: 'SendNotification', listenerFunc: (info: any) => void] | [eventName: 'VideoCallStarted', listenerFunc: (info: any) => void], ...)`](#addlistenereventname-videocallended-listenerfunc-info-any--void--eventname-sendnotification-listenerfunc-info-any--void--eventname-videocallstarted-listenerfunc-info-any--void)
20
21
  * [Interfaces](#interfaces)
21
22
  * [Type Aliases](#type-aliases)
22
23
 
@@ -66,15 +67,30 @@ endVideoCall() => Promise<{ value: string; }>
66
67
  --------------------
67
68
 
68
69
 
69
- ### addListener([eventName: 'VideoCallEnded', listenerFunc: (info: any) => void] | [eventName: 'VideoCallStarted', listenerFunc: (info: any) => void], ...)
70
+ ### setPatientOnlineStatus(...)
70
71
 
71
72
  ```typescript
72
- addListener(...args: [eventName: "VideoCallEnded", listenerFunc: (info: any) => void] | [eventName: "VideoCallStarted", listenerFunc: (info: any) => void]) => Promise<PluginListenerHandle> & PluginListenerHandle
73
+ setPatientOnlineStatus(options: Object) => Promise<{ value: any; }>
73
74
  ```
74
75
 
75
- | Param | Type |
76
- | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
77
- | **`args`** | <code>[eventName: 'VideoCallEnded', listenerFunc: (info: any) =&gt; void] \| [eventName: 'VideoCallStarted', listenerFunc: (info: any) =&gt; void]</code> |
76
+ | Param | Type |
77
+ | ------------- | ----------------------------------------- |
78
+ | **`options`** | <code><a href="#object">Object</a></code> |
79
+
80
+ **Returns:** <code>Promise&lt;{ value: any; }&gt;</code>
81
+
82
+ --------------------
83
+
84
+
85
+ ### addListener([eventName: 'VideoCallEnded', listenerFunc: (info: any) => void] | [eventName: 'SendNotification', listenerFunc: (info: any) => void] | [eventName: 'VideoCallStarted', listenerFunc: (info: any) => void], ...)
86
+
87
+ ```typescript
88
+ addListener(...args: [eventName: "VideoCallEnded", listenerFunc: (info: any) => void] | [eventName: "SendNotification", listenerFunc: (info: any) => void] | [eventName: "VideoCallStarted", listenerFunc: (info: any) => void]) => Promise<PluginListenerHandle> & PluginListenerHandle
89
+ ```
90
+
91
+ | Param | Type |
92
+ | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
93
+ | **`args`** | <code>[eventName: 'VideoCallEnded', listenerFunc: (info: any) =&gt; void] \| [eventName: 'SendNotification', listenerFunc: (info: any) =&gt; void] \| [eventName: 'VideoCallStarted', listenerFunc: (info: any) =&gt; void]</code> |
78
94
 
79
95
  **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt; & <a href="#pluginlistenerhandle">PluginListenerHandle</a></code>
80
96
 
@@ -1,6 +1,7 @@
1
1
  <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
2
  <application>
3
- <activity android:name="com.managemyhealth.plugin.vonage.VideoCallActivity">
3
+ <activity android:name="com.managemyhealth.plugin.vonage.VideoCallActivity"
4
+ android:screenOrientation="portrait">
4
5
  </activity>
5
6
  </application>
6
7
  </manifest>
@@ -1,9 +1,12 @@
1
1
  package com.managemyhealth.plugin.vonage;
2
2
 
3
3
 
4
-
4
+ import android.annotation.SuppressLint;
5
+ import android.os.AsyncTask;
5
6
  import android.app.ActionBar;
6
7
  import android.content.Intent;
8
+ import android.graphics.Bitmap;
9
+ import android.graphics.BitmapFactory;
7
10
  import android.nfc.Tag;
8
11
  import android.opengl.GLSurfaceView;
9
12
  import android.os.Bundle;
@@ -32,6 +35,7 @@ import com.opentok.android.SubscriberKit;
32
35
  //import com.tokbox.sample.basicvideochat.network.APIService;
33
36
  //import com.tokbox.sample.basicvideochat.network.GetSessionResponse;
34
37
 
38
+ import java.io.InputStream;
35
39
  import java.util.List;
36
40
 
37
41
  import okhttp3.OkHttpClient;
@@ -47,8 +51,10 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
47
51
  private static final String TAG = VideoCallActivity.class.getSimpleName();
48
52
  private static final int PERMISSIONS_REQUEST_CODE = 124;
49
53
 
50
- private Session session;
54
+ public Session session;
51
55
  private Publisher publisher;
56
+ String SUBSCRIBERNAME ;
57
+ String PUBLISHERNAME;
52
58
  boolean isMuted = false;
53
59
  boolean isCamOff = false;
54
60
  boolean isTimeron = false;
@@ -80,12 +86,12 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
80
86
  public void onError(PublisherKit publisherKit, OpentokError opentokError) {
81
87
  finishWithMessage("PublisherKit onError: " + opentokError.getMessage());
82
88
  }
89
+
83
90
  };
84
91
 
85
92
  private final Session.SessionListener sessionListener = new Session.SessionListener() {
86
93
  @Override
87
94
  public void onConnected(Session session) {
88
-
89
95
  Log.d(TAG, "onConnected: Connected to session: " + session.getSessionId());
90
96
  // JSObject eventData = new JSObject();
91
97
  // eventData.put("key", "value");
@@ -139,12 +145,14 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
139
145
 
140
146
  @Override
141
147
  public void onStreamReceived(Session session, Stream stream) {
148
+
142
149
  Log.d(TAG, "onStreamReceived: New Stream Received " + stream.getStreamId() + " in session: " + session.getSessionId());
143
150
 
144
151
  if (subscriber == null) {
145
152
  subscriber = new Subscriber.Builder(VideoCallActivity.this, stream).build();
146
153
  subscriber.getRenderer().setStyle(BaseVideoRenderer.STYLE_VIDEO_SCALE, BaseVideoRenderer.STYLE_VIDEO_FILL);
147
154
  subscriber.setSubscriberListener(subscriberListener);
155
+ subscriber.setVideoListener(videoListener);
148
156
  session.subscribe(subscriber);
149
157
  try {
150
158
  subscriberViewContainer.addView(subscriber.getView());
@@ -152,6 +160,8 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
152
160
  Log.d("subscriberViewContainer", e.toString());
153
161
 
154
162
  }
163
+ showToast(SUBSCRIBERNAME + "joined the call");
164
+
155
165
  }
156
166
  }
157
167
 
@@ -175,17 +185,51 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
175
185
  if (subscriber != null) {
176
186
  subscriber = null;
177
187
  subscriberViewContainer.removeAllViews();
188
+ showToast(SUBSCRIBERNAME + " left the call");
189
+
178
190
  }
179
191
  }
180
192
  }
181
193
 
194
+
182
195
  @Override
183
196
  public void onError(Session session, OpentokError opentokError) {
184
197
  finishWithMessage("Session error: " + opentokError.getMessage());
185
198
  }
186
199
  };
200
+ SubscriberKit.VideoListener videoListener = new SubscriberKit.VideoListener() {
201
+
202
+ @Override
203
+ public void onVideoDataReceived(SubscriberKit subscriberKit) {
204
+
205
+ }
206
+
207
+ @Override
208
+ public void onVideoDisabled(SubscriberKit subscriberKit, String s) {
209
+ showToast(SUBSCRIBERNAME + " video disabled");
210
+
211
+ }
212
+
213
+ @Override
214
+ public void onVideoEnabled(SubscriberKit subscriberKit, String s) {
215
+ showToast(SUBSCRIBERNAME + " video enabled");
216
+
217
+
218
+ }
219
+
220
+ @Override
221
+ public void onVideoDisableWarning(SubscriberKit subscriberKit) {
222
+
223
+ }
224
+
225
+ @Override
226
+ public void onVideoDisableWarningLifted(SubscriberKit subscriberKit) {
227
+
228
+ }
229
+ };
187
230
 
188
231
  SubscriberKit.SubscriberListener subscriberListener = new SubscriberKit.SubscriberListener() {
232
+
189
233
  @Override
190
234
  public void onConnected(SubscriberKit subscriberKit) {
191
235
  Log.d(TAG, "onConnected: Subscriber connected. Stream: " + subscriberKit.getStream().getStreamId());
@@ -194,10 +238,14 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
194
238
  @Override
195
239
  public void onDisconnected(SubscriberKit subscriberKit) {
196
240
  Log.d(TAG, "onDisconnected: Subscriber disconnected. Stream: " + subscriberKit.getStream().getStreamId());
241
+
197
242
  }
198
243
 
244
+
245
+
199
246
  @Override
200
247
  public void onError(SubscriberKit subscriberKit, OpentokError opentokError) {
248
+ showToast(SUBSCRIBERNAME + " failed to connect to the call");
201
249
  finishWithMessage("SubscriberKit onError: " + opentokError.getMessage());
202
250
  }
203
251
  };
@@ -219,6 +267,7 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
219
267
  session.disconnect();
220
268
  }
221
269
 
270
+ @SuppressLint("MissingInflatedId")
222
271
  @Override
223
272
  protected void onCreate(Bundle savedInstanceState) {
224
273
 
@@ -226,6 +275,8 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
226
275
 
227
276
  super.onCreate(savedInstanceState);
228
277
  setContentView(R.layout.video_call_layout);
278
+ new DownloadImageFromInternet((ImageView) findViewById(R.id.image_view)).execute("https://www.gravatar.com/avatar/?d=mp");
279
+
229
280
  getSupportActionBar().hide();
230
281
  ActionBar actionBar = getActionBar();
231
282
  if (actionBar != null) {
@@ -237,15 +288,15 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
237
288
  String TOKEN = intent.getStringExtra("token");
238
289
  String SESSION_ID = intent.getStringExtra("sessionId");
239
290
  String API_KEY = intent.getStringExtra("apiKey");
240
- String SUBSCRIBERNAME = intent.getStringExtra("subscriberName");
241
- String PUBLISHERNAME = intent.getStringExtra("publisherName");
291
+ SUBSCRIBERNAME = intent.getStringExtra("subscriberName");
292
+ PUBLISHERNAME = intent.getStringExtra("publisherName");
242
293
  ISPROVIDER = intent.getBooleanExtra("isProvider",false);
243
294
  publisherViewContainer = findViewById(R.id.publisher_container);
244
295
  subscriberViewContainer = findViewById(R.id.subscriber_container);
245
296
  TextView publisherNameTextView = findViewById(R.id.publisherName);
246
297
  TextView subscriberNameTextView = findViewById(R.id.subscriberName);
247
- publisherNameTextView.setText(PUBLISHERNAME);
248
- subscriberNameTextView.setText(SUBSCRIBERNAME);
298
+ publisherNameTextView.setText(SUBSCRIBERNAME);
299
+ subscriberNameTextView.setText(PUBLISHERNAME);
249
300
  timerTextView = findViewById(R.id.timerTextView);
250
301
  startTime = System.currentTimeMillis();
251
302
  isTimeron =true;
@@ -270,30 +321,34 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
270
321
  }
271
322
  });
272
323
 
273
- imageViewMute.setOnClickListener(new View.OnClickListener() {
324
+ imageViewMute.setOnClickListener(new View.OnClickListener() {//mute and unmute audio
274
325
  @Override
275
326
  public void onClick(View v) {
276
327
 
277
- if (!isMuted) {
278
- publisher.setPublishAudio(false);
279
- imageViewMute.setImageResource(R.drawable.microphoneoff);
280
- } else {
281
- publisher.setPublishAudio(true);
282
- imageViewMute.setImageResource(R.drawable.microphoneonwhite);
328
+ if(publisher!=null) {
329
+ if (!isMuted) {
330
+ publisher.setPublishAudio(false);
331
+ imageViewMute.setImageResource(R.drawable.microphoneoff);
332
+ } else {
333
+ publisher.setPublishAudio(true);
334
+ imageViewMute.setImageResource(R.drawable.microphoneonwhite);
335
+ }
336
+ isMuted = !isMuted;
283
337
  }
284
- isMuted = !isMuted;
285
338
 
286
339
  }
287
340
  });
288
- imageViewCamOff.setOnClickListener(new View.OnClickListener() {
341
+ imageViewCamOff.setOnClickListener(new View.OnClickListener() {//off & on camera
289
342
  @Override
290
343
  public void onClick(View v) {
344
+ if(publisher!=null) {
291
345
 
292
346
  if (!isCamOff) {
293
347
  publisher.setPublishVideo(false);
294
348
  imageViewCamOff.setImageResource(R.drawable.cameraoff);
295
349
  imageViewCamSwitch.setVisibility(View.GONE);
296
350
 
351
+
297
352
  } else {
298
353
  publisher.setPublishVideo(true);
299
354
  imageViewCamOff.setImageResource(R.drawable.cameraonwhite);
@@ -303,14 +358,14 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
303
358
  isCamOff = !isCamOff;
304
359
 
305
360
  }
361
+ }
306
362
  });
307
363
  imageViewCamSwitch.setOnClickListener(new View.OnClickListener() {
308
364
  @Override
309
365
  public void onClick(View v) {
310
- publisher.cycleCamera();
311
-
312
-
313
-
366
+ if(publisher!=null) {
367
+ publisher.cycleCamera();//flip camera
368
+ }
314
369
  }
315
370
  });
316
371
 
@@ -335,21 +390,24 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
335
390
  }
336
391
  }
337
392
  public void endCall() {
338
- isEndall =true;
339
- killvc();
340
-
341
- }
342
- public void killvc(){
343
- runOnUiThread(new Runnable() {
344
- @Override
345
- public void run() {
346
- Log.d("endVideoCall","PluginMethodendVideoCall");
347
- // Update UI components or perform UI-related operations here
348
- }
349
- });
393
+ session.disconnect();
350
394
 
395
+ isEndall =true;
396
+ // killvc();
351
397
 
352
398
  }
399
+ // public void killvc(){
400
+ // runOnUiThread(new Runnable() {
401
+ // @Override
402
+ // public void run() {
403
+ // Log.d("endVideoCall","PluginMethodendVideoCall");
404
+ // Log.d("endVideoCall",session.toString());
405
+ //
406
+ // }
407
+ // });
408
+ //
409
+ //
410
+ // }
353
411
  private void startTimer() {
354
412
  // startTime = System.currentTimeMillis();
355
413
  Handler handler = new Handler();
@@ -424,10 +482,10 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
424
482
 
425
483
 
426
484
  private void initializeSession(String apiKey, String sessionId, String token) {
485
+ Log.i(TAG, "initializeSession: " + "initializeSession");
427
486
  Log.i(TAG, "apiKey: " + apiKey);
428
487
  Log.i(TAG, "sessionId: " + sessionId);
429
488
  Log.i(TAG, "token: " + token);
430
-
431
489
  /*
432
490
  The context used depends on the specific use case, but usually, it is desired for the session to
433
491
  live outside of the Activity e.g: live between activities. For a production applications,
@@ -436,6 +494,8 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
436
494
  session = new Session.Builder(this, apiKey, sessionId).build();
437
495
  session.setSessionListener(sessionListener);
438
496
  session.connect(token);
497
+ Log.d("initializeSession","session.toString()");
498
+ Log.d("initializeSession",session.toString());
439
499
  }
440
500
 
441
501
  // private void initRetrofit() {
@@ -455,9 +515,12 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
455
515
  //// apiService = retrofit.create(APIService.class);
456
516
  // }
457
517
 
518
+ private void showToast(String message) {
519
+ Toast.makeText(this, message, Toast.LENGTH_LONG).show();
520
+ }
458
521
  private void finishWithMessage(String message) {
459
522
  Log.e(TAG, message);
460
- Toast.makeText(this, message, Toast.LENGTH_LONG).show();
523
+ // Toast.makeText(this, message, Toast.LENGTH_LONG).show();
461
524
  session.disconnect();
462
525
  Intent resultIntent = new Intent();
463
526
  String resultcode = ISPROVIDER?"999":"888";
@@ -465,4 +528,26 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
465
528
  setResult(RESULT_OK, resultIntent);
466
529
  this.finish();
467
530
  }
531
+ private class DownloadImageFromInternet extends AsyncTask<String, Void, Bitmap> {
532
+ ImageView imageView;
533
+ public DownloadImageFromInternet(ImageView imageView) {
534
+ this.imageView=imageView;
535
+ Toast.makeText(getApplicationContext(), "Please wait, it may take a few minute...",Toast.LENGTH_SHORT).show();
536
+ }
537
+ protected Bitmap doInBackground(String... urls) {
538
+ String imageURL=urls[0];
539
+ Bitmap bimage=null;
540
+ try {
541
+ InputStream in=new java.net.URL(imageURL).openStream();
542
+ bimage= BitmapFactory.decodeStream(in);
543
+ } catch (Exception e) {
544
+ Log.e("Error Message", e.getMessage());
545
+ e.printStackTrace();
546
+ }
547
+ return bimage;
548
+ }
549
+ protected void onPostExecute(Bitmap result) {
550
+ imageView.setImageBitmap(result);
551
+ }
552
+ }
468
553
  }
@@ -38,8 +38,8 @@ public class vonagePlugin extends Plugin {
38
38
  @Override
39
39
  public void run() {
40
40
  try{
41
- VideoCallActivity videoCallActivity = new VideoCallActivity();
42
- videoCallActivity.endCall();
41
+ // VideoCallActivity videoCallActivity = new VideoCallActivity();
42
+ // videoCallActivity.;
43
43
  }catch (Exception e){
44
44
  showLog(e.toString());
45
45
  }
@@ -67,7 +67,6 @@ public class vonagePlugin extends Plugin {
67
67
  intent.putExtra("token",TOKEN);
68
68
  intent.putExtra("subscriberName",SUBSCRIBERNAME);
69
69
  intent.putExtra("publisherName",PUBLISHERNAME);
70
- intent.putExtra("publisherName",PUBLISHERNAME);
71
70
  intent.putExtra("isProvider",ISPROVIDER);
72
71
  // intent.putExtra("callbackIdentifier", );
73
72
  // notifyListeners("onDataReceived", );
@@ -107,13 +106,16 @@ public class vonagePlugin extends Plugin {
107
106
  showLog("ewererewrwerwe");
108
107
  showLog(e.toString());
109
108
  }
110
- if(isProvid){
111
- eventData.put("isProvider", true);
112
- notifyListeners("VideoCallEnded",eventData);
113
- }else{
114
- eventData.put("isProvider", false);
115
- Log.d(TAG,"CODE 98 -----------" );
116
- notifyListeners("VideoCallEnded",eventData);
109
+ VideoCallActivity videoCallActivity = new VideoCallActivity();
110
+ if(!videoCallActivity.isEndall){
111
+ if (isProvid) {
112
+ eventData.put("isProvider", true);
113
+ notifyListeners("VideoCallEnded", eventData);
114
+ } else {
115
+ eventData.put("isProvider", false);
116
+ Log.d(TAG, "CODE 98 -----------");
117
+ notifyListeners("VideoCallEnded", eventData);
118
+ }
117
119
  }
118
120
  }
119
121
 
@@ -30,21 +30,32 @@
30
30
  app:layout_constraintEnd_toEndOf="parent"
31
31
  app:layout_constraintStart_toStartOf="parent"
32
32
  app:layout_constraintTop_toTopOf="parent">
33
+ <!-- android:background="#FF5733"-->
33
34
 
34
35
  <FrameLayout
35
36
  android:id="@+id/subscriber_container"
36
37
  android:layout_width="fill_parent"
37
- android:layout_height="match_parent" />
38
+ android:layout_height="match_parent"
39
+ android:background="#9b9c98" >
40
+
41
+ <ImageView
42
+ android:id="@+id/image_view"
43
+ android:layout_width="150dp"
44
+ android:layout_height="150dp"
45
+ android:scaleType="centerCrop" />
46
+ </FrameLayout>
38
47
 
39
48
  <TextView
40
49
  android:id="@+id/publisherName"
41
- android:layout_width="140dp"
42
- android:layout_height="157dp"
50
+ android:layout_width="150dp"
51
+ android:layout_height="wrap_content"
52
+
43
53
  android:layout_gravity="bottom|start"
44
54
  android:paddingLeft="10dp"
45
55
  android:paddingBottom="120dp"
56
+
46
57
  android:text="Publisher Name"
47
- android:textColor="@android:color/background_dark"
58
+ android:textColor="@android:color/white"
48
59
  android:textSize="16sp"
49
60
  android:visibility="visible" />
50
61
  <TextView
@@ -56,7 +67,7 @@
56
67
  android:paddingLeft="10dp"
57
68
  android:text="00:00:00"
58
69
  android:visibility="visible"
59
- android:textColor="@android:color/background_dark"
70
+ android:textColor="@android:color/white"
60
71
  android:textSize="16sp" />
61
72
 
62
73
  <FrameLayout
@@ -67,21 +78,39 @@
67
78
  android:layout_marginEnd="16dp"
68
79
  android:layout_marginRight="16dp"
69
80
  android:layout_marginBottom="80dp"
70
- android:background="#FFFFFF"
81
+ android:background="#9b9c98"
71
82
  android:layout_below="@id/subscriberName"
72
83
 
73
84
  android:padding="2dp" >
74
85
 
75
- <TextView
76
- android:id="@+id/subscriberName"
77
- android:layout_width="wrap_content"
78
- android:layout_height="wrap_content"
79
- android:layout_gravity="bottom|start"
80
- android:textSize="12sp"
81
- android:text="Subscriber Name"
82
- android:paddingBottom="5dp"
83
- android:textColor="@android:color/background_dark" />
84
86
  </FrameLayout>
87
+ <TextView
88
+ android:id="@+id/subscriberName"
89
+ android:layout_width="100dp"
90
+ android:layout_height="wrap_content"
91
+ android:layout_gravity="bottom|end"
92
+ android:textSize="12sp"
93
+ android:text="Subscriber Name"
94
+ android:paddingBottom="25dp"
95
+ android:layout_marginRight="16dp"
96
+ android:layout_marginBottom="80dp"
97
+ android:textColor="@android:color/white" />
98
+ <androidx.cardview.widget.CardView
99
+ android:layout_width="155dp"
100
+ android:layout_height="155dp"
101
+ app:cardCornerRadius="250dp"
102
+ app:cardBackgroundColor="@android:color/white">
103
+
104
+ <androidx.cardview.widget.CardView
105
+ android:layout_width="150dp"
106
+ android:layout_height="150dp"
107
+ app:cardCornerRadius="250dp"
108
+ android:layout_gravity="center">
109
+
110
+ </androidx.cardview.widget.CardView>
111
+
112
+ </androidx.cardview.widget.CardView>
113
+
85
114
 
86
115
  </FrameLayout>
87
116
 
@@ -94,7 +123,7 @@
94
123
 
95
124
  <LinearLayout
96
125
  android:layout_width="fill_parent"
97
- android:layout_height="49dp"
126
+ android:layout_height="53dp"
98
127
  android:layout_alignParentBottom="false"
99
128
  android:gravity="clip_horizontal"
100
129
  android:orientation="horizontal"
package/dist/docs.json CHANGED
@@ -49,14 +49,32 @@
49
49
  "complexTypes": [],
50
50
  "slug": "endvideocall"
51
51
  },
52
+ {
53
+ "name": "setPatientOnlineStatus",
54
+ "signature": "(options: Object) => Promise<{ value: any; }>",
55
+ "parameters": [
56
+ {
57
+ "name": "options",
58
+ "docs": "",
59
+ "type": "Object"
60
+ }
61
+ ],
62
+ "returns": "Promise<{ value: any; }>",
63
+ "tags": [],
64
+ "docs": "",
65
+ "complexTypes": [
66
+ "Object"
67
+ ],
68
+ "slug": "setpatientonlinestatus"
69
+ },
52
70
  {
53
71
  "name": "addListener",
54
- "signature": "(...args: [eventName: \"VideoCallEnded\", listenerFunc: (info: any) => void] | [eventName: \"VideoCallStarted\", listenerFunc: (info: any) => void]) => Promise<PluginListenerHandle> & PluginListenerHandle",
72
+ "signature": "(...args: [eventName: \"VideoCallEnded\", listenerFunc: (info: any) => void] | [eventName: \"SendNotification\", listenerFunc: (info: any) => void] | [eventName: \"VideoCallStarted\", listenerFunc: (info: any) => void]) => Promise<PluginListenerHandle> & PluginListenerHandle",
55
73
  "parameters": [
56
74
  {
57
75
  "name": "args",
58
76
  "docs": "",
59
- "type": "[eventName: 'VideoCallEnded', listenerFunc: (info: any) => void] | [eventName: 'VideoCallStarted', listenerFunc: (info: any) => void]"
77
+ "type": "[eventName: 'VideoCallEnded', listenerFunc: (info: any) => void] | [eventName: 'SendNotification', listenerFunc: (info: any) => void] | [eventName: 'VideoCallStarted', listenerFunc: (info: any) => void]"
60
78
  }
61
79
  ],
62
80
  "returns": "Promise<PluginListenerHandle> & PluginListenerHandle",
@@ -65,7 +83,7 @@
65
83
  "complexTypes": [
66
84
  "PluginListenerHandle"
67
85
  ],
68
- "slug": "addlistenereventname-videocallended-listenerfunc-info-any--void--eventname-videocallstarted-listenerfunc-info-any--void"
86
+ "slug": "addlistenereventname-videocallended-listenerfunc-info-any--void--eventname-sendnotification-listenerfunc-info-any--void--eventname-videocallstarted-listenerfunc-info-any--void"
69
87
  }
70
88
  ],
71
89
  "properties": []
@@ -11,5 +11,8 @@ export interface vonagePlugin {
11
11
  endVideoCall(): Promise<{
12
12
  value: string;
13
13
  }>;
14
- addListener(...args: [eventName: 'VideoCallEnded', listenerFunc: (info: any) => void] | [eventName: 'VideoCallStarted', listenerFunc: (info: any) => void]): Promise<PluginListenerHandle> & PluginListenerHandle;
14
+ setPatientOnlineStatus(options: Object): Promise<{
15
+ value: any;
16
+ }>;
17
+ addListener(...args: [eventName: 'VideoCallEnded', listenerFunc: (info: any) => void] | [eventName: 'SendNotification', listenerFunc: (info: any) => void] | [eventName: 'VideoCallStarted', listenerFunc: (info: any) => void]): Promise<PluginListenerHandle> & PluginListenerHandle;
15
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import { PluginListenerHandle } from \"@capacitor/core\";\n\nexport interface vonagePlugin {\n echo(options: { value: string }): Promise<{ value: string }>;\n openVideoCallWindow(options: Object): Promise<{ value: any }>;\n endVideoCall(): Promise<{ value: string }>;\n addListener(...args: [eventName: 'VideoCallEnded', listenerFunc: (info: any) => void] | [eventName: 'VideoCallStarted', listenerFunc: (info: any) => void]): Promise<PluginListenerHandle> & PluginListenerHandle;\n\n}\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import { PluginListenerHandle } from \"@capacitor/core\";\n\nexport interface vonagePlugin {\n echo(options: { value: string }): Promise<{ value: string }>;\n openVideoCallWindow(options: Object): Promise<{ value: any }>;\n endVideoCall(): Promise<{ value: string }>;\n setPatientOnlineStatus(options: Object): Promise<{ value: any }>;\n addListener(...args: [eventName: 'VideoCallEnded', listenerFunc: (info: any) => void] | [eventName: 'SendNotification', listenerFunc: (info: any) => void] | [eventName: 'VideoCallStarted', listenerFunc: (info: any) => void]): Promise<PluginListenerHandle> & PluginListenerHandle;\n\n}\n"]}
package/dist/esm/web.d.ts CHANGED
@@ -12,4 +12,7 @@ export declare class vonageWeb extends WebPlugin implements vonagePlugin {
12
12
  openVideoCallWindow(options: Object): Promise<{
13
13
  value: any;
14
14
  }>;
15
+ setPatientOnlineStatus(options: Object): Promise<{
16
+ value: any;
17
+ }>;
15
18
  }
package/dist/esm/web.js CHANGED
@@ -13,5 +13,10 @@ export class vonageWeb extends WebPlugin {
13
13
  console.log('openVideoCallWindow', options);
14
14
  return dummyValue;
15
15
  }
16
+ async setPatientOnlineStatus(options) {
17
+ let dummyValue;
18
+ console.log('setPatientOnlineStatus', options);
19
+ return dummyValue;
20
+ }
16
21
  }
17
22
  //# sourceMappingURL=web.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,SAAU,SAAQ,SAAS;IACtC,YAAY;QACV,IAAI,UAAc,CAAC;QACnB,OAAO,UAAU,CAAC;IACpB,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,OAA0B;QACnC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC7B,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,KAAK,CAAC,mBAAmB,CAAC,OAAe;QACvC,IAAI,UAAc,CAAC;QACnB,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,OAAO,CAAC,CAAC;QAC5C,OAAO,UAAU,CAAC;IACpB,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { vonagePlugin } from './definitions';\n\nexport class vonageWeb extends WebPlugin implements vonagePlugin {\n endVideoCall(): Promise<{ value: string; }> {\n let dummyValue:any;\n return dummyValue;\n }\n async echo(options: { value: string }): Promise<{ value: string }> {\n console.log('ECHO', options);\n return options;\n }\n async openVideoCallWindow(options: Object): Promise<{ value: any }>{\n let dummyValue:any;\n console.log('openVideoCallWindow', options);\n return dummyValue;\n }\n}\n"]}
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,SAAU,SAAQ,SAAS;IACtC,YAAY;QACV,IAAI,UAAc,CAAC;QACnB,OAAO,UAAU,CAAC;IACpB,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,OAA0B;QACnC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC7B,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,KAAK,CAAC,mBAAmB,CAAC,OAAe;QACvC,IAAI,UAAc,CAAC;QACnB,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,OAAO,CAAC,CAAC;QAC5C,OAAO,UAAU,CAAC;IACpB,CAAC;IACD,KAAK,CAAC,sBAAsB,CAAC,OAAe;QAC1C,IAAI,UAAc,CAAC;QACnB,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAAE,OAAO,CAAC,CAAC;QAC/C,OAAO,UAAU,CAAC;IACpB,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { vonagePlugin } from './definitions';\n\nexport class vonageWeb extends WebPlugin implements vonagePlugin {\n endVideoCall(): Promise<{ value: string; }> {\n let dummyValue:any;\n return dummyValue;\n }\n async echo(options: { value: string }): Promise<{ value: string }> {\n console.log('ECHO', options);\n return options;\n }\n async openVideoCallWindow(options: Object): Promise<{ value: any }>{\n let dummyValue:any;\n console.log('openVideoCallWindow', options);\n return dummyValue;\n }\n async setPatientOnlineStatus(options: Object): Promise<{ value: any }>{\n let dummyValue:any;\n console.log('setPatientOnlineStatus', options);\n return dummyValue;\n }\n}\n"]}
@@ -22,6 +22,11 @@ class vonageWeb extends core.WebPlugin {
22
22
  console.log('openVideoCallWindow', options);
23
23
  return dummyValue;
24
24
  }
25
+ async setPatientOnlineStatus(options) {
26
+ let dummyValue;
27
+ console.log('setPatientOnlineStatus', options);
28
+ return dummyValue;
29
+ }
25
30
  }
26
31
 
27
32
  var web = /*#__PURE__*/Object.freeze({
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst vonage = registerPlugin('vonage', {\n web: () => import('./web').then(m => new m.vonageWeb()),\n});\nexport * from './definitions';\nexport { vonage };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class vonageWeb extends WebPlugin {\n endVideoCall() {\n let dummyValue;\n return dummyValue;\n }\n async echo(options) {\n console.log('ECHO', options);\n return options;\n }\n async openVideoCallWindow(options) {\n let dummyValue;\n console.log('openVideoCallWindow', options);\n return dummyValue;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;;;AACK,MAAC,MAAM,GAAGA,mBAAc,CAAC,QAAQ,EAAE;AACxC,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;AAC3D,CAAC;;ACFM,MAAM,SAAS,SAASC,cAAS,CAAC;AACzC,IAAI,YAAY,GAAG;AACnB,QAAQ,IAAI,UAAU,CAAC;AACvB,QAAQ,OAAO,UAAU,CAAC;AAC1B,KAAK;AACL,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;AACxB,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACrC,QAAQ,OAAO,OAAO,CAAC;AACvB,KAAK;AACL,IAAI,MAAM,mBAAmB,CAAC,OAAO,EAAE;AACvC,QAAQ,IAAI,UAAU,CAAC;AACvB,QAAQ,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,OAAO,CAAC,CAAC;AACpD,QAAQ,OAAO,UAAU,CAAC;AAC1B,KAAK;AACL;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst vonage = registerPlugin('vonage', {\n web: () => import('./web').then(m => new m.vonageWeb()),\n});\nexport * from './definitions';\nexport { vonage };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class vonageWeb extends WebPlugin {\n endVideoCall() {\n let dummyValue;\n return dummyValue;\n }\n async echo(options) {\n console.log('ECHO', options);\n return options;\n }\n async openVideoCallWindow(options) {\n let dummyValue;\n console.log('openVideoCallWindow', options);\n return dummyValue;\n }\n async setPatientOnlineStatus(options) {\n let dummyValue;\n console.log('setPatientOnlineStatus', options);\n return dummyValue;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;;;AACK,MAAC,MAAM,GAAGA,mBAAc,CAAC,QAAQ,EAAE;AACxC,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;AAC3D,CAAC;;ACFM,MAAM,SAAS,SAASC,cAAS,CAAC;AACzC,IAAI,YAAY,GAAG;AACnB,QAAQ,IAAI,UAAU,CAAC;AACvB,QAAQ,OAAO,UAAU,CAAC;AAC1B,KAAK;AACL,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;AACxB,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACrC,QAAQ,OAAO,OAAO,CAAC;AACvB,KAAK;AACL,IAAI,MAAM,mBAAmB,CAAC,OAAO,EAAE;AACvC,QAAQ,IAAI,UAAU,CAAC;AACvB,QAAQ,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,OAAO,CAAC,CAAC;AACpD,QAAQ,OAAO,UAAU,CAAC;AAC1B,KAAK;AACL,IAAI,MAAM,sBAAsB,CAAC,OAAO,EAAE;AAC1C,QAAQ,IAAI,UAAU,CAAC;AACvB,QAAQ,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAAE,OAAO,CAAC,CAAC;AACvD,QAAQ,OAAO,UAAU,CAAC;AAC1B,KAAK;AACL;;;;;;;;;"}
package/dist/plugin.js CHANGED
@@ -19,6 +19,11 @@ var capacitorvonage = (function (exports, core) {
19
19
  console.log('openVideoCallWindow', options);
20
20
  return dummyValue;
21
21
  }
22
+ async setPatientOnlineStatus(options) {
23
+ let dummyValue;
24
+ console.log('setPatientOnlineStatus', options);
25
+ return dummyValue;
26
+ }
22
27
  }
23
28
 
24
29
  var web = /*#__PURE__*/Object.freeze({
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst vonage = registerPlugin('vonage', {\n web: () => import('./web').then(m => new m.vonageWeb()),\n});\nexport * from './definitions';\nexport { vonage };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class vonageWeb extends WebPlugin {\n endVideoCall() {\n let dummyValue;\n return dummyValue;\n }\n async echo(options) {\n console.log('ECHO', options);\n return options;\n }\n async openVideoCallWindow(options) {\n let dummyValue;\n console.log('openVideoCallWindow', options);\n return dummyValue;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,MAAM,GAAGA,mBAAc,CAAC,QAAQ,EAAE;IACxC,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;IAC3D,CAAC;;ICFM,MAAM,SAAS,SAASC,cAAS,CAAC;IACzC,IAAI,YAAY,GAAG;IACnB,QAAQ,IAAI,UAAU,CAAC;IACvB,QAAQ,OAAO,UAAU,CAAC;IAC1B,KAAK;IACL,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;IACxB,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,QAAQ,OAAO,OAAO,CAAC;IACvB,KAAK;IACL,IAAI,MAAM,mBAAmB,CAAC,OAAO,EAAE;IACvC,QAAQ,IAAI,UAAU,CAAC;IACvB,QAAQ,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,OAAO,CAAC,CAAC;IACpD,QAAQ,OAAO,UAAU,CAAC;IAC1B,KAAK;IACL;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst vonage = registerPlugin('vonage', {\n web: () => import('./web').then(m => new m.vonageWeb()),\n});\nexport * from './definitions';\nexport { vonage };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class vonageWeb extends WebPlugin {\n endVideoCall() {\n let dummyValue;\n return dummyValue;\n }\n async echo(options) {\n console.log('ECHO', options);\n return options;\n }\n async openVideoCallWindow(options) {\n let dummyValue;\n console.log('openVideoCallWindow', options);\n return dummyValue;\n }\n async setPatientOnlineStatus(options) {\n let dummyValue;\n console.log('setPatientOnlineStatus', options);\n return dummyValue;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,MAAM,GAAGA,mBAAc,CAAC,QAAQ,EAAE;IACxC,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;IAC3D,CAAC;;ICFM,MAAM,SAAS,SAASC,cAAS,CAAC;IACzC,IAAI,YAAY,GAAG;IACnB,QAAQ,IAAI,UAAU,CAAC;IACvB,QAAQ,OAAO,UAAU,CAAC;IAC1B,KAAK;IACL,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;IACxB,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,QAAQ,OAAO,OAAO,CAAC;IACvB,KAAK;IACL,IAAI,MAAM,mBAAmB,CAAC,OAAO,EAAE;IACvC,QAAQ,IAAI,UAAU,CAAC;IACvB,QAAQ,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,OAAO,CAAC,CAAC;IACpD,QAAQ,OAAO,UAAU,CAAC;IAC1B,KAAK;IACL,IAAI,MAAM,sBAAsB,CAAC,OAAO,EAAE;IAC1C,QAAQ,IAAI,UAAU,CAAC;IACvB,QAAQ,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAAE,OAAO,CAAC,CAAC;IACvD,QAAQ,OAAO,UAAU,CAAC;IAC1B,KAAK;IACL;;;;;;;;;;;;;;;;;"}
@@ -22,21 +22,29 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
22
22
  var isVideoMute = false
23
23
  var isBackCameraFace = false
24
24
  var isCallInProgress = false
25
-
25
+ var isPatientOnLine = true
26
+ var isPatientFromWeb = true
26
27
  var videoCallParam = String()
27
-
28
+ var profilePicApiUrl = ""
28
29
  var session: OTSession?
29
30
  var publisher: OTPublisher?
30
31
  var subscriber: OTSubscriber?
31
32
 
33
+ var bottomView = UIView()
32
34
  var remoteView = UIView()
33
35
  var localView = UIView()
36
+ var centerView = UIView()
37
+ var adminBtn = UIButton()
38
+ var denyBtn = UIButton()
39
+ var sendNotificationBtn = UIButton()
34
40
  var camaraBtn = UIButton()
35
41
  var videoBtn = UIButton()
36
42
  var audioBtn = UIButton()
37
43
  var callBtn = UIButton()
44
+ var subscriberStatusLabel = UILabel()
38
45
  var publisherLabel = UILabel()
39
46
  var subscriberLabel = UILabel()
47
+ var subscriberNameLabel = UILabel()
40
48
  var timerLabel = UILabel()
41
49
  var subscriberImg = UIImageView()
42
50
  var counter = 0
@@ -45,6 +53,9 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
45
53
 
46
54
  super.viewDidLoad()
47
55
  self.navigationController?.navigationBar.isHidden = true
56
+ self.view.backgroundColor = .white
57
+ NotificationCenter.default.addObserver(self, selector: #selector(appMovedToBackground), name: UIApplication.willResignActiveNotification, object: nil)
58
+ NotificationCenter.default.addObserver(self, selector: #selector(appMovedToForeground), name: UIApplication.willEnterForegroundNotification, object: nil)
48
59
  self.viewSetupMethod()
49
60
  // let jsonParam = videoCallParam.toJSON() as? [String:AnyObject] // can be any type here
50
61
  // print(jsonParam as Any)
@@ -86,16 +97,53 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
86
97
  // })
87
98
  }
88
99
  override func viewDidAppear(_ animated: Bool) {
100
+ print("viewDidAppear")
89
101
  super.viewDidAppear(animated)
102
+ NotificationCenter.default.addObserver(self, selector: #selector(deviceOrientationDidChange), name: UIDevice.orientationDidChangeNotification, object: nil)
103
+ NotificationCenter.default.addObserver(self, selector: #selector(setPatientOnlineStatus), name: NSNotification.Name ("PatientOnlineStatus"), object: nil)
90
104
  NotificationCenter.default.addObserver(self,selector:#selector(endVideoCall(_:)),name: NSNotification.Name ("EndVideoCall"),object: nil)
91
105
  // DispatchQueue.main.asyncAfter(deadline: .now() + 1.0, execute: {
92
106
  //
93
107
  // self.connectToAnOpenTokSession()
94
108
  // })
109
+ // if(isVideoMute){
110
+ // subscriberImg.isHidden = true
111
+ // }else{
112
+ // subscriberImg.isHidden = false
113
+ // }
114
+ // turnOnAndOffVideo()
95
115
  }
96
116
  override func viewDidDisappear(_ animated: Bool) {
117
+ print("viewDidDisappear")
97
118
  super.viewDidDisappear(animated)
98
- NotificationCenter.default.removeObserver(self, name: NSNotification.Name("EndVideoCall"), object: nil)
119
+ let userInfo = ["userInfo": ["isProvider": self.isProvider]]
120
+ NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoEnded),object: nil,userInfo: userInfo)
121
+ // NotificationCenter.default.removeObserver(self, name: NSNotification.Name("EndVideoCall"), object: nil)
122
+ NotificationCenter.default.removeObserver(self)
123
+ }
124
+ @objc func appMovedToBackground() {
125
+ print("App moved to background!")
126
+ }
127
+ @objc func appMovedToForeground() {
128
+ print("App moved to forground!")
129
+ }
130
+ @objc func deviceOrientationDidChange(_ notification: Notification) {
131
+ let orientation = UIDevice.current.orientation
132
+ print(orientation)
133
+ // self.remoteView.setNeedsLayout()
134
+ // self.localView.setNeedsLayout()
135
+ // self.bottomView.setNeedsLayout()
136
+ }
137
+ @objc func setPatientOnlineStatus(_ notification: Notification) {
138
+ // let userinfo = notification.userInfo?["isOnline"] as? Bool
139
+
140
+ if let isOnline = notification.userInfo?["isOnline"] as? Bool , !isCallInProgress {
141
+ isPatientOnLine = isOnline
142
+ DispatchQueue.main.async {
143
+ self.patientStatusChanged()
144
+ }
145
+ }
146
+
99
147
  }
100
148
  @objc func endVideoCall(_ notification: Notification){
101
149
  print("end video call called")
@@ -134,12 +182,17 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
134
182
  let screenWidth = self.view.frame.width
135
183
 
136
184
  remoteView = UIView(frame: CGRect(x: 0, y: 0, width: screenWidth, height:screenHeight))
137
- remoteView.backgroundColor = UIColor(red: 83/255, green: 83/255, blue: 83/255, alpha: 1.0)
185
+ remoteView.backgroundColor = .white//UIColor(red: 83/255, green: 83/255, blue: 83/255, alpha: 1.0)
186
+ centerView.layer.zPosition = 1
187
+ centerView.frame = CGRect(x: 0, y: 0, width: 250, height: 400)
188
+ // centerView.backgroundColor = .blue
189
+ centerView.center.x = remoteView.center.x
190
+ centerView.center.y = remoteView.center.y - 20
138
191
 
139
192
  subscriberLabel = UILabel(frame: CGRect(x: 20, y: Int(screenHeight) - 180, width: Int(remoteView.frame.size.width - 180), height: 40))
140
193
  subscriberLabel.text = subscriberName
141
194
  //subscriberLabel.backgroundColor = UIColor(red: 31/255, green: 33/255, blue: 36/255, alpha: 1.0)
142
- subscriberLabel.textColor = .white
195
+ subscriberLabel.textColor = .white//UIColor(hex: "#000000")
143
196
  subscriberLabel.textAlignment = .left
144
197
  subscriberLabel.font = subscriberLabel.font.withSize(dynamicFontSize(15))
145
198
  subscriberLabel.layer.zPosition = 1;
@@ -147,12 +200,13 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
147
200
  timerLabel = UILabel(frame: CGRect(x: 30, y: Int(screenHeight) - 155, width: Int(remoteView.frame.size.width - 140), height: 40))
148
201
  //timerLabel.text = "00:00:00"
149
202
  //subscriberLabel.backgroundColor = UIColor(red: 31/255, green: 33/255, blue: 36/255, alpha: 1.0)
150
- timerLabel.textColor = .white
203
+ timerLabel.textColor = .black//UIColor(hex: "#000000")
151
204
  timerLabel.textAlignment = .left
152
- timerLabel.font = subscriberLabel.font.withSize(dynamicFontSize(15))
205
+ timerLabel.font = timerLabel.font.withSize(dynamicFontSize(15))
153
206
  timerLabel.layer.zPosition = 1;
154
- let url = URL(string: "https://www.gravatar.com/avatar/?d=mp")!
155
-
207
+ let dummmyUrl = "https://www.gravatar.com/avatar/?d=mp"
208
+ let url = URL(string: profilePicApiUrl.count > 10 ? profilePicApiUrl : dummmyUrl)!
209
+
156
210
  DispatchQueue.global().async {
157
211
  // Fetch Image Data
158
212
  if let data = try? Data(contentsOf: url) {
@@ -162,19 +216,78 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
162
216
  }
163
217
  }
164
218
  }
165
- subscriberImg.layer.zPosition = 1
166
- subscriberImg.frame = CGRect(x: 0, y: 0, width: 200, height: 200)
167
- subscriberImg.layer.cornerRadius = 100
219
+ //subscriberImg.layer.zPosition = 1
220
+ subscriberImg.frame = CGRect(x: (centerView.frame.width / 2) - 90, y: 0, width: 180, height: 180)
221
+ subscriberImg.layer.cornerRadius = 90
168
222
  subscriberImg.clipsToBounds = true
169
- subscriberImg.center.x = remoteView.center.x
170
- subscriberImg.center.y = remoteView.center.y - 100
223
+ //subscriberImg.center = CGPoint(x: self.view.frame.size.width / 2, y: 0)
224
+ //subscriberImg.center.x = remoteView.center.x - 70
225
+ //subscriberImg.center.y = centerView.center.y - 100
226
+
227
+ subscriberStatusLabel = UILabel(frame: CGRect(x: (centerView.frame.width / 2) - 80, y: 230, width: 160, height: 30))
228
+ subscriberStatusLabel.text = "WAITING"
229
+ subscriberStatusLabel.backgroundColor = UIColor(hex: "#DFF6ED")
230
+ subscriberStatusLabel.textColor = UIColor(hex: "#000000")
231
+ subscriberStatusLabel.textAlignment = .center
232
+ //subscriberStatusLabel.center.x = remoteView.center.x
233
+
234
+ subscriberNameLabel = UILabel(frame: CGRect(x: 0, y: 190, width: centerView.frame.width, height: 40))
235
+ subscriberNameLabel.text = subscriberName
236
+ subscriberNameLabel.backgroundColor = .clear
237
+ subscriberNameLabel.textColor = UIColor(hex: "#000000")
238
+ subscriberNameLabel.textAlignment = .center
239
+ subscriberNameLabel.font = UIFont.boldSystemFont(ofSize: dynamicFontSize(20))
240
+
241
+ adminBtn = UIButton(frame: CGRect(x: (centerView.frame.width/2) - 10 - 100, y: 275, width: 100, height: 50))
242
+ adminBtn.backgroundColor = UIColor(hex: "#DFF6ED")
243
+ adminBtn.layer.borderColor = UIColor(hex: "#60D2A7").cgColor
244
+ adminBtn.layer.borderWidth = 2
245
+ adminBtn.layer.cornerRadius = 10
246
+ adminBtn.setTitleColor(UIColor(hex: "#000000"), for: .normal)
247
+ adminBtn.setTitle("ADMIT", for: .normal)
248
+ adminBtn.titleLabel?.font = UIFont.boldSystemFont(ofSize: dynamicFontSize(15))
249
+ // adminBtn.setBackgroundImage(UIImage(named: "callEnd"), for: .normal)
250
+ adminBtn.addTarget(self, action:#selector(self.adminbuttonClicked), for: .touchUpInside)
251
+
252
+ sendNotificationBtn = UIButton(frame: CGRect(x: (centerView.frame.width/2) - 110, y: 275, width: 220, height: 50))
253
+ sendNotificationBtn.backgroundColor = UIColor(hex: "#DFF6ED")
254
+ sendNotificationBtn.layer.borderColor = UIColor(hex: "#60D2A7").cgColor
255
+ sendNotificationBtn.layer.borderWidth = 2
256
+ sendNotificationBtn.layer.cornerRadius = 10
257
+ sendNotificationBtn.setTitleColor(UIColor(hex: "#000000"), for: .normal)
258
+ sendNotificationBtn.setTitle(isPatientFromWeb ? "SEND EMAIL NOTIFICATION" : "SEND NOTIFICATION", for: .normal)
259
+ sendNotificationBtn.titleLabel?.font = UIFont.boldSystemFont(ofSize: dynamicFontSize(15))
260
+ // adminBtn.setBackgroundImage(UIImage(named: "callEnd"), for: .normal)
261
+ sendNotificationBtn.addTarget(self, action:#selector(self.sendNotificationbuttonClicked), for: .touchUpInside)
262
+
263
+ denyBtn = UIButton(frame: CGRect(x: (centerView.frame.width/2) + 10, y: 275, width: 100, height: 50))
264
+ denyBtn.backgroundColor = UIColor(hex: "#E4EAED")
265
+ denyBtn.layer.borderColor = UIColor(hex: "#C4CBCF").cgColor
266
+ denyBtn.layer.borderWidth = 2
267
+ denyBtn.layer.cornerRadius = 10
268
+ denyBtn.setTitleColor(UIColor(hex: "#000000"), for: .normal)
269
+ denyBtn.setTitle("DENY", for: .normal)
270
+ denyBtn.titleLabel?.font = UIFont.boldSystemFont(ofSize: dynamicFontSize(15))
271
+ // adminBtn.setBackgroundImage(UIImage(named: "callEnd"), for: .normal)
272
+ denyBtn.addTarget(self, action:#selector(self.denybuttonClicked), for: .touchUpInside)
273
+
274
+ centerView.addSubview(denyBtn)
275
+ centerView.addSubview(adminBtn)
276
+ centerView.addSubview(subscriberImg)
277
+ centerView.addSubview(subscriberStatusLabel)
278
+ centerView.addSubview(subscriberNameLabel)
279
+ centerView.addSubview(sendNotificationBtn)
280
+ //patientStatusChanged()
281
+ centerView.isHidden = true
282
+
171
283
  // subscriberImg = UIImageView(image: <#T##UIImage?#>)
172
- remoteView.addSubview(subscriberImg)
284
+ remoteView.addSubview(centerView)
173
285
  remoteView.addSubview(timerLabel)
174
286
  remoteView.addSubview(subscriberLabel)
287
+
175
288
  self.view.addSubview(remoteView)
176
289
  // someImageViewConstraints()
177
- let bottomView = UIView(frame: CGRect(x: 0, y: screenHeight - 90, width: 320, height: 90))
290
+ bottomView = UIView(frame: CGRect(x: 0, y: screenHeight - 90, width: 320, height: 90))
178
291
  bottomView.backgroundColor = UIColor.clear
179
292
  bottomView.center = CGPoint(x: self.view.frame.size.width / 2, y: self.view.frame.size.height - 50)
180
293
 
@@ -189,7 +302,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
189
302
  publisherLabel = UILabel(frame: CGRect(x: 0, y: Int(localView.frame.size.height - 40.0), width: Int(localView.frame.size.width), height: 40))
190
303
  publisherLabel.text = publisherName
191
304
  // publisherLabel.backgroundColor = UIColor(red: 31/255, green: 33/255, blue: 36/255, alpha: 1.0)
192
- publisherLabel.textColor = .white
305
+ publisherLabel.textColor = .white//UIColor(hex: "#000000")
193
306
  publisherLabel.textAlignment = .center
194
307
  publisherLabel.layer.zPosition = 1;
195
308
  publisherLabel.font = publisherLabel.font.withSize(dynamicFontSize(15))
@@ -220,6 +333,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
220
333
  audioBtn.addTarget(self, action:#selector(self.audioBtnbuttonClicked), for: .touchUpInside)
221
334
  bottomView.addSubview(audioBtn)
222
335
 
336
+
223
337
  }
224
338
  deinit{
225
339
  if(!isCallEnded){
@@ -228,6 +342,75 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
228
342
  }
229
343
 
230
344
  }
345
+ func patientStatusChanged(){
346
+ if(isProvider && isPatientOnLine){
347
+ centerView.isHidden = false
348
+ sendNotificationBtn.isHidden = true
349
+ adminBtn.isHidden = false
350
+ denyBtn.isHidden = false
351
+ subscriberStatusLabel.text = "WAITING"
352
+ subscriberStatusLabel.backgroundColor = UIColor(hex: "#DFF6ED")
353
+ subscriberNameLabel.isHidden = false
354
+ }else if(isProvider && !isPatientOnLine){
355
+ centerView.isHidden = false
356
+ sendNotificationBtn.isHidden = false
357
+ adminBtn.isHidden = true
358
+ denyBtn.isHidden = true
359
+ subscriberStatusLabel.text = "OFFLINE"
360
+ subscriberStatusLabel.backgroundColor = UIColor(hex: "#ffd6ca")
361
+ subscriberNameLabel.isHidden = false
362
+ }else{
363
+ centerView.isHidden = false
364
+ sendNotificationBtn.isHidden = true
365
+ adminBtn.isHidden = true
366
+ denyBtn.isHidden = true
367
+ subscriberStatusLabel.isHidden = true
368
+ subscriberNameLabel.isHidden = false
369
+
370
+ }
371
+ }
372
+ @objc func sendNotificationbuttonClicked() {
373
+ print("sendNotificationbuttonClicked")
374
+ centerView.isHidden = false
375
+ sendNotificationBtn.isHidden = true
376
+ adminBtn.isHidden = true
377
+ denyBtn.isHidden = true
378
+ subscriberStatusLabel.isHidden = false
379
+ subscriberNameLabel.isHidden = false
380
+ subscriberStatusLabel.text = "Please Wait.."
381
+ let userInfo = ["userInfo": ["isProvider": isProvider]]
382
+ NotificationCenter.default.post(name: NSNotification.Name("SendNotification"),object: nil,userInfo: userInfo)
383
+ // self.session?.disconnect(nil)
384
+ // self.stopTimer()
385
+ // self.dismiss(animated: true, completion: nil)
386
+ }
387
+ @objc func adminbuttonClicked() {
388
+ print("Admin button clicked")
389
+ centerView.isHidden = false
390
+ sendNotificationBtn.isHidden = true
391
+ adminBtn.isHidden = true
392
+ denyBtn.isHidden = true
393
+ subscriberStatusLabel.isHidden = false
394
+ subscriberNameLabel.isHidden = false
395
+ subscriberStatusLabel.text = "Please Wait.."
396
+ //subscriberStatusLabel.frame.width =
397
+ // let userInfo = ["userInfo": ["isProvider": isProvider]]
398
+ // NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoEnded),object: nil,userInfo: userInfo)
399
+ // self.session?.disconnect(nil)
400
+ // self.stopTimer()
401
+ // self.dismiss(animated: true, completion: nil)
402
+ let userInfo = ["userInfo": ["isProvider": isProvider]]
403
+ NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoStarted),object: nil,userInfo: userInfo)
404
+ }
405
+ @objc func denybuttonClicked() {
406
+ print("deny button clicked")
407
+ centerView.isHidden = true
408
+ let userInfo = ["userInfo": ["isProvider": isProvider]]
409
+ NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoEnded),object: nil,userInfo: userInfo)
410
+ self.session?.disconnect(nil)
411
+ self.stopTimer()
412
+ self.dismiss(animated: true, completion: nil)
413
+ }
231
414
 
232
415
  @objc func callBtnbuttonClicked() {
233
416
 
@@ -252,6 +435,9 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
252
435
  }
253
436
 
254
437
  @objc func videoBtnbuttonClicked() {
438
+ turnOnAndOffVideo()
439
+ }
440
+ func turnOnAndOffVideo(){
255
441
  if (self.isVideoMute) {
256
442
  self.publisher?.publishVideo = true
257
443
  self.videoBtn.setImage(UIImage(named : "cameraOnWhite"), for: .normal)
@@ -290,10 +476,13 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
290
476
  func sessionDidConnect(_ session: OTSession) {
291
477
  print("The client connected to the OpenTok session.")
292
478
  let userInfo = ["userInfo": ["isProvider": isProvider]]
293
- NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoStarted),object: nil,userInfo: userInfo)
479
+ // NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoStarted),object: nil,userInfo: userInfo)
294
480
  let settings = OTPublisherSettings()
481
+ settings.cameraResolution = .high
482
+ settings.cameraFrameRate = .rate30FPS
295
483
  settings.name = publisherName
296
484
  guard let publisher = OTPublisher(delegate: self, settings: settings) else {
485
+ print("publisher create error")
297
486
  return
298
487
  }
299
488
  self.publisher = publisher
@@ -305,6 +494,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
305
494
  }
306
495
 
307
496
  guard let publisherView = publisher.view else {
497
+ print("publisher view not created")
308
498
  return
309
499
  }
310
500
 
@@ -314,11 +504,19 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
314
504
 
315
505
  localView.addSubview(publisherView)
316
506
  startTimer()
507
+ DispatchQueue.main.async {
508
+ self.patientStatusChanged()
509
+ }
510
+
317
511
  }
318
512
 
319
513
  func sessionDidDisconnect(_ session: OTSession) {
320
514
  print("The client disconnected from the OpenTok session.")
321
515
  // self.session?.disconnect(nil)
516
+ if(!isCallEnded){
517
+ let userInfo = ["userInfo": ["isProvider": self.isProvider]]
518
+ NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoEnded),object: nil,userInfo: userInfo)
519
+ }
322
520
  self.dismiss(animated: true, completion: nil)
323
521
  }
324
522
 
@@ -341,10 +539,14 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
341
539
  }
342
540
 
343
541
  guard let subscriberView = subscriber.view else {
542
+ print("subscriberView empty")
344
543
  return
345
544
  }
346
545
 
347
546
  subscriberView.frame = UIScreen.main.bounds
547
+ if(stream.videoType == .screen){
548
+ subscriberView.accessibilityValue = "from screen"
549
+ }
348
550
  remoteView.addSubview(subscriberView)
349
551
  }
350
552
 
@@ -356,16 +558,27 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
356
558
  // self.session?.disconnect(nil)
357
559
  // self.dismiss(animated: true, completion: nil)
358
560
  // }
359
- if let subStream = subscriber?.stream, subStream.streamId == stream.streamId,!isProvider {
561
+ if let subStream = subscriber?.stream, subStream.streamId == stream.streamId,!isProvider, stream.videoType != .screen {
360
562
  // cleanupSubscriber()
361
563
  let userInfo = ["userInfo": ["isProvider": isProvider]]
362
564
  NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoEnded),object: nil,userInfo: userInfo)
363
565
  self.session?.disconnect(nil)
364
566
  self.dismiss(animated: true, completion: nil)
365
567
  }
366
- subscriberImg.isHidden = false
367
- showToast(message: "\(subscriberName) is left the call")
368
- cleanupSubscriber()
568
+ if(stream.videoType != .screen){
569
+ subscriberImg.isHidden = false
570
+ subscriberNameLabel.isHidden = false
571
+ showToast(message: "\(subscriberName) is left the call")
572
+ cleanupSubscriber()
573
+ }
574
+ if(stream.videoType == .screen){
575
+ for subview in remoteView.subviews{
576
+ if(subview.accessibilityValue == "from screen"){
577
+ subview.removeFromSuperview()
578
+ }
579
+ }
580
+ }
581
+
369
582
 
370
583
  }
371
584
 
@@ -387,7 +600,14 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
387
600
  public func subscriberDidConnect(toStream subscriber: OTSubscriberKit) {
388
601
  print("The subscriber did connect to the stream.")
389
602
  subscriberImg.isHidden = true
390
- showToast(message: "\(subscriberName) is joined the call")
603
+ subscriberStatusLabel.isHidden = true
604
+ subscriberNameLabel.isHidden = true
605
+ timerLabel.textColor = .white
606
+ isCallInProgress = true
607
+ if(subscriber.stream?.videoType != .screen){
608
+ showToast(message: "\(subscriberName) is joined the call")
609
+ }
610
+
391
611
  }
392
612
 
393
613
  public func subscriber(_ subscriber: OTSubscriberKit, didFailWithError error: OTError) {
@@ -397,13 +617,20 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
397
617
 
398
618
  func subscriberVideoDisabled(_ subscriber: OTSubscriberKit, reason: OTSubscriberVideoEventReason) {
399
619
  // Display the video disabled indicator
620
+ print("subscriberVideoDisabled")
400
621
  showToast(message: "\(subscriberName) video disabled")
401
622
  subscriberImg.isHidden = false
623
+ subscriberNameLabel.isHidden = false
624
+ remoteView.backgroundColor = .white
402
625
  }
403
626
 
404
627
  func subscriberVideoEnabled(_ subscriber: OTSubscriberKit, reason: OTSubscriberVideoEventReason) {
628
+ print("subscriberVideoEnabled")
405
629
  showToast(message: "\(subscriberName) video enabled")
406
630
  subscriberImg.isHidden = true
631
+ subscriberStatusLabel.isHidden = true
632
+ subscriberNameLabel.isHidden = true
633
+ timerLabel.textColor = .white
407
634
  // showToast(message: "is provider \(isProvider) video enabled")
408
635
 
409
636
  // Remove the video disabled indicator
@@ -429,6 +656,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
429
656
  fileprivate func cleanupSubscriber() {
430
657
  subscriber?.view?.removeFromSuperview()
431
658
  subscriber = nil
659
+ remoteView.backgroundColor = .white
432
660
  }
433
661
 
434
662
  fileprivate func cleanupPublisher() {
@@ -441,6 +669,50 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
441
669
  subscriberImg.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
442
670
  subscriberImg.centerYAnchor.constraint(equalTo: view.centerYAnchor, constant: 28).isActive = true
443
671
  }
672
+ // override func viewDidLayoutSubviews() {
673
+ // super.viewDidLayoutSubviews()
674
+ // let screenHeight = self.view.bounds.height
675
+ // let screenWidth = self.view.bounds.width
676
+ //
677
+ // remoteView.frame = CGRect(x: 0, y: 0, width: self.view.bounds.width, height:self.view.bounds.height)
678
+ // subscriberLabel.frame = CGRect(x: 20, y: Int(screenHeight) - 180, width: Int(remoteView.frame.size.width - 180), height: 40)
679
+ // subscriberLabel.layer.zPosition = 1;
680
+ //
681
+ // timerLabel.frame = CGRect(x: 30, y: Int(screenHeight) - 155, width: Int(remoteView.frame.size.width - 140), height: 40)
682
+ // timerLabel.layer.zPosition = 1;
683
+ //
684
+ // subscriberImg.layer.zPosition = 1
685
+ // subscriberImg.frame = CGRect(x: 0, y: 0, width: 200, height: 200)
686
+ // subscriberImg.layer.cornerRadius = 100
687
+ // subscriberImg.clipsToBounds = true
688
+ // subscriberImg.center.x = centerView.center.x
689
+ // //subscriberImg.center.y = centerView.center.y - 100
690
+ //
691
+ // bottomView.frame = CGRect(x: 0, y: screenHeight - 90, width: 320, height: 90)
692
+ // bottomView.center = CGPoint(x: self.view.frame.size.width / 2, y: self.view.frame.size.height - 50)
693
+ //
694
+ // localView.frame = CGRect(x: screenWidth - 140, y: screenHeight - 250, width: 120, height: 120)
695
+ //
696
+ // localView.layer.cornerRadius = 10;
697
+ // localView.clipsToBounds = true
698
+ //
699
+ // publisherLabel.frame = CGRect(x: 0, y: Int(localView.frame.size.height - 40.0), width: Int(localView.frame.size.width), height: 40)
700
+ //
701
+ // publisherLabel.layer.zPosition = 1;
702
+ //
703
+ //
704
+ // callBtn.frame = CGRect(x: 0, y: 0, width: 60, height: 60)
705
+ //
706
+ //
707
+ // camaraBtn.frame = CGRect(x: 80, y: 0, width: 60, height: 60)
708
+ //
709
+ //
710
+ // videoBtn.frame = CGRect(x: 160, y: 0, width: 60, height: 60)
711
+ //
712
+ //
713
+ // audioBtn.frame = CGRect(x: 240, y: 0, width: 60, height: 60)
714
+ // }
715
+
444
716
  }
445
717
 
446
718
  extension String {
@@ -453,10 +725,10 @@ extension UIViewController {
453
725
 
454
726
  func showToast(message : String) {
455
727
  DispatchQueue.main.async {
456
- let toastLabel = UILabel(frame: CGRect(x: 0, y: self.view.frame.size.height-300, width: self.view.frame.size.width - 100, height: 50))
457
- toastLabel.center.x = self.view.center.x
458
- toastLabel.backgroundColor = UIColor.white.withAlphaComponent(0.6)
459
- toastLabel.textColor = UIColor.black
728
+ let toastLabel = UILabel(frame: CGRect(x: 100, y: 40, width: self.view.frame.size.width - 100, height: 50))
729
+ // toastLabel.center.x = self.view.center.x
730
+ toastLabel.backgroundColor = UIColor(hex: "#0B6623")//UIColor.white.withAlphaComponent(0.6)
731
+ toastLabel.textColor = .white//UIColor.black
460
732
  toastLabel.font = .systemFont(ofSize: 12.0)
461
733
  toastLabel.textAlignment = .center;
462
734
  toastLabel.text = message
@@ -473,3 +745,21 @@ func showToast(message : String) {
473
745
  }
474
746
 
475
747
  }
748
+ extension UIColor {
749
+ convenience init(hex: String, alpha: CGFloat = 1.0) {
750
+ var hexValue = hex.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines).uppercased()
751
+
752
+ if hexValue.hasPrefix("#") {
753
+ hexValue.remove(at: hexValue.startIndex)
754
+ }
755
+
756
+ var rgbValue: UInt64 = 0
757
+ Scanner(string: hexValue).scanHexInt64(&rgbValue)
758
+
759
+ let red = CGFloat((rgbValue & 0xFF0000) >> 16) / 255.0
760
+ let green = CGFloat((rgbValue & 0x00FF00) >> 8) / 255.0
761
+ let blue = CGFloat(rgbValue & 0x0000FF) / 255.0
762
+
763
+ self.init(red: red, green: green, blue: blue, alpha: alpha)
764
+ }
765
+ }
@@ -7,4 +7,5 @@ CAP_PLUGIN(vonagePlugin, "vonage",
7
7
  CAP_PLUGIN_METHOD(echo, CAPPluginReturnPromise);
8
8
  CAP_PLUGIN_METHOD(openVideoCallWindow, CAPPluginReturnPromise);
9
9
  CAP_PLUGIN_METHOD(endVideoCall, CAPPluginReturnPromise);
10
+ CAP_PLUGIN_METHOD(setPatientOnlineStatus, CAPPluginReturnPromise);
10
11
  )
@@ -15,8 +15,9 @@ public class vonagePlugin: CAPPlugin {
15
15
 
16
16
  let publisherName = call.getString("publisherName") ?? ""
17
17
  let subscriberName = call.getString("subscriberName") ?? ""
18
- let isProvider = call.getBool("isProvider") ?? false
19
-
18
+ let isProvider = call.getBool("isProvider") ?? false //profilePicApiUrl
19
+ let isPatientOnline = call.getBool("isPatientOnline") ?? false
20
+ let profilePhoto = call.getString("profilePhoto") ?? ""
20
21
  DispatchQueue.main.async {
21
22
  let vc = VideoChatViewController()
22
23
  vc.kApiKey = apiKey
@@ -25,12 +26,15 @@ public class vonagePlugin: CAPPlugin {
25
26
  vc.publisherName = publisherName
26
27
  vc.subscriberName = subscriberName
27
28
  vc.isProvider = isProvider
29
+ vc.isPatientOnLine = isPatientOnline
30
+ vc.profilePicApiUrl = profilePhoto
28
31
  // vc.videoCallParam = value
29
32
  vc.modalPresentationStyle = .fullScreen
30
33
  self.bridge?.viewController?.present(vc, animated: true, completion: nil)
31
34
  }
32
35
  NotificationCenter.default.addObserver(self,selector:#selector(videoEnded(_:)),name: NSNotification.Name (NotificationNames.videoEnded),object: nil)
33
36
  NotificationCenter.default.addObserver(self,selector:#selector(videoStarted(_:)),name: NSNotification.Name (NotificationNames.videoStarted),object: nil)
37
+ NotificationCenter.default.addObserver(self,selector:#selector(videoStarted(_:)),name: NSNotification.Name ("SendNotification"),object: nil)
34
38
  // if let visibleViewCtrl = UIApplication.topViewController() {
35
39
  // // do whatever you want with your `visibleViewCtrl`
36
40
  // print(visibleViewCtrl)
@@ -46,6 +50,14 @@ public class vonagePlugin: CAPPlugin {
46
50
 
47
51
  call.resolve(["value": "Video call initiated"])
48
52
  }
53
+ @objc func setPatientOnlineStatus(_ call: CAPPluginCall) {
54
+
55
+ let isOnline = call.getBool("isOnline") ?? false
56
+
57
+ NotificationCenter.default.post(name: NSNotification.Name("PatientOnlineStatus"),object: nil,userInfo: ["isOnline":isOnline])
58
+
59
+ call.resolve(["value": "setPatientOnlineStatus"])
60
+ }
49
61
  @objc func endVideoCall(_ call: CAPPluginCall) {
50
62
  NotificationCenter.default.post(name: NSNotification.Name("EndVideoCall"),object: nil,userInfo: nil)
51
63
  call.resolve(["value": "Video call ended."])
@@ -58,6 +70,10 @@ public class vonagePlugin: CAPPlugin {
58
70
  self.notifyListeners(NotificationNames.videoStarted, data: notification.userInfo?["userInfo"] as? [String: Any] ?? [:])
59
71
  NotificationCenter.default.removeObserver(self, name: NSNotification.Name(NotificationNames.videoStarted), object: nil)
60
72
  }
73
+ @objc func sendNotification(_ notification: Notification){
74
+ self.notifyListeners("SendNotification", data: notification.userInfo?["userInfo"] as? [String: Any] ?? [:])
75
+ NotificationCenter.default.removeObserver(self, name: NSNotification.Name("SendNotification"), object: nil)
76
+ }
61
77
  }
62
78
  extension UIApplication {
63
79
  class func topViewController(base: UIViewController? = UIApplication.shared.keyWindow?.rootViewController) -> UIViewController? {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capacitor-plugin-vonage",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "opentok sdk capacitor plugin",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",