-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
198 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,96 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.kadeno.reactnativecallpoc"> | ||
<uses-permission android:name="android.permission.INTERNET"/> | ||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> | ||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/> | ||
<uses-permission android:name="android.permission.VIBRATE"/> | ||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.kadeno.reactnativecallpoc"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> | ||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> | ||
<uses-permission android:name="android.permission.VIBRATE" /> | ||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | ||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> | ||
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> | ||
<uses-permission android:name="android.permission.CALL_PHONE" /> | ||
<uses-permission android:name="android.permission.READ_PHONE_NUMBERS" /> | ||
<uses-permission android:name="android.permission.RECORD_AUDIO" /> | ||
<uses-permission android:name="android.permission.MANAGE_OWN_CALLS" /> | ||
<uses-permission android:name="android.permission.READ_CALL_LOG" /> | ||
<queries> | ||
<intent> | ||
<action android:name="android.intent.action.VIEW"/> | ||
<category android:name="android.intent.category.BROWSABLE"/> | ||
<data android:scheme="https"/> | ||
</intent> | ||
</queries> | ||
<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="true" android:theme="@style/AppTheme" android:usesCleartextTraffic="true"> | ||
<meta-data android:name="expo.modules.updates.ENABLED" android:value="true"/> | ||
<meta-data android:name="expo.modules.updates.EXPO_SDK_VERSION" android:value="45.0.0"/> | ||
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH" android:value="ALWAYS"/> | ||
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS" android:value="0"/> | ||
<meta-data android:name="expo.modules.updates.EXPO_UPDATE_URL" android:value="https://exp.host/@kadeno/react-native-call-poc"/> | ||
<activity android:name=".MainActivity" android:label="@string/app_name" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:theme="@style/Theme.App.SplashScreen" android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN"/> | ||
<category android:name="android.intent.category.LAUNCHER"/> | ||
</intent-filter> | ||
<intent-filter> | ||
<action android:name="android.intent.action.VIEW"/> | ||
<category android:name="android.intent.category.DEFAULT"/> | ||
<category android:name="android.intent.category.BROWSABLE"/> | ||
<data android:scheme="com.kadeno.reactnativecallpoc"/> | ||
</intent-filter> | ||
</activity> | ||
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:exported="false"/> | ||
<service | ||
android:name="io.wazo.callkeep.VoiceConnectionService" | ||
android:foregroundServiceType="camera|microphone" | ||
android:label="Wazo" | ||
android:permission="android.permission.BIND_TELECOM_CONNECTION_SERVICE" | ||
android:exported="false"> | ||
<intent-filter> | ||
<action android:name="android.telecom.ConnectionService" /> | ||
</intent-filter> | ||
</service> | ||
</application> | ||
|
||
<queries> | ||
<intent> | ||
<action android:name="android.intent.action.VIEW" /> | ||
|
||
<category android:name="android.intent.category.BROWSABLE" /> | ||
|
||
<data android:scheme="https" /> | ||
</intent> | ||
</queries> | ||
|
||
<application | ||
android:name=".MainApplication" | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:theme="@style/AppTheme" | ||
android:usesCleartextTraffic="true"> | ||
|
||
<service | ||
android:name=".sinch.SinchService" | ||
android:enabled="true" | ||
android:exported="true" /> | ||
|
||
<meta-data | ||
android:name="expo.modules.updates.ENABLED" | ||
android:value="true" /> | ||
<meta-data | ||
android:name="expo.modules.updates.EXPO_SDK_VERSION" | ||
android:value="45.0.0" /> | ||
<meta-data | ||
android:name="expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH" | ||
android:value="ALWAYS" /> | ||
<meta-data | ||
android:name="expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS" | ||
android:value="0" /> | ||
<meta-data | ||
android:name="expo.modules.updates.EXPO_UPDATE_URL" | ||
android:value="https://exp.host/@kadeno/react-native-call-poc" /> | ||
|
||
<activity | ||
android:name=".MainActivity" | ||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode" | ||
android:exported="true" | ||
android:label="@string/app_name" | ||
android:launchMode="singleTask" | ||
android:theme="@style/Theme.App.SplashScreen" | ||
android:windowSoftInputMode="adjustResize"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
<intent-filter> | ||
<action android:name="android.intent.action.VIEW" /> | ||
|
||
<category android:name="android.intent.category.DEFAULT" /> | ||
<category android:name="android.intent.category.BROWSABLE" /> | ||
|
||
<data android:scheme="com.kadeno.reactnativecallpoc" /> | ||
</intent-filter> | ||
</activity> | ||
<activity | ||
android:name="com.facebook.react.devsupport.DevSettingsActivity" | ||
android:exported="false" /> | ||
|
||
<service | ||
android:name="io.wazo.callkeep.VoiceConnectionService" | ||
android:exported="false" | ||
android:foregroundServiceType="camera|microphone" | ||
android:label="Wazo" | ||
android:permission="android.permission.BIND_TELECOM_CONNECTION_SERVICE"> | ||
<intent-filter> | ||
<action android:name="android.telecom.ConnectionService" /> | ||
</intent-filter> | ||
</service> | ||
</application> | ||
|
||
</manifest> |
110 changes: 110 additions & 0 deletions
110
android/app/src/main/java/com/kadeno/reactnativecallpoc/sinch/SinchService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
package com.kadeno.reactnativecallpoc.sinch; | ||
|
||
import android.app.Service; | ||
import android.content.Intent; | ||
import android.os.IBinder; | ||
|
||
import com.sinch.android.rtc.ClientRegistration; | ||
import com.sinch.android.rtc.Sinch; | ||
import com.sinch.android.rtc.SinchClient; | ||
import com.sinch.android.rtc.SinchClientListener; | ||
import com.sinch.android.rtc.SinchError; | ||
import com.sinch.android.rtc.calling.Call; | ||
import com.sinch.android.rtc.calling.CallClient; | ||
import com.sinch.android.rtc.calling.CallClientListener; | ||
import com.sinch.android.rtc.internal.client.DefaultSinchClient; | ||
|
||
public class SinchService extends Service implements SinchClientListener, CallClientListener { | ||
|
||
private static final String APP_KEY = ""; | ||
private static final String ENVIRONMENT = "application-secret"; | ||
private static final String APP_SECRET = "ocra.api.sinch.com"; | ||
|
||
|
||
private SinchClient sinchClient = null; | ||
private String userId = ""; | ||
|
||
public SinchService() { | ||
if (this.sinchClient == null) { | ||
createClient("username"); | ||
} | ||
sinchClient.start(); | ||
} | ||
|
||
private void createClient(String userName) { | ||
this.userId = userName; | ||
sinchClient = Sinch.getSinchClientBuilder() | ||
.context(this) | ||
.applicationKey(APP_KEY) | ||
.environmentHost(ENVIRONMENT) | ||
.userId(userName) | ||
.build(); | ||
|
||
|
||
((DefaultSinchClient)sinchClient).setSupportActiveConnection(true); | ||
sinchClient.startListeningOnActiveConnection(); | ||
|
||
SinchService sinchService = new SinchService(); | ||
sinchClient.addSinchClientListener(sinchService); | ||
sinchClient.getCallClient().addCallClientListener(sinchService); | ||
|
||
} | ||
|
||
|
||
|
||
|
||
@Override | ||
public IBinder onBind(Intent intent) { | ||
// TODO: Return the communication channel to the service. | ||
throw new UnsupportedOperationException("Not yet implemented"); | ||
} | ||
|
||
@Override | ||
public void onClientStarted(SinchClient sinchClient) { | ||
|
||
} | ||
|
||
@Override | ||
public void onClientFailed(SinchClient sinchClient, SinchError sinchError) { | ||
|
||
} | ||
|
||
@Override | ||
public void onLogMessage(int i, String s, String s1) { | ||
|
||
} | ||
|
||
@Override | ||
public void onPushTokenRegistered() { | ||
|
||
} | ||
|
||
@Override | ||
public void onPushTokenRegistrationFailed(SinchError sinchError) { | ||
|
||
} | ||
|
||
@Override | ||
public void onCredentialsRequired(ClientRegistration clientRegistration) { | ||
if(clientRegistration != null) { | ||
clientRegistration.register("JWT.create(APP_KEY, APP_SECRET, userId)"); | ||
|
||
} | ||
} | ||
|
||
@Override | ||
public void onUserRegistered() { | ||
|
||
} | ||
|
||
@Override | ||
public void onUserRegistrationFailed(SinchError sinchError) { | ||
|
||
} | ||
|
||
@Override | ||
public void onIncomingCall(CallClient callClient, Call call) { | ||
|
||
} | ||
|
||
} |