capacitor-plugin-vonage 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/README.md +12 -0
  2. package/android/build.gradle +1 -2
  3. package/android/src/main/AndroidManifest.xml +0 -0
  4. package/android/src/main/java/com/managemyhealth/plugin/vonage/VideoCallActivity.java +38 -4
  5. package/android/src/main/java/com/managemyhealth/plugin/vonage/vonage.java +0 -0
  6. package/android/src/main/java/com/managemyhealth/plugin/vonage/vonagePlugin.java +41 -7
  7. package/android/src/main/res/.gitkeep +0 -0
  8. package/android/src/main/res/drawable/callend.png +0 -0
  9. package/android/src/main/res/drawable/callstart.png +0 -0
  10. package/android/src/main/res/drawable/cameraoff.png +0 -0
  11. package/android/src/main/res/drawable/cameraonwhite.png +0 -0
  12. package/android/src/main/res/drawable/cameraswitch.png +0 -0
  13. package/android/src/main/res/drawable/ic_launcher_background.xml +0 -0
  14. package/android/src/main/res/drawable/microphoneoff.png +0 -0
  15. package/android/src/main/res/drawable/microphoneonwhite.png +0 -0
  16. package/android/src/main/res/layout/activity_main.xml +0 -0
  17. package/android/src/main/res/layout/video_call_layout.xml +5 -3
  18. package/android/src/main/res.zip +0 -0
  19. package/dist/docs.json +10 -0
  20. package/dist/esm/definitions.d.ts +3 -0
  21. package/dist/esm/definitions.js.map +1 -1
  22. package/dist/esm/web.d.ts +3 -0
  23. package/dist/esm/web.js +4 -0
  24. package/dist/esm/web.js.map +1 -1
  25. package/dist/plugin.cjs.js +4 -0
  26. package/dist/plugin.cjs.js.map +1 -1
  27. package/dist/plugin.js +4 -0
  28. package/dist/plugin.js.map +1 -1
  29. package/ios/Plugin/VideoChatViewController.swift +98 -10
  30. package/ios/Plugin/vonagePlugin.m +1 -0
  31. package/ios/Plugin/vonagePlugin.swift +4 -0
  32. package/package.json +1 -1
package/README.md CHANGED
@@ -15,6 +15,7 @@ npx cap sync
15
15
 
