Skip to content

Commit 132eddf

Browse files
authored
Merge pull request #331 from react-native-webrtc/sdk_lower_30_compatible
Make foreground service compatible with SDK version < 30
2 parents 60b2620 + 8d0ec78 commit 132eddf

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,7 @@ Since iOS 13, you'll have to report the incoming calls that wakes up your applic
833833
## Android 11
834834

835835
Since Android 11, your application [requires to start a foregroundService](https://developer.android.com/about/versions/11/privacy/foreground-services) in order to access the microphone in background.
836+
You'll need to upgrade your `compileSdkVersion` to `30` to be able to use this feature.
836837

837838
You have to set the `foregroundService` key in the [`setup()`](#setup) method and add a `foregroundServiceType` in the [`AndroidManifest` file](docs/android-installation.md#android-common-step-installation).
838839

android/src/main/java/io/wazo/callkeep/Constants.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,6 @@ public class Constants {
1818
public static final String EXTRA_CALLER_NAME = "EXTRA_CALLER_NAME";
1919
// Can't use telecom.EXTRA_DISABLE_ADD_CALL ...
2020
public static final String EXTRA_DISABLE_ADD_CALL = "android.telecom.extra.DISABLE_ADD_CALL";
21+
22+
public static final int FOREGROUND_SERVICE_TYPE_MICROPHONE = 128;
2123
}

android/src/main/java/io/wazo/callkeep/VoiceConnectionService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
import java.util.UUID;
5757
import java.util.stream.Collectors;
5858

59-
import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE;
6059
import static io.wazo.callkeep.Constants.ACTION_AUDIO_SESSION;
6160
import static io.wazo.callkeep.Constants.ACTION_ONGOING_CALL;
6261
import static io.wazo.callkeep.Constants.ACTION_CHECK_REACHABILITY;
@@ -65,6 +64,7 @@
6564
import static io.wazo.callkeep.Constants.EXTRA_CALL_NUMBER;
6665
import static io.wazo.callkeep.Constants.EXTRA_CALL_UUID;
6766
import static io.wazo.callkeep.Constants.EXTRA_DISABLE_ADD_CALL;
67+
import static io.wazo.callkeep.Constants.FOREGROUND_SERVICE_TYPE_MICROPHONE;
6868

6969
// @see https://github.com/kbagchiGWC/voice-quickstart-android/blob/9a2aff7fbe0d0a5ae9457b48e9ad408740dfb968/exampleConnectionService/src/main/java/com/twilio/voice/examples/connectionservice/VoiceConnectionService.java
7070
@TargetApi(Build.VERSION_CODES.M)

0 commit comments

Comments
 (0)