voip-callkit 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,6 +16,7 @@ buildscript {
16
16
  }
17
17
 
18
18
  apply plugin: 'com.android.library'
19
+ apply plugin: 'com.google.gms.google-services'
19
20
 
20
21
  android {
21
22
  compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 30
@@ -51,12 +52,16 @@ repositories {
51
52
  dependencies {
52
53
  implementation fileTree(dir: 'libs', include: ['*.jar'])
53
54
  implementation project(':capacitor-android')
55
+ implementation 'com.android.support:design:25.0.1'
54
56
  implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
55
- implementation "com.amitshekhar.android:android-networking:1.0.2"
57
+ implementation 'com.google.firebase:firebase-analytics:17.2.3'
58
+ implementation 'com.google.android.material:material:1.3.0-alpha02'
59
+ implementation "com.amitshekhar.android:android-networking:1.0.2"
56
60
  implementation 'com.twilio:video-android:7.1.0'
57
61
  implementation 'androidx.preference:preference:1.2.0'
58
62
  implementation 'com.google.android.material:material:1.6.1'
59
63
  implementation 'com.google.firebase:firebase-messaging:23.0.6'
64
+ implementation 'com.google.android.material:material:1.0.0'
60
65
  testImplementation "junit:junit:$junitVersion"
61
66
  androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
62
67
  androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
Binary file
@@ -1,6 +1,7 @@
1
1
  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
2
  package="com.test.callkit">
3
3
 
4
+ <uses-permission android:name="android.permission.BROADCAST_CLOSE_SYSTEM_DIALOGS" />
4
5
  <uses-permission android:name="android.permission.CALL_PHONE"/>
5
6
  <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
6
7
  <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
@@ -41,9 +42,19 @@
41
42
  android:enabled="true"
42
43
  android:stopWithTask="true"
43
44
  android:exported="true"></service>
44
- <receiver
45
- android:name="com.test.callkit.androidcall.VoipForegroundServiceActionReceiver">
46
- </receiver>
45
+ <receiver
46
+ android:name="com.test.callkit.androidcall.VoipForegroundServiceActionReceiver"
47
+ android:enabled="true"
48
+ android:exported="true"
49
+ android:label="RestartServiceWhenStopped"
50
+ android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
51
+ <intent-filter>
52
+ <action android:name="VoipForegroundServiceActionReceiver" />
53
+ </intent-filter>
54
+ </receiver>
55
+ <!-- <receiver-->
56
+ <!-- android:name="com.test.callkit.androidcall.VoipForegroundServiceActionReceiver">-->
57
+ <!-- </receiver>-->
47
58
  <service
48
59
  android:name="com.test.callkit.androidcall.VoipBackgroundService"
49
60
  android:enabled="true"
@@ -51,13 +62,21 @@
51
62
  android:stopWithTask="true">
52
63
 
53
64
  </service>
54
- <service
55
- android:name="com.test.callkit.MyFirebaseMessagingService"
56
- android:enabled="true"
65
+ <!-- <service-->
66
+ <!-- android:name="com.test.callkit.MyFirebaseMessagingService"-->
67
+ <!-- android:enabled="true"-->
68
+ <!-- android:exported="false">-->
69
+ <!-- <intent-filter>-->
70
+ <!-- <action android:name="com.google.firebase.MESSAGING_EVENT" />-->
71
+ <!-- </intent-filter>-->
72
+ <!-- </service>-->
73
+ <service
74
+ android:name=".MyFirebaseMessagingService"
75
+ android:stopWithTask="false"
57
76
  android:exported="false">
58
- <intent-filter>
59
- <action android:name="com.google.firebase.MESSAGING_EVENT" />
60
- </intent-filter>
61
- </service>
77
+ <intent-filter>
78
+ <action android:name="com.google.firebase.MESSAGING_EVENT" />
79
+ </intent-filter>
80
+ </service>
62
81
  </application>
63
82
  </manifest>
@@ -7,6 +7,7 @@ import com.getcapacitor.Plugin;
7
7
  import com.getcapacitor.PluginCall;
8
8
  import com.getcapacitor.PluginHandle;
9
9
  import com.getcapacitor.PluginMethod;
10
+ import com.getcapacitor.annotation.CapacitorPlugin;
10
11
  import com.google.firebase.messaging.FirebaseMessaging;
11
12
 
12
13
 
@@ -16,7 +17,7 @@ import android.widget.Toast;
16
17
 
17
18
  import androidx.annotation.NonNull;
18
19
  import androidx.annotation.RequiresApi;
19
-
20
+ @CapacitorPlugin(name = "CallKitVoip")
20
21
  public class CallKitVoipPlugin extends Plugin {
21
22
  public static Bridge staticBridge = null;
22
23
  public MyFirebaseMessagingService messagingService;
@@ -33,6 +34,7 @@ public class CallKitVoipPlugin extends Plugin {
33
34
 
34
35
  @PluginMethod
35
36
  public void register(PluginCall call) {
37
+ Log.d("Inside RegisterPlugin","<<<>>>");
36
38
  final String topicName = call.getString("userToken");
37
39
  Log.d("CallKitVoip","register");
38
40
 
@@ -55,6 +57,7 @@ public class CallKitVoipPlugin extends Plugin {
55
57
  call.reject("Cant subscribe to topic" + topicName);
56
58
  });
57
59
  call.resolve();
60
+
58
61
  }
59
62
  public void notifyEvent(String eventName, String username, String connectionId){
60
63
  Log.d("notifyEvent",eventName + " " + username + " " + connectionId);
@@ -3,7 +3,9 @@ package com.test.callkit;
3
3
 
4
4
  import android.annotation.SuppressLint;
5
5
  import android.app.ActivityManager;
6
+ import android.content.Context;
6
7
  import android.content.Intent;
8
+ import android.content.SharedPreferences;
7
9
  import android.os.Build;
8
10
  import android.util.Log;
9
11
 
@@ -36,6 +38,17 @@ public class MyFirebaseMessagingService extends FirebaseMessagingService {
36
38
  Log.d(TAG, "class instantiated");
37
39
  }
38
40
 
41
+ @Override
42
+ public void onNewToken(String token) {
43
+ super.onNewToken(token);
44
+ Log.e("newToken from FCM", token);
45
+ //Add your token in your sharepreferences.
46
+ SharedPreferences sp = getSharedPreferences("My Pref" , Context.MODE_PRIVATE);
47
+ sp.edit().putString("fcm_token",token).commit();
48
+ // getSharedPreferences("_", MODE_PRIVATE).edit().putString("fcm_token", token).apply();
49
+ }
50
+
51
+
39
52
  /**
40
53
  * Called when message is received.
41
54
  *
@@ -1,11 +1,13 @@
1
1
  package com.test.callkit.androidcall;
2
2
 
3
+ import android.text.TextUtils;
3
4
  import android.util.Log;
4
5
 
5
6
 
6
7
  import com.androidnetworking.AndroidNetworking;
7
8
  import com.androidnetworking.error.ANError;
8
9
  import com.androidnetworking.interfaces.JSONObjectRequestListener;
10
+ import com.google.firebase.messaging.FirebaseMessaging;
9
11
 
10
12
  import org.json.JSONException;
11
13
  import org.json.JSONObject;
@@ -13,6 +15,8 @@ import org.json.JSONObject;
13
15
 
14
16
  public class ApiCalls {
15
17
 
18
+
19
+
16
20
  public void gettwiliotoken(final String connectionId,final RetreivedTokenCallback callback)
17
21
  {
18
22
  Log.d("gettwiliotoken","called " + connectionId);
@@ -1,86 +1,96 @@
1
1
  package com.test.callkit.androidcall;
2
2
 
3
- import android.Manifest;
4
- import android.annotation.SuppressLint;
5
- import android.app.NotificationManager;
6
- import android.app.PendingIntent;
7
- import android.content.Context;
8
- import android.content.Intent;
9
- import android.content.SharedPreferences;
10
- import android.content.pm.PackageManager;
11
- import android.content.res.Resources;
12
- import android.media.AudioManager;
13
- import android.os.Build;
14
3
  import android.os.Bundle;
15
- import android.preference.PreferenceManager;
16
- import android.util.Log;
17
- import android.util.TypedValue;
18
- import android.view.MenuItem;
19
- import android.view.View;
20
- import android.view.ViewGroup;
21
- import android.widget.ImageView;
22
- import android.widget.LinearLayout;
23
- import android.widget.ProgressBar;
24
- import android.widget.TextView;
25
4
  import android.widget.Toast;
26
5
 
27
- import androidx.annotation.NonNull;
28
- import androidx.annotation.Nullable;
29
- import androidx.appcompat.app.AlertDialog;
30
6
  import androidx.appcompat.app.AppCompatActivity;
31
- import androidx.core.app.ActivityCompat;
32
- import androidx.core.app.NotificationCompat;
33
- import androidx.core.content.ContextCompat;
34
7
 
35
- import com.test.callkit.androidcall.util.CameraCapturerCompat;
36
- import com.google.android.material.floatingactionbutton.FloatingActionButton;
37
- import com.google.android.material.snackbar.Snackbar;
38
- import com.test.callkit.CallKitVoipPlugin;
39
8
  import com.test.callkit.R;
40
9
 
41
- import com.twilio.video.AudioCodec;
42
- import com.twilio.video.ConnectOptions;
43
- import com.twilio.video.EncodingParameters;
44
- import com.twilio.video.G722Codec;
45
- import com.twilio.video.H264Codec;
46
- import com.twilio.video.IsacCodec;
47
- import com.twilio.video.LocalAudioTrack;
48
- import com.twilio.video.LocalParticipant;
49
- import com.twilio.video.LocalVideoTrack;
50
- import com.twilio.video.OpusCodec;
51
- import com.twilio.video.PcmaCodec;
52
- import com.twilio.video.PcmuCodec;
53
- import com.twilio.video.RemoteAudioTrack;
54
- import com.twilio.video.RemoteAudioTrackPublication;
55
- import com.twilio.video.RemoteDataTrack;
56
- import com.twilio.video.RemoteDataTrackPublication;
57
- import com.twilio.video.RemoteParticipant;
58
- import com.twilio.video.RemoteVideoTrack;
59
- import com.twilio.video.RemoteVideoTrackPublication;
60
- import com.twilio.video.Room;
61
- import com.twilio.video.TwilioException;
62
- import com.twilio.video.Video;
63
- import com.twilio.video.VideoCodec;
64
- import com.twilio.video.VideoTrack;
65
- import com.twilio.video.VideoView;
66
- import com.twilio.video.Vp8Codec;
67
- import com.twilio.video.Vp9Codec;
68
-
69
- import java.util.ArrayList;
70
- import java.util.Collections;
71
- import java.util.List;
72
-
73
- import kotlin.Unit;
74
- import tvi.webrtc.VideoSink;
75
-
76
-
10
+ //
11
+ //import android.Manifest;
12
+ //import android.annotation.SuppressLint;
13
+ //import android.app.NotificationManager;
14
+ //import android.app.PendingIntent;
15
+ //import android.content.Context;
16
+ //import android.content.Intent;
17
+ //import android.content.SharedPreferences;
18
+ //import android.content.pm.PackageManager;
19
+ //import android.content.res.Resources;
20
+ //import android.media.AudioManager;
21
+ //import android.os.Build;
22
+ //import android.os.Bundle;
23
+ //import android.preference.PreferenceManager;
24
+ //import android.util.Log;
25
+ //import android.util.TypedValue;
26
+ //import android.view.MenuItem;
27
+ //import android.view.View;
28
+ //import android.view.ViewGroup;
29
+ //import android.widget.ImageView;
30
+ //import android.widget.LinearLayout;
31
+ //import android.widget.ProgressBar;
32
+ //import android.widget.TextView;
33
+ //import android.widget.Toast;
34
+ //
35
+ //import androidx.annotation.NonNull;
36
+ //import androidx.annotation.Nullable;
37
+ //import androidx.appcompat.app.AlertDialog;
38
+ //import androidx.appcompat.app.AppCompatActivity;
39
+ //import androidx.core.app.ActivityCompat;
40
+ //import androidx.core.app.NotificationCompat;
41
+ //import androidx.core.content.ContextCompat;
42
+ //
43
+ //import com.test.callkit.androidcall.util.CameraCapturerCompat;
44
+ //import com.google.android.material.floatingactionbutton.FloatingActionButton;
45
+ //import com.google.android.material.snackbar.Snackbar;
46
+ //import com.test.callkit.CallKitVoipPlugin;
47
+ //import com.test.callkit.R;
48
+ //
49
+ //import com.twilio.video.AudioCodec;
50
+ //import com.twilio.video.ConnectOptions;
51
+ //import com.twilio.video.EncodingParameters;
52
+ //import com.twilio.video.G722Codec;
53
+ //import com.twilio.video.H264Codec;
54
+ //import com.twilio.video.IsacCodec;
55
+ //import com.twilio.video.LocalAudioTrack;
56
+ //import com.twilio.video.LocalParticipant;
57
+ //import com.twilio.video.LocalVideoTrack;
58
+ //import com.twilio.video.OpusCodec;
59
+ //import com.twilio.video.PcmaCodec;
60
+ //import com.twilio.video.PcmuCodec;
61
+ //import com.twilio.video.RemoteAudioTrack;
62
+ //import com.twilio.video.RemoteAudioTrackPublication;
63
+ //import com.twilio.video.RemoteDataTrack;
64
+ //import com.twilio.video.RemoteDataTrackPublication;
65
+ //import com.twilio.video.RemoteParticipant;
66
+ //import com.twilio.video.RemoteVideoTrack;
67
+ //import com.twilio.video.RemoteVideoTrackPublication;
68
+ //import com.twilio.video.Room;
69
+ //import com.twilio.video.TwilioException;
70
+ //import com.twilio.video.Video;
71
+ //import com.twilio.video.VideoCodec;
72
+ //import com.twilio.video.VideoTrack;
73
+ //import com.twilio.video.VideoView;
74
+ //import com.twilio.video.Vp8Codec;
75
+ //import com.twilio.video.Vp9Codec;
76
+ //
77
+ //import java.util.ArrayList;
78
+ //import java.util.Collections;
79
+ //import java.util.List;
80
+ //
81
+ //import kotlin.Unit;
82
+ //import tvi.webrtc.VideoSink;
83
+ //import android.os.Bundle;
84
+ //
85
+ //import com.getcapacitor.BridgeActivity;
86
+ //
87
+ //
88
+ //
89
+ //
77
90
  public class CallActivity extends AppCompatActivity {
78
- @Override
79
- protected void onCreate(@Nullable Bundle savedInstanceState) {
80
- super.onCreate(savedInstanceState);
81
- }
82
-
83
- // private static final int CAMERA_MIC_PERMISSION_REQUEST_CODE = 1;
91
+ //
92
+ //
93
+ // private static final int CAMERA_MIC_PERMISSION_REQUEST_CODE = 1;
84
94
  // private static final int CAMERA_PERMISSION_INDEX = 0;
85
95
  // private static final int MIC_PERMISSION_INDEX = 1;
86
96
  // private static final String TAG = "VideoActivity";
@@ -160,18 +170,23 @@ public class CallActivity extends AppCompatActivity {
160
170
  // /*
161
171
  // * Audio management
162
172
  // */
163
- // private AudioSwitch audioSwitch;
173
+ //// private AudioSwitch audioSwitch;
164
174
  // private int savedVolumeControlStream;
165
175
  //
166
176
  // private VideoSink localVideoView;
167
177
  // private boolean disconnectedFromOnDestroy;
168
178
  // private boolean enableAutomaticSubscription;
169
179
  //
170
- // @Override
171
- // protected void onCreate(Bundle savedInstanceState) {
172
- // super.onCreate(savedInstanceState);
173
- // setContentView(R.layout.activity_video);
174
- //
180
+ @Override
181
+ protected void onCreate(Bundle savedInstanceState) {
182
+ super.onCreate(savedInstanceState);
183
+ setContentView(R.layout.layout_video);
184
+
185
+ Toast.makeText(getApplicationContext(),"Answered",Toast.LENGTH_LONG).show();
186
+
187
+ }
188
+ }
189
+
175
190
  // primaryVideoView = findViewById(R.id.primary_video_view);
176
191
  // thumbnailVideoView = findViewById(R.id.thumbnail_video_view);
177
192
  // reconnectingProgressBar = findViewById(R.id.reconnecting_progress_bar);
@@ -212,7 +227,7 @@ public class CallActivity extends AppCompatActivity {
212
227
  // /*
213
228
  // * Setup audio management and set the volume control stream
214
229
  // */
215
- // audioSwitch = new AudioSwitch(getApplicationContext());
230
+ //// audioSwitch = new AudioSwitch(getApplicationContext());
216
231
  // savedVolumeControlStream = getVolumeControlStream();
217
232
  // setVolumeControlStream(AudioManager.STREAM_VOICE_CALL);
218
233
  // /*
@@ -222,8 +237,8 @@ public class CallActivity extends AppCompatActivity {
222
237
  // if (!checkPermissionForCameraAndMicrophone()) {
223
238
  // requestPermissionForCameraMicrophoneAndBluetooth();
224
239
  // } else {
225
- // audioSwitch.start(
226
- // (audioDevices, audioDevice) -> Unit.INSTANCE);
240
+ //// audioSwitch.start(
241
+ //// (audioDevices, audioDevice) -> Unit.INSTANCE);
227
242
  // createAudioAndVideoTracks();
228
243
  // }
229
244
  //
@@ -335,13 +350,13 @@ public class CallActivity extends AppCompatActivity {
335
350
  // * permissions, AudioSwitch should be started after providing the user the option
336
351
  // * to grant the necessary permissions for bluetooth.
337
352
  // */
338
- // audioSwitch.start(
339
- // (audioDevices, audioDevice) -> Unit.INSTANCE);
353
+ //// audioSwitch.start(
354
+ //// (audioDevices, audioDevice) -> Unit.INSTANCE);
340
355
  //
341
356
  // if (cameraAndMicPermissionGranted) {
342
357
  // createAudioAndVideoTracks();
343
358
  // } else {
344
- // Toast.makeText(this, R.string.permissions_needed, Toast.LENGTH_LONG).show();
359
+ // Toast.makeText(this, "permission needed", Toast.LENGTH_LONG).show();
345
360
  // }
346
361
  // }
347
362
  // }
@@ -374,7 +389,7 @@ public class CallActivity extends AppCompatActivity {
374
389
  // /*
375
390
  // * Tear down audio management and restore previous volume stream
376
391
  // */
377
- // audioSwitch.stop();
392
+ //// audioSwitch.stop();
378
393
  // setVolumeControlStream(savedVolumeControlStream);
379
394
  //
380
395
  // /*
@@ -419,7 +434,7 @@ public class CallActivity extends AppCompatActivity {
419
434
  // ActivityCompat.shouldShowRequestPermissionRationale(this, permission);
420
435
  // }
421
436
  // if (displayRational) {
422
- // Toast.makeText(this, R.string.permissions_needed, Toast.LENGTH_LONG).show();
437
+ // Toast.makeText(this, "Permission needed", Toast.LENGTH_LONG).show();
423
438
  // } else {
424
439
  // ActivityCompat.requestPermissions(
425
440
  // this, permissions, CAMERA_MIC_PERMISSION_REQUEST_CODE);
@@ -469,7 +484,7 @@ public class CallActivity extends AppCompatActivity {
469
484
  // } else {
470
485
  // CallActivity.this.startService(serviceIntent);
471
486
  // }
472
- // audioSwitch.activate();
487
+ //// audioSwitch.activate();
473
488
  // ConnectOptions.Builder connectOptionsBuilder =
474
489
  // new ConnectOptions.Builder(accessToken).roomName(roomName);
475
490
  //
@@ -597,7 +612,8 @@ public class CallActivity extends AppCompatActivity {
597
612
  // */
598
613
  // private void setDisconnectAction() {
599
614
  // connectActionFab.setImageDrawable(
600
- // ContextCompat.getDrawable(this, R.drawable.ic_hangup));
615
+ //// ContextCompat.getDrawable(this, R.drawable.ic_hangup));
616
+ // ContextCompat.getDrawable(this, android.R.drawable.star_on));
601
617
  // connectActionFab.show();
602
618
  // connectActionFab.setOnClickListener(disconnectClickListener());
603
619
  // }
@@ -806,7 +822,7 @@ public class CallActivity extends AppCompatActivity {
806
822
  //
807
823
  // @Override
808
824
  // public void onConnectFailure(Room room, TwilioException e) {
809
- // audioSwitch.deactivate();
825
+ //// audioSwitch.deactivate();
810
826
  // intializeUI();
811
827
  // }
812
828
  //
@@ -814,10 +830,10 @@ public class CallActivity extends AppCompatActivity {
814
830
  // public void onDisconnected(Room room, TwilioException e) {
815
831
  // localParticipant = null;
816
832
  // reconnectingProgressBar.setVisibility(View.GONE);
817
- // CallActivity.this.room = null;
833
+ //// CallActivity.this.room = null;
818
834
  // // Only reinitialize the UI if disconnect was not called from onDestroy()
819
835
  // if (!disconnectedFromOnDestroy) {
820
- // audioSwitch.deactivate();
836
+ //// audioSwitch.deactivate();
821
837
  // intializeUI();
822
838
  // moveLocalVideoToPrimaryView();
823
839
  // }
@@ -1193,10 +1209,12 @@ public class CallActivity extends AppCompatActivity {
1193
1209
  // localVideoTrack.enable(enable);
1194
1210
  // int icon;
1195
1211
  // if (enable) {
1196
- // icon = R.drawable.ic_disable_camera;
1212
+ //// icon = R.drawable.ic_disable_camera;
1213
+ // icon = android.R.drawable.ic_menu_camera;
1197
1214
  // switchCameraActionFab.show();
1198
1215
  // } else {
1199
- // icon = R.drawable.ic_enable_camera;
1216
+ //// icon = R.drawable.ic_enable_camera;
1217
+ // icon = android.R.drawable.ic_menu_camera;
1200
1218
  // switchCameraActionFab.hide();
1201
1219
  // }
1202
1220
  // localVideoActionFab.setImageDrawable(
@@ -1215,11 +1233,12 @@ public class CallActivity extends AppCompatActivity {
1215
1233
  // if (localAudioTrack != null) {
1216
1234
  // boolean enable = !localAudioTrack.isEnabled();
1217
1235
  // localAudioTrack.enable(enable);
1218
- // int icon = enable ? R.drawable.ic_mic : R.drawable.ic_mic_disabled;
1236
+ //// int icon = enable ? R.drawable.ic_mic : R.drawable.ic_mic_disabled;
1237
+ // int icon = enable ? android.R.drawable.star_on : android.R.drawable.star_on;
1219
1238
  // muteActionFab.setImageDrawable(ContextCompat.getDrawable(CallActivity.this, icon));
1220
1239
  // }
1221
1240
  // };
1222
1241
  // }
1223
-
1224
-
1225
- }
1242
+ //
1243
+ //
1244
+ //}
@@ -6,10 +6,13 @@ import android.app.KeyguardManager;
6
6
  import android.app.Service;
7
7
  import android.content.Context;
8
8
  import android.content.Intent;
9
+ import android.content.SharedPreferences;
9
10
  import android.os.Build;
10
11
  import android.os.IBinder;
11
12
  import android.util.Log;
12
13
 
14
+ import androidx.preference.PreferenceManager;
15
+
13
16
 
14
17
  public class VoipBackgroundService extends Service
15
18
  {
@@ -42,11 +45,23 @@ public class VoipBackgroundService extends Service
42
45
  @Override
43
46
  public int onStartCommand(Intent intent, int flags, int startId)
44
47
  {
48
+ SharedPreferences sp = getSharedPreferences("My Pref" ,Context.MODE_PRIVATE);
49
+ String token = sp.getString("fcm_token","");
50
+ Log.d("FCM TOKEN","Token is "+ token);
45
51
  Log.d("MySipService", "onStartCommand");
52
+ Log.d("token from SP>>>>>", token);
53
+
46
54
  if(intent.hasExtra("connectionId") && intent.hasExtra("username"))
47
55
  {
48
56
  String connectionId = intent.getStringExtra("connectionId");
49
57
  String username = intent.getStringExtra("username");
58
+ if(!isServiceRunningInForeground(VoipBackgroundService.this,VoipForegroundService.class)) {
59
+ show_call_notification("incoming",token,username,connectionId);
60
+
61
+ KeyguardManager km = (KeyguardManager) getApplicationContext().getSystemService(Context.KEYGUARD_SERVICE);
62
+ KeyguardManager.KeyguardLock kl = km.newKeyguardLock("name");
63
+ kl.disableKeyguard();
64
+ }
50
65
  ApiCalls apiCalls = new ApiCalls();
51
66
  apiCalls.gettwiliotoken(connectionId, new RetreivedTokenCallback() {
52
67
  @SuppressLint("MissingPermission")
@@ -64,7 +79,8 @@ public class VoipBackgroundService extends Service
64
79
  }
65
80
  });
66
81
  }
67
- return START_NOT_STICKY;
82
+ // return START_NOT_STICKY;
83
+ return START_STICKY;
68
84
  }
69
85
 
70
86
 
@@ -102,4 +118,9 @@ public class VoipBackgroundService extends Service
102
118
 
103
119
  }
104
120
 
121
+ public static String getPref(String key, Context context) {
122
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
123
+ return preferences.getString(key, null);
124
+ }
125
+
105
126
  }
@@ -186,23 +186,26 @@ public class VoipForegroundService extends Service {
186
186
  }
187
187
  }
188
188
  public void createOngoingChannel() {
189
+ Uri defaultRingtone = Uri.parse("android.resource://"+getPackageName()+"/raw/alarm");
190
+
189
191
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
190
192
 
191
193
  NotificationChannel channel = new NotificationChannel(ONGOING_CHANNEL_ID, ONGOING_CHANNEL_NAME, NotificationManager.IMPORTANCE_DEFAULT);
192
194
  channel.setDescription(ONGOING_CHANNEL_NAME);
193
195
 
194
- channel.setSound(null,null);
196
+ channel.setSound(defaultRingtone,null);
195
197
  Objects.requireNonNull(getApplicationContext().getSystemService(NotificationManager.class)).createNotificationChannel(channel);
196
198
 
197
199
  }
198
200
  }
199
201
  public void createIncomingChannel() {
202
+ Uri defaultRingtone = Uri.parse("android.resource://"+getPackageName()+"/raw/alarm");
200
203
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
201
204
 
202
205
  NotificationChannel channel = new NotificationChannel(INCOMING_CHANNEL_ID, INCOMING_CHANNEL_NAME, NotificationManager.IMPORTANCE_HIGH);
203
206
  channel.setDescription(INCOMING_CHANNEL_NAME);
204
207
 
205
- channel.setSound(null,null);
208
+ channel.setSound(defaultRingtone,null);
206
209
 
207
210
 
208
211
  Objects.requireNonNull(getApplicationContext().getSystemService(NotificationManager.class)).createNotificationChannel(channel);
@@ -26,6 +26,8 @@ public class VoipForegroundServiceActionReceiver extends BroadcastReceiver {
26
26
  performClickAction(context, action,token,roomName,username);
27
27
  }
28
28
 
29
+ context.startService(new Intent(context,VoipBackgroundService.class));
30
+
29
31
  // Close the notification after the click action is performed.
30
32
 
31
33
 
Binary file
@@ -0,0 +1,68 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+ xmlns:app="http://schemas.android.com/apk/res-auto"
4
+ xmlns:tools="http://schemas.android.com/tools"
5
+ android:layout_width="match_parent"
6
+ android:layout_height="match_parent"
7
+ android:paddingVertical="50dp"
8
+ android:background="@android:color/white"
9
+ tools:ignore="MissingDefaultResource">
10
+
11
+ <TextView
12
+ android:id="@+id/incoming_call_title"
13
+ android:layout_width="wrap_content"
14
+ android:layout_height="wrap_content"
15
+ android:layout_marginBottom="50dp"
16
+ android:text="Incoming"
17
+ app:layout_constraintTop_toTopOf="parent"
18
+ app:layout_constraintLeft_toLeftOf="parent"
19
+ app:layout_constraintRight_toRightOf="parent"
20
+ app:layout_constraintBottom_toTopOf="@+id/caller_name"/>
21
+
22
+ <TextView
23
+ android:id="@+id/caller_name"
24
+ android:layout_width="wrap_content"
25
+ android:layout_height="wrap_content"
26
+ android:text="Username"
27
+ android:textStyle="bold"
28
+ android:textSize="25sp"
29
+ app:layout_constraintTop_toBottomOf="@id/incoming_call_title"
30
+ app:layout_constraintLeft_toLeftOf="parent"
31
+ app:layout_constraintRight_toRightOf="parent"
32
+ app:layout_constraintBottom_toTopOf="@+id/activity_caller_photo"/>
33
+
34
+ <ImageView
35
+ android:id="@+id/activity_caller_photo"
36
+ android:layout_width="100dp"
37
+ android:layout_height="100sp"
38
+ android:layout_marginTop="30dp"
39
+ android:src="@android:drawable/stat_sys_phone_call"
40
+ app:layout_constraintTop_toBottomOf="@id/caller_name"
41
+ app:layout_constraintLeft_toLeftOf="parent"
42
+ app:layout_constraintRight_toRightOf="parent"
43
+ />
44
+
45
+ <com.google.android.material.floatingactionbutton.FloatingActionButton
46
+ android:id="@+id/activity_hang_up_button"
47
+ android:layout_marginBottom="45dp"
48
+ android:layout_marginLeft="50dp"
49
+ app:backgroundTint="@android:color/holo_red_dark"
50
+ app:borderWidth="0dp"
51
+ app:layout_constraintLeft_toLeftOf="parent"
52
+ app:layout_constraintBottom_toBottomOf="parent"
53
+ android:contentDescription="hang up"
54
+ android:layout_height="wrap_content"
55
+ android:layout_width="wrap_content"
56
+ app:srcCompat="@android:drawable/presence_audio_away"/>
57
+
58
+ <com.google.android.material.floatingactionbutton.FloatingActionButton
59
+ android:id="@+id/activity_answer_call_button"
60
+ android:layout_height="wrap_content"
61
+ android:layout_width="wrap_content"
62
+ app:srcCompat="@android:drawable/presence_audio_away"
63
+ app:backgroundTint="@android:color/holo_green_light"
64
+ android:layout_marginRight="50dp"
65
+ app:layout_constraintRight_toRightOf="parent"
66
+ app:layout_constraintBottom_toBottomOf="@id/activity_hang_up_button"
67
+ android:contentDescription="answer call" />
68
+ </androidx.constraintlayout.widget.ConstraintLayout>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "voip-callkit",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "capacitor plugin for callkit and voip",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",