From bf2b08279cb2174311e498627c34a56ef44d26bd Mon Sep 17 00:00:00 2001 From: Shubh Porwal Date: Thu, 3 Apr 2025 18:42:02 +0530 Subject: [PATCH 1/3] chore: update example app --- example/android/app/src/main/AndroidManifest.xml | 14 ++++++++++---- example/package.json | 2 +- .../@supersami+rn-foreground-service+2.1.0.patch | 12 ------------ example/src/RoomPage.tsx | 1 + example/src/callservice/CallService.android.ts | 14 ++++++++++++-- example/src/callservice/CallService.ios.ts | 7 +++++++ example/yarn.lock | 10 +++++----- 7 files changed, 36 insertions(+), 24 deletions(-) delete mode 100644 example/patches/@supersami+rn-foreground-service+2.1.0.patch diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index 88e89565..4af21b2a 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -8,11 +8,17 @@ + + + + + + - - + - + diff --git a/example/package.json b/example/package.json index c46bb798..f5a6529e 100644 --- a/example/package.json +++ b/example/package.json @@ -14,7 +14,7 @@ "@react-native-async-storage/async-storage": "^1.17.10", "@react-navigation/native": "^6.0.8", "@react-navigation/native-stack": "^6.5.0", - "@supersami/rn-foreground-service": "^2.1.1", + "@supersami/rn-foreground-service": "^2.2.5", "livekit-client": "^2.9.8", "react": "18.2.0", "react-native": "0.74.2", diff --git a/example/patches/@supersami+rn-foreground-service+2.1.0.patch b/example/patches/@supersami+rn-foreground-service+2.1.0.patch deleted file mode 100644 index a3592ddb..00000000 --- a/example/patches/@supersami+rn-foreground-service+2.1.0.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff --git a/node_modules/@supersami/rn-foreground-service/android/src/main/java/com/supersami/foregroundservice/NotificationHelper.java b/node_modules/@supersami/rn-foreground-service/android/src/main/java/com/supersami/foregroundservice/NotificationHelper.java -index afccd04..26dbded 100644 ---- a/node_modules/@supersami/rn-foreground-service/android/src/main/java/com/supersami/foregroundservice/NotificationHelper.java -+++ b/node_modules/@supersami/rn-foreground-service/android/src/main/java/com/supersami/foregroundservice/NotificationHelper.java -@@ -14,6 +14,7 @@ import android.os.Bundle; - import androidx.core.app.NotificationCompat; - import android.util.Log; - -+import com.facebook.react.R; - - // partially took ideas from: https://github.com/zo0r/react-native-push-notification/blob/master/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationHelper.java - diff --git a/example/src/RoomPage.tsx b/example/src/RoomPage.tsx index 63781714..edebaadb 100644 --- a/example/src/RoomPage.tsx +++ b/example/src/RoomPage.tsx @@ -95,6 +95,7 @@ interface RoomViewProps { const RoomView = ({ navigation, e2ee }: RoomViewProps) => { const [isCameraFrontFacing, setCameraFrontFacing] = useState(true); const room = useRoomContext(); + useEffect(() => { let setup = async () => { if (e2ee) { diff --git a/example/src/callservice/CallService.android.ts b/example/src/callservice/CallService.android.ts index 0e0a4234..6a62340c 100644 --- a/example/src/callservice/CallService.android.ts +++ b/example/src/callservice/CallService.android.ts @@ -1,7 +1,7 @@ import ReactNativeForegroundService from '@supersami/rn-foreground-service'; // Start a foreground notification on Android. -// A foreground notification is required for screenshare on Android. +// A foreground notification is required for video/audio calls on Android. export async function startCallService() { await ReactNativeForegroundService.start({ id: 3456, @@ -10,12 +10,22 @@ export async function startCallService() { importance: 'none', vibration: false, icon: 'ic_launcher', + // @ts-ignore + ServiceType: 'microphone', }); } + export async function stopCallService() { await ReactNativeForegroundService.stop(); } export function setupCallService() { - ReactNativeForegroundService.register(); + ReactNativeForegroundService.register({ + config: { + alert: false, + onServiceErrorCallBack: () => { + console.error('Foreground service error occurred'); + }, + }, + }); } diff --git a/example/src/callservice/CallService.ios.ts b/example/src/callservice/CallService.ios.ts index bc59ad59..50090399 100644 --- a/example/src/callservice/CallService.ios.ts +++ b/example/src/callservice/CallService.ios.ts @@ -14,6 +14,13 @@ export async function startCallService() { let handle = '1234567'; let contactIdentifier = 'Caller Contact'; RNCallKeep.startCall(uuid, handle, contactIdentifier, 'number', true); + + RNCallKeep.reportConnectingOutgoingCallWithUUID(uuid); + + // Small delay to ensure proper state transition + setTimeout(() => { + RNCallKeep.reportConnectedOutgoingCallWithUUID(uuid); + }, 100); } export async function stopCallService() { diff --git a/example/yarn.lock b/example/yarn.lock index 9731bd23..12dd1378 100644 --- a/example/yarn.lock +++ b/example/yarn.lock @@ -2807,12 +2807,12 @@ __metadata: languageName: node linkType: hard -"@supersami/rn-foreground-service@npm:^2.1.1": - version: 2.1.1 - resolution: "@supersami/rn-foreground-service@npm:2.1.1" +"@supersami/rn-foreground-service@npm:^2.2.5": + version: 2.2.5 + resolution: "@supersami/rn-foreground-service@npm:2.2.5" peerDependencies: react-native: ">=0.59.0" - checksum: 733d9449e0e95566449306656a8465207bb45d6ecbc5cce9694a64779e4128677de06a5aa7a55e6cc7a929ad32de751cbf0e465ad8f663229705780cd1b7c161 + checksum: a817ad18d722b977fd9e51f86af9ebae321c3533c8957ad9017562ab946ce1e6f6bbafe5b3cf5e0b4e0be01ffc0d191104b9013b892013a791b51a32c36f5210 languageName: node linkType: hard @@ -6134,7 +6134,7 @@ __metadata: "@react-native/typescript-config": 0.74.84 "@react-navigation/native": ^6.0.8 "@react-navigation/native-stack": ^6.5.0 - "@supersami/rn-foreground-service": ^2.1.1 + "@supersami/rn-foreground-service": ^2.2.5 "@types/fastestsmallesttextencoderdecoder": ^1.0.0 "@types/react": ^18.2.6 babel-plugin-module-resolver: ^4.1.0 From ef9cac5794c3b2bb08edb5088e8c651156b2b32a Mon Sep 17 00:00:00 2001 From: Shubh Porwal Date: Thu, 3 Apr 2025 19:23:25 +0530 Subject: [PATCH 2/3] refactor: revert changes --- example/src/callservice/CallService.android.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/src/callservice/CallService.android.ts b/example/src/callservice/CallService.android.ts index 6a62340c..aef1eaaa 100644 --- a/example/src/callservice/CallService.android.ts +++ b/example/src/callservice/CallService.android.ts @@ -1,7 +1,7 @@ import ReactNativeForegroundService from '@supersami/rn-foreground-service'; // Start a foreground notification on Android. -// A foreground notification is required for video/audio calls on Android. +// A foreground notification is required for screenshare on Android. export async function startCallService() { await ReactNativeForegroundService.start({ id: 3456, From 4b97a9dba696db7a7266fd416367e6fe356d85fb Mon Sep 17 00:00:00 2001 From: Shubh Porwal Date: Fri, 4 Apr 2025 18:12:57 +0530 Subject: [PATCH 3/3] fix: report end call with reason --- example/src/callservice/CallService.ios.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/example/src/callservice/CallService.ios.ts b/example/src/callservice/CallService.ios.ts index 50090399..610b3f5d 100644 --- a/example/src/callservice/CallService.ios.ts +++ b/example/src/callservice/CallService.ios.ts @@ -3,6 +3,7 @@ import RNCallKeep, { AudioSessionCategoryOption, AudioSessionMode, + CONSTANTS as CK_CONSTANTS, } from 'react-native-callkeep'; import { RTCAudioSession } from '@livekit/react-native-webrtc'; @@ -25,6 +26,10 @@ export async function startCallService() { export async function stopCallService() { RNCallKeep.endCall(uuid); + RNCallKeep.reportEndCallWithUUID( + uuid, + CK_CONSTANTS.END_CALL_REASONS.REMOTE_ENDED + ); } export function setupCallService() {