16
16
  * [`echo(...)`](#echo)
17
17
  * [`openVideoCallWindow(...)`](#openvideocallwindow)
18
+ * [`endVideoCall()`](#endvideocall)
18
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
20
  * [Interfaces](#interfaces)
20
21
  * [Type Aliases](#type-aliases)
@@ -54,6 +55,17 @@ openVideoCallWindow(options: Object) => Promise<{ value: any; }>
54
55
  --------------------
55
56
 
56
57
 
58
+ ### endVideoCall()
59
+
60
+ ```typescript
61
+ endVideoCall() => Promise<{ value: string; }>
62
+ ```
63
+
64
+ **Returns:** <code>Promise&lt;{ value: string; }&gt;</code>
65
+
66
+ --------------------
67
+
68
+
57
69
  ### addListener([eventName: 'VideoCallEnded', listenerFunc: (info: any) => void] | [eventName: 'VideoCallStarted', listenerFunc: (info: any) => void], ...)
58
70
 
59
71
  ```typescript
@@ -51,7 +51,6 @@ repositories {
51
51
  dependencies {
52
52
  implementation 'com.google.android.material:material:1.4.0'
53
53
  implementation 'pub.devrel:easypermissions:3.0.0'
54
- implementation 'com.opentok.android:opentok-android-sdk:2.22.0'
55
54
  implementation fileTree(dir: 'libs', include: ['*.jar'])
56
55
  implementation project(':capacitor-android')
57
56
  implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
@@ -62,7 +61,7 @@ dependencies {
62
61
  implementation fileTree(dir: 'libs', include: ['*.jar'])
63
62
  implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
64
63
  implementation 'androidx.annotation:annotation:1.7.0'
65
- implementation 'com.opentok.android:opentok-android-sdk:2.22.2'
64
+ implementation 'com.opentok.android:opentok-android-sdk:2.26.2'
66
65
  androidTestImplementation 'androidx.test:runner:1.5.2'
67
66
  androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
68
67
 
File without changes
@@ -52,6 +52,7 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
52
52
  boolean isMuted = false;
53
53
  boolean isCamOff = false;
54
54
  boolean isTimeron = false;
55
+ boolean isEndall = false;
55
56
  private Subscriber subscriber;
56
57
  private FrameLayout publisherViewContainer;
57
58
  private FrameLayout subscriberViewContainer;
@@ -121,8 +122,14 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
121
122
  publisherViewContainer.removeAllViews();
122
123
  }
123
124
  Intent resultIntent = new Intent();
124
- String resultcode = ISPROVIDER?"999":"888";
125
- resultIntent.putExtra("result_key", resultcode); // Optional: Pass data back to the calling activity
125
+ String resultcode = "";
126
+
127
+ if(isEndall){
128
+ resultcode= "111";
129
+ }else{
130
+ resultcode = ISPROVIDER ? "999" : "888";
131
+ }
132
+ resultIntent.putExtra("result_key", resultcode);
126
133
  setResult(RESULT_OK, resultIntent);
127
134
  // setResult(RESULT_CANCELED); // Use this to indicate cancellation
128
135
 
@@ -160,10 +167,15 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
160
167
  subscriberViewContainer.removeAllViews();
161
168
  Intent resultIntent = new Intent();
162
169
  String resultcode = ISPROVIDER?"999":"888";
163
- resultIntent.putExtra("result_key", resultcode); // Optional: Pass data back to the calling activity
170
+ resultIntent.putExtra("result_key", resultcode);
164
171
  setResult(RESULT_OK, resultIntent);
165
172
  finish();
166
173
  }
174
+ }else{
175
+ if (subscriber != null) {
176
+ subscriber = null;
177
+ subscriberViewContainer.removeAllViews();
178
+ }
167
179
  }
168
180
  }
169
181
 
@@ -201,6 +213,12 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
201
213
  }
202
214
  }
203
215
 
216
+ @Override
217
+ public void onBackPressed() {
218
+ Log.d("onBack","Called===============");
219
+ session.disconnect();
220
+ }
221
+
204
222
  @Override
205
223
  protected void onCreate(Bundle savedInstanceState) {
206
224
 
@@ -315,6 +333,22 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
315
333
  if (session != null) {
316
334
  session.onResume();
317
335
  }
336
+ }
337
+ 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
+ });
350
+
351
+
318
352
  }
319
353
  private void startTimer() {
320
354
  // startTime = System.currentTimeMillis();
@@ -427,7 +461,7 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
427
461
  session.disconnect();
428
462
  Intent resultIntent = new Intent();
429
463
  String resultcode = ISPROVIDER?"999":"888";
430
- resultIntent.putExtra("result_key", resultcode); // Optional: Pass data back to the calling activity
464
+ resultIntent.putExtra("result_key", resultcode);
431
465
  setResult(RESULT_OK, resultIntent);
432
466
  this.finish();
433
467
  }
@@ -9,6 +9,7 @@ import com.opentok.android.Subscriber;
9
9
  import android.app.Activity;
10
10
  import android.content.Intent;
11
11
  import android.os.Handler;
12
+ import android.os.Looper;
12
13
  import android.util.Log;
13
14
 
14
15
  import com.getcapacitor.JSObject;
@@ -20,10 +21,33 @@ import com.getcapacitor.annotation.CapacitorPlugin;
20
21
 
21
22
  @CapacitorPlugin(name = "vonage",requestCodes = {999})
22
23
  public class vonagePlugin extends Plugin {
23
-
24
+ String Tag = "VONAGETAG";
25
+ Boolean isProvid=false;
24
26
  private Session session;
25
27
 
26
28
  private String TAG = "Capacitor_Vonage_plugin";
29
+
30
+ @PluginMethod()
31
+ public void endVideoCall(PluginCall call) {
32
+ showLog("endVideoCallPluginMethod");
33
+
34
+
35
+
36
+ Handler mainHandler = new Handler(Looper.getMainLooper());
37
+ Runnable myRunnable = new Runnable() {
38
+ @Override
39
+ public void run() {
40
+ try{
41
+ VideoCallActivity videoCallActivity = new VideoCallActivity();
42
+ videoCallActivity.endCall();
43
+ }catch (Exception e){
44
+ showLog(e.toString());
45
+ }
46
+ }
47
+ };
48
+ mainHandler.post(myRunnable);
49
+
50
+ }
27
51
  @PluginMethod()
28
52
  public void openVideoCallWindow(PluginCall call) {
29
53
 
@@ -35,6 +59,7 @@ public class vonagePlugin extends Plugin {
35
59
  final String PUBLISHERNAME = call.getString("publisherName");
36
60
  final String SUBSCRIBERNAME = call.getString("subscriberName");
37
61
  final Boolean ISPROVIDER = call.getBoolean("isProvider");
62
+ isProvid = ISPROVIDER;
38
63
  // initializeSession(API_KEY, SESSION_ID, TOKEN);
39
64
  Intent intent = new Intent(getContext(), VideoCallActivity.class);
40
65
  intent.putExtra("apiKey",API_KEY);
@@ -48,14 +73,14 @@ public class vonagePlugin extends Plugin {
48
73
  // notifyListeners("onDataReceived", );
49
74
  // StartedCall();
50
75
  Handler handler = new Handler();
51
- int delayMillis = 5000;
76
+ int delayMillis = 2000;
52
77
 
53
78
  handler.postDelayed(new Runnable() {
54
79
  @Override
55
80
  public void run() {
56
-
57
81
  eventData.put("isProvider", ISPROVIDER);
58
82
  notifyListeners("VideoCallStarted",eventData);
83
+ Log.d("VIDEOCALL","isProvider634");
59
84
  }
60
85
  }, delayMillis);
61
86
  startActivityForResult(call,intent,999);
@@ -73,12 +98,18 @@ public class vonagePlugin extends Plugin {
73
98
  Log.d(TAG, String.valueOf(resultCode));
74
99
  Log.d(TAG, String.valueOf(requestCode));
75
100
  Log.d(TAG, String.valueOf(data));
76
- String result = data.getStringExtra("result_key");
77
- if(result == "999"){
101
+ String result = "";
102
+ try{
103
+ result = data.getStringExtra("result_key");
104
+ showLog("result");
105
+ showLog(result);
106
+ }catch(Exception e){
107
+ showLog("ewererewrwerwe");
108
+ showLog(e.toString());
109
+ }
110
+ if(isProvid){
78
111
  eventData.put("isProvider", true);
79
112
  notifyListeners("VideoCallEnded",eventData);
80
-
81
-
82
113
  }else{
83
114
  eventData.put("isProvider", false);
84
115
  Log.d(TAG,"CODE 98 -----------" );
@@ -122,4 +153,7 @@ public class vonagePlugin extends Plugin {
122
153
  // session.setSessionListener(sessionListener);
123
154
  // session.connect(token);
124
155
  // }
156
+ private void showLog(String log){
157
+ Log.d(Tag,log);
158
+ }
125
159
  }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -37,7 +37,7 @@
37
37
  android:layout_height="match_parent" />
38
38
 
39
39
  <TextView
40
- android:id="@+id/subscriberName"
40
+ android:id="@+id/publisherName"
41
41
  android:layout_width="140dp"
42
42
  android:layout_height="157dp"
43
43
  android:layout_gravity="bottom|start"
@@ -68,16 +68,18 @@
68
68
  android:layout_marginRight="16dp"
69
69
  android:layout_marginBottom="80dp"
70
70
  android:background="#FFFFFF"
71
+ android:layout_below="@id/subscriberName"
72
+
71
73
  android:padding="2dp" >
74
+
72
75
  <TextView
73
- android:id="@+id/publisherName"
76
+ android:id="@+id/subscriberName"
74
77
  android:layout_width="wrap_content"
75
78
  android:layout_height="wrap_content"
76
79
  android:layout_gravity="bottom|start"
77
80
  android:textSize="12sp"
78
81
  android:text="Subscriber Name"
79
82
  android:paddingBottom="5dp"
80
- android:visibility="visible"
81
83
  android:textColor="@android:color/background_dark" />
82
84
  </FrameLayout>
83
85
 
File without changes
package/dist/docs.json CHANGED
@@ -39,6 +39,16 @@
39
39
  ],
40
40
  "slug": "openvideocallwindow"
41
41
  },
42
+ {
43
+ "name": "endVideoCall",
44
+ "signature": "() => Promise<{ value: string; }>",
45
+ "parameters": [],
46
+ "returns": "Promise<{ value: string; }>",
47
+ "tags": [],
48
+ "docs": "",
49
+ "complexTypes": [],
50
+ "slug": "endvideocall"
51
+ },
42
52
  {
43
53
  "name": "addListener",
44
54
  "signature": "(...args: [eventName: \"VideoCallEnded\", listenerFunc: (info: any) => void] | [eventName: \"VideoCallStarted\", listenerFunc: (info: any) => void]) => Promise<PluginListenerHandle> & PluginListenerHandle",
@@ -8,5 +8,8 @@ export interface vonagePlugin {
8
8
  openVideoCallWindow(options: Object): Promise<{
9
9
  value: any;
10
10
  }>;
11
+ endVideoCall(): Promise<{
12
+ value: string;
13
+ }>;
11
14
  addListener(...args: [eventName: 'VideoCallEnded', listenerFunc: (info: any) => void] | [eventName: 'VideoCallStarted', listenerFunc: (info: any) => void]): Promise<PluginListenerHandle> & PluginListenerHandle;
12
15
  }
@@ -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 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 addListener(...args: [eventName: 'VideoCallEnded', listenerFunc: (info: any) => void] | [eventName: 'VideoCallStarted', listenerFunc: (info: any) => void]): Promise<PluginListenerHandle> & PluginListenerHandle;\n\n}\n"]}
package/dist/esm/web.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  import { WebPlugin } from '@capacitor/core';
2
2
  import type { vonagePlugin } from './definitions';
3
3
  export declare class vonageWeb extends WebPlugin implements vonagePlugin {
4
+ endVideoCall(): Promise<{
5
+ value: string;
6
+ }>;
4
7
  echo(options: {
5
8
  value: string;
6
9
  }): Promise<{
package/dist/esm/web.js CHANGED
@@ -1,5 +1,9 @@
1
1
  import { WebPlugin } from '@capacitor/core';
2
2
  export class vonageWeb extends WebPlugin {
3
+ endVideoCall() {
4
+ let dummyValue;
5
+ return dummyValue;
6
+ }
3
7
  async echo(options) {
4
8
  console.log('ECHO', options);
5
9
  return options;
@@ -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,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 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;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"]}
@@ -9,6 +9,10 @@ const vonage = core.registerPlugin('vonage', {
9
9
  });
10
10
 
11
11
  class vonageWeb extends core.WebPlugin {
12
+ endVideoCall() {
13
+ let dummyValue;
14
+ return dummyValue;
15
+ }
12
16
  async echo(options) {
13
17
  console.log('ECHO', options);
14
18
  return options;
@@ -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 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,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}\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;;;;;;;;;"}
package/dist/plugin.js CHANGED
@@ -6,6 +6,10 @@ var capacitorvonage = (function (exports, core) {
6
6
  });
7
7
 
8
8
  class vonageWeb extends core.WebPlugin {
9
+ endVideoCall() {
10
+ let dummyValue;
11
+ return dummyValue;
12
+ }
9
13
  async echo(options) {
10
14
  console.log('ECHO', options);
11
15
  return options;
@@ -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 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,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}\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;;;;;;;;;;;;;;;;;"}
@@ -9,6 +9,7 @@ import UIKit
9
9
  import OpenTok
10
10
 
11
11
  class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDelegate,OTSubscriberDelegate {
12
+ var isCallEnded = false
12
13
  var kApiKey = ""
13
14
  var kSessionId = ""
14
15
  var kToken = ""
@@ -37,9 +38,11 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
37
38
  var publisherLabel = UILabel()
38
39
  var subscriberLabel = UILabel()
39
40
  var timerLabel = UILabel()
41
+ var subscriberImg = UIImageView()
40
42
  var counter = 0
41
43
  var timer = Timer()
42
44
  override func viewDidLoad() {
45
+
43
46
  super.viewDidLoad()
44
47
  self.navigationController?.navigationBar.isHidden = true
45
48
  self.viewSetupMethod()
@@ -84,11 +87,21 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
84
87
  }
85
88
  override func viewDidAppear(_ animated: Bool) {
86
89
  super.viewDidAppear(animated)
90
+ NotificationCenter.default.addObserver(self,selector:#selector(endVideoCall(_:)),name: NSNotification.Name ("EndVideoCall"),object: nil)
87
91
  // DispatchQueue.main.asyncAfter(deadline: .now() + 1.0, execute: {
88
92
  //
89
93
  // self.connectToAnOpenTokSession()
90
94
  // })
91
95
  }
96
+ override func viewDidDisappear(_ animated: Bool) {
97
+ super.viewDidDisappear(animated)
98
+ NotificationCenter.default.removeObserver(self, name: NSNotification.Name("EndVideoCall"), object: nil)
99
+ }
100
+ @objc func endVideoCall(_ notification: Notification){
101
+ print("end video call called")
102
+ endVonageCall()
103
+ NotificationCenter.default.removeObserver(self, name: NSNotification.Name("EndVideoCall"), object: nil)
104
+ }
92
105
  func startTimer(){
93
106
  timer.invalidate()
94
107
  timer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(timerAction), userInfo: nil, repeats: true)
@@ -123,7 +136,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
123
136
  remoteView = UIView(frame: CGRect(x: 0, y: 0, width: screenWidth, height:screenHeight))
124
137
  remoteView.backgroundColor = UIColor(red: 83/255, green: 83/255, blue: 83/255, alpha: 1.0)
125
138
 
126
- subscriberLabel = UILabel(frame: CGRect(x: 20, y: Int(screenHeight) - 180, width: Int(remoteView.frame.size.width - 140), height: 40))
139
+ subscriberLabel = UILabel(frame: CGRect(x: 20, y: Int(screenHeight) - 180, width: Int(remoteView.frame.size.width - 180), height: 40))
127
140
  subscriberLabel.text = subscriberName
128
141
  //subscriberLabel.backgroundColor = UIColor(red: 31/255, green: 33/255, blue: 36/255, alpha: 1.0)
129
142
  subscriberLabel.textColor = .white
@@ -138,11 +151,29 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
138
151
  timerLabel.textAlignment = .left
139
152
  timerLabel.font = subscriberLabel.font.withSize(dynamicFontSize(15))
140
153
  timerLabel.layer.zPosition = 1;
141
-
154
+ let url = URL(string: "https://www.gravatar.com/avatar/?d=mp")!
155
+
156
+ DispatchQueue.global().async {
157
+ // Fetch Image Data
158
+ if let data = try? Data(contentsOf: url) {
159
+ DispatchQueue.main.async {
160
+ // Create Image and Update Image View
161
+ self.subscriberImg.image = UIImage(data: data)
162
+ }
163
+ }
164
+ }
165
+ subscriberImg.layer.zPosition = 1
166
+ subscriberImg.frame = CGRect(x: 0, y: 0, width: 200, height: 200)
167
+ subscriberImg.layer.cornerRadius = 100
168
+ subscriberImg.clipsToBounds = true
169
+ subscriberImg.center.x = remoteView.center.x
170
+ subscriberImg.center.y = remoteView.center.y - 100
171
+ // subscriberImg = UIImageView(image: <#T##UIImage?#>)
172
+ remoteView.addSubview(subscriberImg)
142
173
  remoteView.addSubview(timerLabel)
143
174
  remoteView.addSubview(subscriberLabel)
144
175
  self.view.addSubview(remoteView)
145
-
176
+ // someImageViewConstraints()
146
177
  let bottomView = UIView(frame: CGRect(x: 0, y: screenHeight - 90, width: 320, height: 90))
147
178
  bottomView.backgroundColor = UIColor.clear
148
179
  bottomView.center = CGPoint(x: self.view.frame.size.width / 2, y: self.view.frame.size.height - 50)
@@ -189,6 +220,13 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
189
220
  audioBtn.addTarget(self, action:#selector(self.audioBtnbuttonClicked), for: .touchUpInside)
190
221
  bottomView.addSubview(audioBtn)
191
222
 
223
+ }
224
+ deinit{
225
+ if(!isCallEnded){
226
+ let userInfo = ["userInfo": ["isProvider": self.isProvider]]
227
+ NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoEnded),object: nil,userInfo: userInfo)
228
+ }
229
+
192
230
  }
193
231
 
194
232
  @objc func callBtnbuttonClicked() {
@@ -325,6 +363,9 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
325
363
  self.session?.disconnect(nil)
326
364
  self.dismiss(animated: true, completion: nil)
327
365
  }
366
+ subscriberImg.isHidden = false
367
+ showToast(message: "\(subscriberName) is left the call")
368
+ cleanupSubscriber()
328
369
 
329
370
  }
330
371
 
@@ -341,32 +382,49 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
341
382
  }
342
383
  }
343
384
 
385
+
344
386
  //Subscriber methods
345
387
  public func subscriberDidConnect(toStream subscriber: OTSubscriberKit) {
346
388
  print("The subscriber did connect to the stream.")
389
+ subscriberImg.isHidden = true
390
+ showToast(message: "\(subscriberName) is joined the call")
347
391
  }
348
392
 
349
393
  public func subscriber(_ subscriber: OTSubscriberKit, didFailWithError error: OTError) {
350
394
  print("The subscriber failed to connect to the stream.")
395
+ showToast(message: "\(subscriberName) failed to connect to the call")
351
396
  }
352
397
 
353
398
  func subscriberVideoDisabled(_ subscriber: OTSubscriberKit, reason: OTSubscriberVideoEventReason) {
354
399
  // Display the video disabled indicator
400
+ showToast(message: "\(subscriberName) video disabled")
401
+ subscriberImg.isHidden = false
355
402
  }
356
403
 
357
404
  func subscriberVideoEnabled(_ subscriber: OTSubscriberKit, reason: OTSubscriberVideoEventReason) {
405
+ showToast(message: "\(subscriberName) video enabled")
406
+ subscriberImg.isHidden = true
407
+ // showToast(message: "is provider \(isProvider) video enabled")
408
+
358
409
  // Remove the video disabled indicator
359
410
  }
360
411
 
361
412
  @IBAction func endCallAction(_ sender: Any) {
362
- //var error: OTError?
363
- let userInfo = ["userInfo": ["isProvider": isProvider]]
413
+ isCallEnded = true
414
+ let userInfo = ["userInfo": ["isProvider": self.isProvider]]
364
415
  NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoEnded),object: nil,userInfo: userInfo)
365
- cleanupSubscriber()
366
- cleanupPublisher()
367
- self.session?.disconnect(nil)
368
- self.stopTimer()
369
- // self.dismiss(animated: true, completion: nil)
416
+ endVonageCall()
417
+ }
418
+ fileprivate func endVonageCall(){
419
+ isCallEnded = true
420
+ DispatchQueue.main.async {
421
+
422
+ self.cleanupSubscriber()
423
+ self.cleanupPublisher()
424
+ self.session?.disconnect(nil)
425
+ self.stopTimer()
426
+ // self.dismiss(animated: true, completion: nil)
427
+ }
370
428
  }
371
429
  fileprivate func cleanupSubscriber() {
372
430
  subscriber?.view?.removeFromSuperview()
@@ -377,6 +435,12 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
377
435
  publisher?.view?.removeFromSuperview()
378
436
  publisher = nil
379
437
  }
438
+ func someImageViewConstraints() {
439
+ subscriberImg.widthAnchor.constraint(equalToConstant: 180).isActive = true
440
+ subscriberImg.heightAnchor.constraint(equalToConstant: 180).isActive = true
441
+ subscriberImg.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
442
+ subscriberImg.centerYAnchor.constraint(equalTo: view.centerYAnchor, constant: 28).isActive = true
443
+ }
380
444
  }
381
445
 
382
446
  extension String {
@@ -385,3 +449,27 @@ extension String {
385
449
  return try? JSONSerialization.jsonObject(with: data, options: .mutableContainers)
386
450
  }
387
451
  }
452
+ extension UIViewController {
453
+
454
+ func showToast(message : String) {
455
+ 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
460
+ toastLabel.font = .systemFont(ofSize: 12.0)
461
+ toastLabel.textAlignment = .center;
462
+ toastLabel.text = message
463
+ toastLabel.alpha = 1.0
464
+ toastLabel.layer.cornerRadius = 10;
465
+ toastLabel.clipsToBounds = true
466
+ self.view.addSubview(toastLabel)
467
+ UIView.animate(withDuration: 5.0, delay: 0.2, options: .curveEaseOut, animations: {
468
+ toastLabel.alpha = 0.0
469
+ }, completion: {(isCompleted) in
470
+ toastLabel.removeFromSuperview()
471
+ })
472
+ }
473
+ }
474
+
475
+ }
@@ -6,4 +6,5 @@
6
6
  CAP_PLUGIN(vonagePlugin, "vonage",
7
7
  CAP_PLUGIN_METHOD(echo, CAPPluginReturnPromise);
8
8
  CAP_PLUGIN_METHOD(openVideoCallWindow, CAPPluginReturnPromise);
9
+ CAP_PLUGIN_METHOD(endVideoCall, CAPPluginReturnPromise);
9
10
  )
@@ -46,6 +46,10 @@ public class vonagePlugin: CAPPlugin {
46
46
 
47
47
  call.resolve(["value": "Video call initiated"])
48
48
  }
49
+ @objc func endVideoCall(_ call: CAPPluginCall) {
50
+ NotificationCenter.default.post(name: NSNotification.Name("EndVideoCall"),object: nil,userInfo: nil)
51
+ call.resolve(["value": "Video call ended."])
52
+ }
49
53
  @objc func videoEnded(_ notification: Notification){
50
54
  self.notifyListeners(NotificationNames.videoEnded, data: notification.userInfo?["userInfo"] as? [String: Any] ?? [:])
51
55
  NotificationCenter.default.removeObserver(self, name: NSNotification.Name(NotificationNames.videoEnded), object: nil)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capacitor-plugin-vonage",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "opentok sdk capacitor plugin",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",