Skip to content

Commit b32b23c

Browse files
authored
example: update android callservice for android 12 (#73)
1 parent be03392 commit b32b23c

6 files changed

Lines changed: 50 additions & 31 deletions

File tree

example/android/app/src/main/AndroidManifest.xml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,18 @@
2929
<category android:name="android.intent.category.LAUNCHER" />
3030
</intent-filter>
3131
</activity>
32-
<service android:name="com.voximplant.foregroundservice.VIForegroundService"
33-
android:foregroundServiceType="mediaProjection" />
32+
<meta-data
33+
android:name="com.supersami.foregroundservice.notification_channel_name"
34+
android:value="Call"
35+
/>
36+
<meta-data
37+
android:name="com.supersami.foregroundservice.notification_channel_description"
38+
android:value=""
39+
/>
40+
<service android:name="com.supersami.foregroundservice.ForegroundService"
41+
android:foregroundServiceType="mediaProjection" />
42+
<service android:name="com.supersami.foregroundservice.ForegroundServiceTask" />
43+
<service android:name="com.voximplant.foregroundservice.VIForegroundService" />
3444
</application>
3545

3646
</manifest>

example/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ import { name as appName } from './app.json';
44
import { registerGlobals } from '@livekit/react-native';
55
import { LogLevel, setLogLevel } from 'livekit-client';
66
import { setJSExceptionHandler } from 'react-native-exception-handler';
7+
import ReactNativeForegroundService from '@supersami/rn-foreground-service';
78
setJSExceptionHandler((error) => {
89
console.log('error:', error, error.stack);
910
}, true);
1011

1112
setLogLevel(LogLevel.debug);
1213
registerGlobals();
14+
ReactNativeForegroundService.register();
1315
AppRegistry.registerComponent(appName, () => App);

example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"@react-native-async-storage/async-storage": "^1.17.10",
1414
"@react-navigation/native": "^6.0.8",
1515
"@react-navigation/native-stack": "^6.5.0",
16-
"@voximplant/react-native-foreground-service": "^3.0.1",
16+
"@supersami/rn-foreground-service": "^2.1.0",
1717
"fastestsmallesttextencoderdecoder": "^1.0.22",
1818
"react": "18.2.0",
1919
"react-native": "0.71.8",
Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,17 @@
1-
import VIForegroundService from '@voximplant/react-native-foreground-service';
1+
import ReactNativeForegroundService from '@supersami/rn-foreground-service';
22

33
// Start a foreground notification on Android.
44
// A foreground notification is required for screenshare on Android.
55
export async function startCallService() {
6-
const channelConfig = {
7-
id: 'channelId',
8-
name: 'Call',
9-
description: '',
10-
enableVibration: false,
11-
};
12-
await VIForegroundService.getInstance().createNotificationChannel(
13-
channelConfig
14-
);
15-
const notificationConfig = {
16-
channelId: 'channelId',
6+
await ReactNativeForegroundService.start({
177
id: 3456,
188
title: 'LiveKit React Example',
19-
text: 'Call in progress',
9+
message: 'Call in progress',
10+
importance: 'none',
11+
vibration: false,
2012
icon: 'ic_launcher',
21-
};
22-
try {
23-
await VIForegroundService.getInstance().startService(notificationConfig);
24-
} catch (e) {
25-
console.error(e);
26-
}
13+
});
2714
}
2815
export async function stopCallService() {
29-
await VIForegroundService.getInstance().stopService();
16+
await ReactNativeForegroundService.stop();
3017
}

example/yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2024,6 +2024,11 @@
20242024
dependencies:
20252025
"@sinonjs/commons" "^3.0.0"
20262026

2027+
"@supersami/rn-foreground-service@^2.1.0":
2028+
version "2.1.0"
2029+
resolved "https://registry.yarnpkg.com/@supersami/rn-foreground-service/-/rn-foreground-service-2.1.0.tgz#890d82778676651899be8d7aed72640242af2193"
2030+
integrity sha512-Ou++vMcW42uZDuZr7wWMJYKZL7Ui1Z5lfY5fg7LT2vVwuuDNjjFf4RCHxul9y33VcoQrPTyPJhd0jQ3+3kFi8w==
2031+
20272032
"@types/fastestsmallesttextencoderdecoder@^1.0.0":
20282033
version "1.0.0"
20292034
resolved "https://registry.yarnpkg.com/@types/fastestsmallesttextencoderdecoder/-/fastestsmallesttextencoderdecoder-1.0.0.tgz#24477652ac71737558fdf54ee0ab17385bd653b5"
@@ -2110,11 +2115,6 @@
21102115
dependencies:
21112116
"@types/yargs-parser" "*"
21122117

2113-
"@voximplant/react-native-foreground-service@^3.0.1":
2114-
version "3.0.1"
2115-
resolved "https://registry.yarnpkg.com/@voximplant/react-native-foreground-service/-/react-native-foreground-service-3.0.1.tgz#e96d102d060b15c303558ecac9846345d22f7410"
2116-
integrity sha512-lCjNe89KcOuTxe8i+XKAMoWhHqeLQr9dAYprLNum/VyZgDOUhmz3tRdQ86lXs9M37oXTe0VkEd22oVCdtMIQpw==
2117-
21182118
abort-controller@^3.0.0:
21192119
version "3.0.0"
21202120
resolved "https://registry.yarnpkg.com/abort-controller/-/abort-controller-3.0.0.tgz#eaf54d53b62bae4138e809ca225c8439a6efb392"

package.json

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@
7373
"typescript": "4.8.4"
7474
},
7575
"peerDependencies": {
76+
"@livekit/react-native-webrtc": "^104.0.0",
7677
"react": "*",
77-
"react-native": "*",
78-
"@livekit/react-native-webrtc": "^104.0.0"
78+
"react-native": "*"
7979
},
8080
"scripts": {
8181
"test": "jest",
@@ -98,7 +98,27 @@
9898
"commitlint": {
9999
"extends": [
100100
"@commitlint/config-conventional"
101-
]
101+
],
102+
"rules": {
103+
"type-enum": [
104+
2,
105+
"always",
106+
[
107+
"build",
108+
"chore",
109+
"ci",
110+
"docs",
111+
"feat",
112+
"fix",
113+
"perf",
114+
"refactor",
115+
"revert",
116+
"style",
117+
"test",
118+
"example"
119+
]
120+
]
121+
}
102122
},
103123
"release-it": {
104124
"hooks": {

0 commit comments

Comments
 (0)