@stream-io/video-react-native-sdk 1.45.0 → 2.0.0-beta.0
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.
- package/CHANGELOG.md +8 -7
- package/android/src/main/java/com/streamvideo/reactnative/keepalive/StreamCallKeepAliveHeadlessService.kt +112 -26
- package/android/src/main/java/com/streamvideo/reactnative/util/CallAlivePermissionsHelper.kt +68 -37
- package/dist/commonjs/hooks/push/useCallingExpWithCallingStateEffect.js +3 -1
- package/dist/commonjs/hooks/push/useCallingExpWithCallingStateEffect.js.map +1 -1
- package/dist/commonjs/hooks/useAndroidKeepCallAliveEffect.js +38 -11
- package/dist/commonjs/hooks/useAndroidKeepCallAliveEffect.js.map +1 -1
- package/dist/commonjs/utils/internal/callingx/callingx.js +37 -55
- package/dist/commonjs/utils/internal/callingx/callingx.js.map +1 -1
- package/dist/commonjs/utils/keepCallAliveHeadlessTask.js +43 -4
- package/dist/commonjs/utils/keepCallAliveHeadlessTask.js.map +1 -1
- package/dist/commonjs/utils/push/internal/android.js +28 -10
- package/dist/commonjs/utils/push/internal/android.js.map +1 -1
- package/dist/commonjs/version.js +1 -1
- package/dist/commonjs/version.js.map +1 -1
- package/dist/module/hooks/push/useCallingExpWithCallingStateEffect.js +3 -1
- package/dist/module/hooks/push/useCallingExpWithCallingStateEffect.js.map +1 -1
- package/dist/module/hooks/useAndroidKeepCallAliveEffect.js +39 -12
- package/dist/module/hooks/useAndroidKeepCallAliveEffect.js.map +1 -1
- package/dist/module/utils/internal/callingx/callingx.js +37 -55
- package/dist/module/utils/internal/callingx/callingx.js.map +1 -1
- package/dist/module/utils/keepCallAliveHeadlessTask.js +41 -3
- package/dist/module/utils/keepCallAliveHeadlessTask.js.map +1 -1
- package/dist/module/utils/push/internal/android.js +28 -10
- package/dist/module/utils/push/internal/android.js.map +1 -1
- package/dist/module/version.js +1 -1
- package/dist/module/version.js.map +1 -1
- package/dist/typescript/hooks/push/useCallingExpWithCallingStateEffect.d.ts.map +1 -1
- package/dist/typescript/hooks/useAndroidKeepCallAliveEffect.d.ts.map +1 -1
- package/dist/typescript/utils/StreamVideoRN/types.d.ts +1 -2
- package/dist/typescript/utils/StreamVideoRN/types.d.ts.map +1 -1
- package/dist/typescript/utils/internal/callingx/callingx.d.ts.map +1 -1
- package/dist/typescript/utils/keepCallAliveHeadlessTask.d.ts +9 -0
- package/dist/typescript/utils/keepCallAliveHeadlessTask.d.ts.map +1 -1
- package/dist/typescript/utils/push/internal/android.d.ts.map +1 -1
- package/dist/typescript/version.d.ts +1 -1
- package/dist/typescript/version.d.ts.map +1 -1
- package/expo-config-plugin/dist/withAndroidPermissions.js +1 -1
- package/package.json +4 -4
- package/src/hooks/push/useCallingExpWithCallingStateEffect.ts +13 -6
- package/src/hooks/useAndroidKeepCallAliveEffect.ts +59 -21
- package/src/utils/StreamVideoRN/types.ts +1 -2
- package/src/utils/internal/callingx/callingx.ts +47 -66
- package/src/utils/keepCallAliveHeadlessTask.ts +45 -3
- package/src/utils/push/internal/android.ts +31 -10
- package/src/version.ts +1 -1
|
@@ -31,8 +31,21 @@ export function getCallDisplayName(callMembers, participants, currentUserId) {
|
|
|
31
31
|
}
|
|
32
32
|
return names.sort().join(', ');
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Args shared by the callingx call registration APIs:
|
|
37
|
+
* `(callId, phoneNumber, callerName, hasVideo)`.
|
|
38
|
+
*/
|
|
39
|
+
function getCallingxCallArgs(call) {
|
|
40
|
+
const callDisplayName = call.state.custom?.display_name || getCallDisplayName(call.state.members, call.state.participants, call.currentUserId);
|
|
41
|
+
return [call.cid,
|
|
42
|
+
// unique id for call
|
|
43
|
+
call.state.createdBy?.id ?? callDisplayName,
|
|
44
|
+
// handle for native call UI (prefer createdBy user id, fallback to call display name)
|
|
45
|
+
callDisplayName,
|
|
46
|
+
// display name for display in call screen
|
|
47
|
+
call.state.settings?.video?.enabled ?? false // is video call?
|
|
48
|
+
];
|
|
36
49
|
}
|
|
37
50
|
export async function registerOutgoingCall(call) {
|
|
38
51
|
if (!CallingxModule || !CallingxModule.isSetup || call.isOwnTracksLoopbackAllowed) {
|
|
@@ -45,15 +58,7 @@ export async function registerOutgoingCall(call) {
|
|
|
45
58
|
const logger = videoLoggerSystem.getLogger('callingx');
|
|
46
59
|
try {
|
|
47
60
|
logger.debug(`registerOutgoingCall: Registering outgoing call ${call.cid}`);
|
|
48
|
-
|
|
49
|
-
await CallingxModule.startCall(call.cid,
|
|
50
|
-
// unique id for call
|
|
51
|
-
call.state.createdBy?.id ?? callDisplayName,
|
|
52
|
-
// handle for native call UI (prefer createdBy user id, fallback to call display name)
|
|
53
|
-
callDisplayName,
|
|
54
|
-
// display name for display in call screen
|
|
55
|
-
call.state.settings?.video?.enabled ?? false // is video call?
|
|
56
|
-
);
|
|
61
|
+
await CallingxModule.startCall(...getCallingxCallArgs(call));
|
|
57
62
|
} catch (error) {
|
|
58
63
|
logger.error(`registerOutgoingCall: Error registering outgoing call in callingx: ${call.cid}`, error);
|
|
59
64
|
}
|
|
@@ -74,53 +79,30 @@ export async function joinCallingxCall(call, activeCalls) {
|
|
|
74
79
|
const logger = videoLoggerSystem.getLogger('callingx');
|
|
75
80
|
const isOutcomingCall = call.ringing && call.isCreatedByMe;
|
|
76
81
|
const isIncomingCall = call.ringing && !call.isCreatedByMe;
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
call.state.
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
try {
|
|
91
|
-
await startCallInCallingx();
|
|
92
|
-
} catch (error) {
|
|
93
|
-
logger.error(`startCallingxCall: Error starting call in callingx: ${call.cid}`, error);
|
|
82
|
+
const isOngoingCall = c => !c.ringing && CallingxModule.isOngoingCallsEnabled && !c.isOwnTracksLoopbackAllowed;
|
|
83
|
+
if (!isIncomingCall && !isOutcomingCall && !isOngoingCall(call)) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
const activeCallsToLeave = activeCalls.filter(c => c.cid !== call.cid && (c.ringing || isOngoingCall(c)) && c.state.callingState !== CallingState.LEFT);
|
|
88
|
+
for (const activeCall of activeCallsToLeave) {
|
|
89
|
+
logger.debug(`leaving currently-active-call:${activeCall.cid} before joining the call:${call.cid}`);
|
|
90
|
+
await activeCall.leave({
|
|
91
|
+
reason: 'cancel'
|
|
92
|
+
}).catch(e => {
|
|
93
|
+
logger.error(`failed to leave active call ${activeCall.cid}`, e);
|
|
94
|
+
});
|
|
94
95
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
const activeCallsToLeave = activeCalls.filter(c => c.cid !== call.cid && c.ringing && c.state.callingState !== CallingState.LEFT);
|
|
100
|
-
for (const activeCall of activeCallsToLeave) {
|
|
101
|
-
logger.debug(`leaving active call ${activeCall.cid} before joining ${call.cid}`);
|
|
102
|
-
await activeCall.leave({
|
|
103
|
-
reason: 'cancel'
|
|
104
|
-
}).catch(e => {
|
|
105
|
-
logger.error(`failed to leave active call ${activeCall.cid}`, e);
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
// Awaits native CallKit/Telecom registration before answering.
|
|
109
|
-
// Safe to call even if the call is already registered (e.g. from VoIP push) --
|
|
110
|
-
// iOS early-returns with no error, Android sends the registered broadcast.
|
|
111
|
-
const callDisplayName = getCallDisplayNameFromCall(call);
|
|
112
|
-
await CallingxModule.displayIncomingCall(call.cid,
|
|
113
|
-
// unique id for call
|
|
114
|
-
call.state.createdBy?.id ?? callDisplayName,
|
|
115
|
-
// handle for native call UI (prefer createdBy user id, fallback to call display name)
|
|
116
|
-
callDisplayName,
|
|
117
|
-
// display name for display in call screen
|
|
118
|
-
call.state.settings?.video?.enabled ?? false // is video call?
|
|
119
|
-
);
|
|
96
|
+
logger.debug(`joinCallingxCall: Joining call ${call.cid} isIncoming: ${isIncomingCall} isOutgoing: ${isOutcomingCall}`);
|
|
97
|
+
const callArgs = getCallingxCallArgs(call);
|
|
98
|
+
if (isIncomingCall) {
|
|
99
|
+
await CallingxModule.displayIncomingCall(...callArgs);
|
|
120
100
|
await CallingxModule.answerIncomingCall(call.cid);
|
|
121
|
-
}
|
|
122
|
-
|
|
101
|
+
} else {
|
|
102
|
+
await CallingxModule.startCall(...callArgs);
|
|
123
103
|
}
|
|
104
|
+
} catch (error) {
|
|
105
|
+
logger.error(`startCallingxCall: Error starting call in callingx: ${call.cid} isIncoming: ${isIncomingCall} isOutgoing: ${isOutcomingCall}`, error);
|
|
124
106
|
}
|
|
125
107
|
}
|
|
126
108
|
export async function endCallingxCall(call, reason) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Platform","getCallingxLibIfAvailable","CallingState","videoLoggerSystem","CallingxModule","getCallDisplayName","callMembers","participants","currentUserId","names","length","flatMap","member","user","id","name","participant","userId","find","sort","join","
|
|
1
|
+
{"version":3,"names":["Platform","getCallingxLibIfAvailable","CallingState","videoLoggerSystem","CallingxModule","getCallDisplayName","callMembers","participants","currentUserId","names","length","flatMap","member","user","id","name","participant","userId","find","sort","join","getCallingxCallArgs","call","callDisplayName","state","custom","display_name","members","cid","createdBy","settings","video","enabled","registerOutgoingCall","isSetup","isOwnTracksLoopbackAllowed","isOutcomingCall","ringing","isCreatedByMe","logger","getLogger","debug","startCall","error","joinCallingxCall","activeCalls","isIncomingCall","isOngoingCall","c","isOngoingCallsEnabled","activeCallsToLeave","filter","callingState","LEFT","activeCall","leave","reason","catch","e","callArgs","displayIncomingCall","answerIncomingCall","endCallingxCall","isCallTracked","endCallWithReason","wireAudioEngineSubscription","OS","unwireAudioEngineSubscription"],"sourceRoot":"../../../../../src","sources":["utils/internal/callingx/callingx.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA,SAASA,QAAQ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,CAAC,oDAAoD,CAAC;IAClErC,cAAc,CAAC6D,2BAA2B,CAAC,CAAC;EAC9C,CAAC,CAAC,OAAOtB,KAAK,EAAE;IACdJ,MAAM,CAACI,KAAK,CACV,+DAA+D,EAC/DA,KACF,CAAC;EACH;AACF;AAEA,OAAO,SAASwB,6BAA6BA,CAAA,EAAG;EAC9C,IAAI,CAAC/D,cAAc,IAAI,CAACA,cAAc,CAAC8B,OAAO,IAAIlC,QAAQ,CAACkE,EAAE,KAAK,KAAK,EAAE;IACvE;EACF;EACA,MAAM3B,MAAM,GAAGpC,iBAAiB,CAACqC,SAAS,CAAC,UAAU,CAAC;EAEtD,IAAI;IACFD,MAAM,CAACE,KAAK,CAAC,0DAA0D,CAAC;IACxErC,cAAc,CAAC+D,6BAA6B,CAAC,CAAC;EAChD,CAAC,CAAC,OAAOxB,KAAK,EAAE;IACdJ,MAAM,CAACI,KAAK,CACV,qEAAqE,EACrEA,KACF,CAAC;EACH;AACF","ignoreList":[]}
|
|
@@ -12,6 +12,20 @@ export const KEEP_CALL_ALIVE_HEADLESS_TASK_NAME = 'StreamVideoKeepCallAlive';
|
|
|
12
12
|
export const keepCallAliveCallRef = {
|
|
13
13
|
current: undefined
|
|
14
14
|
};
|
|
15
|
+
let resolveRunningTask;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Ends the currently running keep-alive headless task.
|
|
19
|
+
*
|
|
20
|
+
* The task's promise is app-provided (`foregroundService.android.taskToRun`) and by default never
|
|
21
|
+
* resolves, so stopping the native service alone would leave the task registered in
|
|
22
|
+
* `HeadlessJsTaskContext` forever - which keeps RN's timer choreographer callback posted for the
|
|
23
|
+
* rest of the process lifetime. Resolving it here lets React Native unwind the task properly.
|
|
24
|
+
*/
|
|
25
|
+
export const endKeepCallAliveHeadlessTask = () => {
|
|
26
|
+
resolveRunningTask?.();
|
|
27
|
+
resolveRunningTask = undefined;
|
|
28
|
+
};
|
|
15
29
|
function registerKeepCallAliveHeadlessTaskOnce() {
|
|
16
30
|
if (Platform.OS !== 'android') return;
|
|
17
31
|
AppRegistry.registerHeadlessTask(KEEP_CALL_ALIVE_HEADLESS_TASK_NAME, () => async data => {
|
|
@@ -33,10 +47,34 @@ function registerKeepCallAliveHeadlessTaskOnce() {
|
|
|
33
47
|
}
|
|
34
48
|
const config = StreamVideoRN.getConfig();
|
|
35
49
|
const taskToRun = config.foregroundService.android.taskToRun;
|
|
50
|
+
// A previous task (if any) must not keep hanging around.
|
|
51
|
+
endKeepCallAliveHeadlessTask();
|
|
52
|
+
const taskEnded = new Promise(resolve => {
|
|
53
|
+
resolveRunningTask = resolve;
|
|
54
|
+
});
|
|
55
|
+
const ownResolver = resolveRunningTask;
|
|
56
|
+
|
|
57
|
+
// React Native stops the foreground service as soon as the promise returned from here
|
|
58
|
+
// settles. `taskToRun` is app-provided and may resolve early - or immediately - so its
|
|
59
|
+
// completion must not end the keep-alive: that would drop the call's background protection
|
|
60
|
+
// while the call is still ongoing. The task's lifetime is owned by the SDK instead, and ends
|
|
61
|
+
// via endKeepCallAliveHeadlessTask() when the call is left.
|
|
62
|
+
(async () => {
|
|
63
|
+
try {
|
|
64
|
+
await taskToRun(call);
|
|
65
|
+
logger.debug('Keep-alive taskToRun completed, keeping the call alive until the call ends');
|
|
66
|
+
} catch (e) {
|
|
67
|
+
logger.error('Keep-alive headless task failed', e);
|
|
68
|
+
}
|
|
69
|
+
})();
|
|
36
70
|
try {
|
|
37
|
-
await
|
|
38
|
-
}
|
|
39
|
-
|
|
71
|
+
await taskEnded;
|
|
72
|
+
} finally {
|
|
73
|
+
// a newer task may already have installed its own resolver - clearing it here would leave
|
|
74
|
+
// that task with no way to be ended.
|
|
75
|
+
if (resolveRunningTask === ownResolver) {
|
|
76
|
+
resolveRunningTask = undefined;
|
|
77
|
+
}
|
|
40
78
|
}
|
|
41
79
|
});
|
|
42
80
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["AppRegistry","Platform","videoLoggerSystem","StreamVideoRN","KEEP_CALL_ALIVE_HEADLESS_TASK_NAME","keepCallAliveCallRef","current","undefined","registerKeepCallAliveHeadlessTaskOnce","OS","registerHeadlessTask","data","logger","getLogger","callCid","call","warn","cid","activeCallCid","config","getConfig","taskToRun","foregroundService","android","e","error"],"sourceRoot":"../../../src","sources":["utils/keepCallAliveHeadlessTask.ts"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,QAAQ,QAAQ,cAAc;AAEpD,SAASC,iBAAiB,QAAQ,yBAAyB;AAC3D,SAASC,aAAa,QAAQ,iBAAiB;AAE/C,OAAO,MAAMC,kCAAkC,GAAG,0BAA0B;;AAE5E;AACA;AACA;AACA;AACA,OAAO,MAAMC,oBAAmD,GAAG;EACjEC,OAAO,EAAEC;AACX,CAAC;AAED,
|
|
1
|
+
{"version":3,"names":["AppRegistry","Platform","videoLoggerSystem","StreamVideoRN","KEEP_CALL_ALIVE_HEADLESS_TASK_NAME","keepCallAliveCallRef","current","undefined","resolveRunningTask","endKeepCallAliveHeadlessTask","registerKeepCallAliveHeadlessTaskOnce","OS","registerHeadlessTask","data","logger","getLogger","callCid","call","warn","cid","activeCallCid","config","getConfig","taskToRun","foregroundService","android","taskEnded","Promise","resolve","ownResolver","debug","e","error"],"sourceRoot":"../../../src","sources":["utils/keepCallAliveHeadlessTask.ts"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,QAAQ,QAAQ,cAAc;AAEpD,SAASC,iBAAiB,QAAQ,yBAAyB;AAC3D,SAASC,aAAa,QAAQ,iBAAiB;AAE/C,OAAO,MAAMC,kCAAkC,GAAG,0BAA0B;;AAE5E;AACA;AACA;AACA;AACA,OAAO,MAAMC,oBAAmD,GAAG;EACjEC,OAAO,EAAEC;AACX,CAAC;AAED,IAAIC,kBAA4C;;AAEhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,4BAA4B,GAAGA,CAAA,KAAM;EAChDD,kBAAkB,GAAG,CAAC;EACtBA,kBAAkB,GAAGD,S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IAAI;MACF,MAAML,SAAS;IACjB,CAAC,SAAS;MACR;MACA;MACA,IAAIlB,kBAAkB,KAAKqB,WAAW,EAAE;QACtCrB,kBAAkB,GAAGD,SAAS;MAChC;IACF;EACF,CACF,CAAC;AACH;AAEAG,qCAAqC,CAAC,CAAC","ignoreList":[]}
|
|
@@ -47,6 +47,32 @@ export const onRingNotificationReceived = async data => {
|
|
|
47
47
|
nativeLog(`Finishing background task for callCid: ${call_cid}`);
|
|
48
48
|
callingx.releaseBackgroundTask(backgroundTaskOwner);
|
|
49
49
|
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Gives up on this push: dismisses the call the native push path already displayed, then asks
|
|
53
|
+
* the call service to stop. `stopService` is only a request — it no-ops while any other call is
|
|
54
|
+
* registered or being registered — so this call must be ended explicitly rather than relying on
|
|
55
|
+
* the service teardown to wipe it.
|
|
56
|
+
*/
|
|
57
|
+
const abandonPush = async () => {
|
|
58
|
+
if (asForegroundService) {
|
|
59
|
+
finishBackgroundTask();
|
|
60
|
+
}
|
|
61
|
+
// Each step is contained on its own: failing to dismiss the call must not skip the stop
|
|
62
|
+
// request, and neither may skip the unsubscription cleanup — a stale entry makes every later
|
|
63
|
+
// push for this cid look like a duplicate and get discarded.
|
|
64
|
+
try {
|
|
65
|
+
await callingx.endCallWithReason(call_cid, 'error');
|
|
66
|
+
} catch (error) {
|
|
67
|
+
nativeLog(`Failed to end call ${call_cid}: ${error}`, 'error');
|
|
68
|
+
}
|
|
69
|
+
try {
|
|
70
|
+
await callingx.stopService();
|
|
71
|
+
} catch (error) {
|
|
72
|
+
nativeLog(`Failed to stop the call service for ${call_cid}: ${error}`, 'error');
|
|
73
|
+
}
|
|
74
|
+
pushUnsubscriptionCallbacks.delete(call_cid);
|
|
75
|
+
};
|
|
50
76
|
if (asForegroundService) {
|
|
51
77
|
// initialize the callback array immediately to avoid race condition
|
|
52
78
|
pushUnsubscriptionCallbacks.set(call_cid, []);
|
|
@@ -62,21 +88,13 @@ export const onRingNotificationReceived = async data => {
|
|
|
62
88
|
client = await pushConfig.createStreamVideoClient();
|
|
63
89
|
if (!client) {
|
|
64
90
|
nativeLog(`video client not found, skipping the call.ring notification`);
|
|
65
|
-
|
|
66
|
-
finishBackgroundTask();
|
|
67
|
-
}
|
|
68
|
-
await callingx.stopService();
|
|
69
|
-
pushUnsubscriptionCallbacks.delete(call_cid);
|
|
91
|
+
await abandonPush();
|
|
70
92
|
return;
|
|
71
93
|
}
|
|
72
94
|
} catch (error) {
|
|
73
95
|
//we need to release the background task and stop the service to avoid stale owner
|
|
74
96
|
nativeLog(`Failed to create video client: ${error}`, 'error');
|
|
75
|
-
|
|
76
|
-
finishBackgroundTask();
|
|
77
|
-
}
|
|
78
|
-
await callingx.stopService();
|
|
79
|
-
pushUnsubscriptionCallbacks.delete(call_cid);
|
|
97
|
+
await abandonPush();
|
|
80
98
|
return;
|
|
81
99
|
}
|
|
82
100
|
if (asForegroundService) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CallingState","AppState","Platform","getCallingxLib","getCallingxLibIfAvailable","StreamVideoRN","pushUnsubscriptionCallbacks","canListenToWS","shouldCallBeClosed","onRingNotificationReceived","data","OS","nativeLog","message","level","log","pushConfig","getConfig","push","sender","type","call_cid","callingx","has","asForegroundService","backgroundTaskOwner","finishBackgroundTask","releaseBackgroundTask","
|
|
1
|
+
{"version":3,"names":["CallingState","AppState","Platform","getCallingxLib","getCallingxLibIfAvailable","StreamVideoRN","pushUnsubscriptionCallbacks","canListenToWS","shouldCallBeClosed","onRingNotificationReceived","data","OS","nativeLog","message","level","log","pushConfig","getConfig","push","sender","type","call_cid","callingx","has","asForegroundService","backgroundTaskOwner","finishBackgroundTask","releaseBackgroundTask","abandonPush","endCallWithReason","error","stopService","delete","set","acquireBackgroundTask","catch","e","client","createStreamVideoClient","callFromPush","onRingingCall","mustEndCall","endCallReason","leave","reject","unsubscribeFunctions","get","unsubscribe","on","event","_canListenToWS","forEach","fn","mustEndCallFromEvent","endCallReasonFromEvent","stateSubscription","state","callingState$","subscribe","callingState","IDLE","LEFT","appStateSubscription","addEventListener","nextAppState","remove"],"sourceRoot":"../../../../../src","sources":["utils/push/internal/android.ts"],"mappings":";;AAAA,SAGEA,YAAY,QAEP,yBAAyB;AAChC,SAASC,QAAQ,EAAEC,QAAQ,QAAQ,cAAc;AACjD,SAEEC,cAAc,EACdC,yBAAyB,QACpB,SAAS;AAChB,SAASC,aAAa,QAAQ,qBAAqB;AACnD,SAASC,2BAA2B,QAAQ,aAAa;AACzD,SAASC,aAAa,EAAEC,kBAAkB,QAAQ,SAAS;;AAE3D;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,0BAA0B,GAAG,MACxCC,IAAmC,IAChC;EACH;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,IAAIR,QAAQ,CAACS,EAAE,KAAK,SAAS,EAAE;EAE/B,MAAMC,SAAS,GAAGA,CAChBC,OAAe,EACfC,KAA0C,GAAG,OAAO,KAEpDV,yBAAyB,CAAC,CAAC,EAAEW,GAAG,CAC9B,4CAA4CF,OAAO,EAAE,EACrDC,KACF,CAAC;EAEH,MAAME,UAAU,GAAGX,aAAa,CAACY,SAAS,CAAC,CAAC,CAACC,IAAI;EACjD,IACE,CAACF,UAAU,IACX,CAACN,IAAI,IACLA,IAAI,CAACS,MAAM,KAAK,cAAc,IAC9BT,IAAI,CAACU,IAAI,KAAK,WAAW,EACzB;IACA;EACF;EAEA,MAAMC,QAAQ,GAAGX,IAAI,CAACW,QAAkB;EACxC,MAAMC,QAAQ,GAAGnB,cAAc,CAAC,CAAC;EAEjC,IAAIG,2BAA2B,CAACiB,GAAG,CAACF,QAAQ,CAAC,EAAE;IAC7CT,SAAS,CACP,YAAYS,QAAQ,0EACtB,CAAC;IACD;EACF;EAEA,MAAMG,mBAAmB,GAAGjB,aAAa,CAAC,CAAC;EAC3C,MAAMkB,mBAAmB,GAAG,QA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,KAAK,CAAC;MAAEC,MAAM,EAAE;IAAM,CAAC,CAAC,CAACT,KAAK,CAAEL,KAAK,IAAK;MACrDlB,SAAS,CACP,8CAA8CS,QAAQ,KAAKS,KAAK,EAAE,EAClE,OACF,CAAC;IACH,CAAC,CAAC;EACJ;AACF,CAAC","ignoreList":[]}
|
package/dist/module/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["version"],"sourceRoot":"../../src","sources":["version.ts"],"mappings":";;AAAA,OAAO,MAAMA,OAAO,GAAG,
|
|
1
|
+
{"version":3,"names":["version"],"sourceRoot":"../../src","sources":["version.ts"],"mappings":";;AAAA,OAAO,MAAMA,OAAO,GAAG,cAAc","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCallingExpWithCallingStateEffect.d.ts","sourceRoot":"","sources":["../../../../src/hooks/push/useCallingExpWithCallingStateEffect.ts"],"names":[],"mappings":"AAWA;;GAEG;AACH,eAAO,MAAM,mCAAmC,
|
|
1
|
+
{"version":3,"file":"useCallingExpWithCallingStateEffect.d.ts","sourceRoot":"","sources":["../../../../src/hooks/push/useCallingExpWithCallingStateEffect.ts"],"names":[],"mappings":"AAWA;;GAEG;AACH,eAAO,MAAM,mCAAmC,YA+R/C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAndroidKeepCallAliveEffect.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAndroidKeepCallAliveEffect.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useAndroidKeepCallAliveEffect.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAndroidKeepCallAliveEffect.ts"],"names":[],"mappings":"AAqGA;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,YA6IzC,CAAC"}
|
|
@@ -166,8 +166,7 @@ export type StreamVideoConfig = {
|
|
|
166
166
|
*/
|
|
167
167
|
notificationTexts: KeepAliveAndroidNotificationTexts;
|
|
168
168
|
/**
|
|
169
|
-
* The task to run in the foreground service
|
|
170
|
-
* The task must resolve a promise once complete
|
|
169
|
+
* The task to run in the foreground service.
|
|
171
170
|
*/
|
|
172
171
|
taskToRun: (call: Call) => Promise<void>;
|
|
173
172
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/utils/StreamVideoRN/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,oBAAoB,EACzB,iBAAiB,EACjB,KAAK,IAAI,EACV,MAAM,yBAAyB,CAAC;AAEjC,MAAM,MAAM,oBAAoB,GAAG;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,iCAAiC,GAAG;IAC9C,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAC7B,mBAAmB,GAAG,mBAAmB,GAAG,aAAa,CAAC;AAE5D,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;;;OAIG;IACH,IAAI,CAAC,EAAE;QACL;;WAEG;QACH,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB;;;;WAIG;QACH,cAAc,CAAC,EAAE,oBAAoB,CAAC;QAEtC,GAAG,CAAC,EAAE;YACJ;;;;eAIG;YACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;YAC1B,aAAa,CAAC,EAAE,OAAO,CAAC;YACxB;;;eAGG;YACH,KAAK,CAAC,EAAE,MAAM,CAAC;YACf;;;eAGG;YACH,SAAS,CAAC,EAAE,MAAM,CAAC;YACnB;;;eAGG;YACH,YAAY,CAAC,EAAE,OAAO,CAAC;YACvB;;;eAGG;YACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;YAC5B;;;eAGG;YACH,kBAAkB,CAAC,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AoB,CAAC;YACvC;;;;;;;;eAQG;YACH,iBAAiB,CAAC,EAAE;gBAClB,SAAS,CAAC,EAAE,MAAM,CAAC;gBACnB,SAAS,CAAC,EAAE,MAAM,CAAC;aACpB,CAAC;YACF;;eAEG;YACH,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,KAAK,MAAM,CAAC;YACrE,kBAAkB,CAAC,EAAE,OAAO,CAAC;YAC7B;;;;eAIG;YACH,4BAA4B,CAAC,EAAE,OAAO,CAAC;YACvC;;;eAGG;YACH,yBAAyB,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC;SACpD,CAAC;QACF;;;WAGG;QACH,wBAAwB,CAAC,EAAE,OAAO,CAAC;QACnC;;;;;;;;;;;;;;;;;WAiBG;QACH,uBAAuB,EAAE,MAAM,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC,CAAC;KACvE,CAAC;IACF,iBAAiB,EAAE;QACjB,OAAO,EAAE;YACP;;eAEG;YACH,OAAO,EAAE,IAAI,CAAC,oBAAoB,EAAE,OAAO,GAAG,WAAW,CAAC,CAAC;YAC3D;;eAEG;YACH,iBAAiB,EAAE,iCAAiC,CAAC;YACrD;;eAEG;YACH,SAAS,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;SAC1C,CAAC;KACH,CAAC;CACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"callingx.d.ts","sourceRoot":"","sources":["../../../../../src/utils/internal/callingx/callingx.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAEtE,OAAO,KAAK,EACV,IAAI,EACJ,cAAc,EACd,sBAAsB,EACvB,MAAM,yBAAyB,CAAC;AAKjC;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,cAAc,EAAE,GAAG,SAAS,EACzC,YAAY,EAAE,sBAAsB,EAAE,GAAG,SAAS,EAClD,aAAa,EAAE,MAAM,GAAG,SAAS,GAChC,MAAM,CAgCR;
|
|
1
|
+
{"version":3,"file":"callingx.d.ts","sourceRoot":"","sources":["../../../../../src/utils/internal/callingx/callingx.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAEtE,OAAO,KAAK,EACV,IAAI,EACJ,cAAc,EACd,sBAAsB,EACvB,MAAM,yBAAyB,CAAC;AAKjC;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,cAAc,EAAE,GAAG,SAAS,EACzC,YAAY,EAAE,sBAAsB,EAAE,GAAG,SAAS,EAClD,aAAa,EAAE,MAAM,GAAG,SAAS,GAChC,MAAM,CAgCR;AAsBD,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,IAAI,iBAyBpD;AAED;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,iBAoDrE;AAED,wBAAsB,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,aAAa,iBAmBvE;AAED,wBAAsB,2BAA2B,kBAehD;AAED,wBAAgB,6BAA6B,SAe5C"}
|
|
@@ -7,4 +7,13 @@ export declare const KEEP_CALL_ALIVE_HEADLESS_TASK_NAME = "StreamVideoKeepCallAl
|
|
|
7
7
|
export declare const keepCallAliveCallRef: {
|
|
8
8
|
current: Call | undefined;
|
|
9
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* Ends the currently running keep-alive headless task.
|
|
12
|
+
*
|
|
13
|
+
* The task's promise is app-provided (`foregroundService.android.taskToRun`) and by default never
|
|
14
|
+
* resolves, so stopping the native service alone would leave the task registered in
|
|
15
|
+
* `HeadlessJsTaskContext` forever - which keeps RN's timer choreographer callback posted for the
|
|
16
|
+
* rest of the process lifetime. Resolving it here lets React Native unwind the task properly.
|
|
17
|
+
*/
|
|
18
|
+
export declare const endKeepCallAliveHeadlessTask: () => void;
|
|
10
19
|
//# sourceMappingURL=keepCallAliveHeadlessTask.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keepCallAliveHeadlessTask.d.ts","sourceRoot":"","sources":["../../../src/utils/keepCallAliveHeadlessTask.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAIpD,eAAO,MAAM,kCAAkC,6BAA6B,CAAC;AAE7E;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE;IAAE,OAAO,EAAE,IAAI,GAAG,SAAS,CAAA;CAE7D,CAAC"}
|
|
1
|
+
{"version":3,"file":"keepCallAliveHeadlessTask.d.ts","sourceRoot":"","sources":["../../../src/utils/keepCallAliveHeadlessTask.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAIpD,eAAO,MAAM,kCAAkC,6BAA6B,CAAC;AAE7E;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE;IAAE,OAAO,EAAE,IAAI,GAAG,SAAS,CAAA;CAE7D,CAAC;AAIF;;;;;;;GAOG;AACH,eAAO,MAAM,4BAA4B,YAGxC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"android.d.ts","sourceRoot":"","sources":["../../../../../src/utils/push/internal/android.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,KAAK,qBAAqB,EAG3B,MAAM,SAAS,CAAC;AAKjB;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,GACrC,MAAM,qBAAqB,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"android.d.ts","sourceRoot":"","sources":["../../../../../src/utils/push/internal/android.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,KAAK,qBAAqB,EAG3B,MAAM,SAAS,CAAC;AAKjB;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,GACrC,MAAM,qBAAqB,CAAC,MAAM,CAAC,kBA0PpC,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "
|
|
1
|
+
export declare const version = "2.0.0-beta.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,iBAAiB,CAAC"}
|
|
@@ -15,7 +15,7 @@ const withStreamVideoReactNativeSDKAndroidPermissions = (configuration, props) =
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
if (props?.androidKeepCallAlive) {
|
|
18
|
-
permissions.push('android.permission.FOREGROUND_SERVICE_CAMERA', 'android.permission.FOREGROUND_SERVICE_MICROPHONE', 'android.permission.
|
|
18
|
+
permissions.push('android.permission.FOREGROUND_SERVICE_CAMERA', 'android.permission.FOREGROUND_SERVICE_MICROPHONE', 'android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK');
|
|
19
19
|
}
|
|
20
20
|
const config = config_plugins_1.AndroidConfig.Permissions.withPermissions(configuration, permissions);
|
|
21
21
|
return config;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stream-io/video-react-native-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-beta.0",
|
|
4
4
|
"description": "Stream Video SDK for React Native",
|
|
5
5
|
"author": "https://getstream.io",
|
|
6
6
|
"homepage": "https://getstream.io/video/docs/react-native/",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"!**/.*"
|
|
53
53
|
],
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@stream-io/video-client": "
|
|
56
|
-
"@stream-io/video-react-bindings": "
|
|
55
|
+
"@stream-io/video-client": "2.0.0-beta.0",
|
|
56
|
+
"@stream-io/video-react-bindings": "2.0.0-beta.0",
|
|
57
57
|
"intl-pluralrules": "2.0.1",
|
|
58
58
|
"react-native-url-polyfill": "^3.0.0",
|
|
59
59
|
"rxjs": "~7.8.2",
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
"@react-native/jest-preset": "0.86.2",
|
|
119
119
|
"@react-native/metro-config": "0.86.2",
|
|
120
120
|
"@stream-io/noise-cancellation-react-native": "^0.11.0",
|
|
121
|
-
"@stream-io/react-native-callingx": "^0.11.
|
|
121
|
+
"@stream-io/react-native-callingx": "^0.11.1",
|
|
122
122
|
"@stream-io/react-native-webrtc": "145.3.1",
|
|
123
123
|
"@stream-io/typescript-config": "^0.0.0",
|
|
124
124
|
"@stream-io/video-filters-react-native": "^0.16.0",
|
|
@@ -112,12 +112,19 @@ export const useCallingExpWithCallingStateEffect = () => {
|
|
|
112
112
|
return;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
callingx
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
115
|
+
callingx
|
|
116
|
+
.updateDisplay(
|
|
117
|
+
activeCallCid,
|
|
118
|
+
createdByUserId ?? callDisplayName,
|
|
119
|
+
callDisplayName,
|
|
120
|
+
isIncoming,
|
|
121
|
+
)
|
|
122
|
+
.catch((error: unknown) => {
|
|
123
|
+
logger.debug(
|
|
124
|
+
`useCallingExpWithCallingStateEffect: Error updating display in callingx: ${activeCallCid}`,
|
|
125
|
+
error,
|
|
126
|
+
);
|
|
127
|
+
});
|
|
121
128
|
}, [activeCallCid, createdByUserId, callDisplayName, isIncoming]);
|
|
122
129
|
|
|
123
130
|
// Sync microphone mute state from app → CallKit
|
|
@@ -9,7 +9,10 @@ import {
|
|
|
9
9
|
Platform,
|
|
10
10
|
} from 'react-native';
|
|
11
11
|
import { CallingState, videoLoggerSystem } from '@stream-io/video-client';
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
endKeepCallAliveHeadlessTask,
|
|
14
|
+
keepCallAliveCallRef,
|
|
15
|
+
} from '../utils/keepCallAliveHeadlessTask';
|
|
13
16
|
import { getCallingxLibIfAvailable } from '../utils/push/libs';
|
|
14
17
|
|
|
15
18
|
async function stopForegroundServiceNoThrow() {
|
|
@@ -21,7 +24,10 @@ async function stopForegroundServiceNoThrow() {
|
|
|
21
24
|
}
|
|
22
25
|
}
|
|
23
26
|
|
|
24
|
-
|
|
27
|
+
/**
|
|
28
|
+
* @returns true when the native foreground service was asked to start.
|
|
29
|
+
*/
|
|
30
|
+
async function startForegroundService(call_cid: string): Promise<boolean> {
|
|
25
31
|
const logger = videoLoggerSystem.getLogger('startForegroundService');
|
|
26
32
|
const isCallAliveConfigured = await (async () => {
|
|
27
33
|
try {
|
|
@@ -32,10 +38,14 @@ async function startForegroundService(call_cid: string) {
|
|
|
32
38
|
}
|
|
33
39
|
})();
|
|
34
40
|
if (!isCallAliveConfigured) {
|
|
35
|
-
logger.
|
|
36
|
-
'KeepCallAlive is not configured
|
|
41
|
+
logger.warn(
|
|
42
|
+
'KeepCallAlive is not configured, the call will not survive the app going to the ' +
|
|
43
|
+
'background: audio publishing stops and the user is eventually dropped from the call. ' +
|
|
44
|
+
'Declare android.permission.FOREGROUND_SERVICE and ' +
|
|
45
|
+
'android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK in the app manifest (see logcat, ' +
|
|
46
|
+
'tag StreamVideoReactNative, for the exact list of missing permissions).',
|
|
37
47
|
);
|
|
38
|
-
return;
|
|
48
|
+
return false;
|
|
39
49
|
}
|
|
40
50
|
// Check for notification permission (Android 13+) before starting the service.
|
|
41
51
|
const hasPostNotificationsPermission =
|
|
@@ -47,7 +57,7 @@ async function startForegroundService(call_cid: string) {
|
|
|
47
57
|
logger.info(
|
|
48
58
|
'Notification permission not granted, can not start foreground service to keep the call alive',
|
|
49
59
|
);
|
|
50
|
-
return;
|
|
60
|
+
return false;
|
|
51
61
|
}
|
|
52
62
|
const videoConfig = StreamVideoRN.getConfig();
|
|
53
63
|
const foregroundServiceConfig = videoConfig.foregroundService;
|
|
@@ -58,19 +68,34 @@ async function startForegroundService(call_cid: string) {
|
|
|
58
68
|
// NOTE: we use requestAnimationFrame to ensure that the foreground service is started after all the current UI operations are done
|
|
59
69
|
// this is a workaround for the crash - android.app.RemoteServiceException$ForegroundServiceDidNotStartInTimeException: Context.startForegroundService() did not then call Service.startForeground()
|
|
60
70
|
// this crash was reproducible only in some android devices
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
return new Promise<boolean>((resolve) => {
|
|
72
|
+
requestAnimationFrame(async () => {
|
|
73
|
+
// The service declares the camera/microphone foreground service types, which are
|
|
74
|
+
// while-in-use permissions: Android requires startForegroundService() to be called while the
|
|
75
|
+
// app has a visible activity, otherwise the start is rejected. The frame we deferred to can
|
|
76
|
+
// land after the app left the foreground, so re-check before calling native.
|
|
77
|
+
if (AppState.currentState !== 'active') {
|
|
78
|
+
logger.info(
|
|
79
|
+
'App is no longer in the foreground, not starting the keep-call-alive foreground service',
|
|
80
|
+
);
|
|
81
|
+
resolve(false);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
await NativeModules.StreamVideoReactNative.startKeepCallAliveService(
|
|
86
|
+
call_cid,
|
|
87
|
+
channel.id,
|
|
88
|
+
channel.name,
|
|
89
|
+
notificationTexts.title,
|
|
90
|
+
notificationTexts.body,
|
|
91
|
+
smallIconName ?? null,
|
|
92
|
+
);
|
|
93
|
+
resolve(true);
|
|
94
|
+
} catch (e) {
|
|
95
|
+
logger.warn('Failed to start keep-call-alive foreground service', e);
|
|
96
|
+
resolve(false);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
74
99
|
});
|
|
75
100
|
}
|
|
76
101
|
|
|
@@ -147,8 +172,18 @@ export const useAndroidKeepCallAliveEffect = () => {
|
|
|
147
172
|
return;
|
|
148
173
|
}
|
|
149
174
|
|
|
150
|
-
|
|
151
|
-
|
|
175
|
+
try {
|
|
176
|
+
// only mark as started when native actually accepted the start, so that a later render
|
|
177
|
+
// while still joined can retry.
|
|
178
|
+
foregroundServiceStartedRef.current =
|
|
179
|
+
await startForegroundService(activeCallCid);
|
|
180
|
+
} catch (e) {
|
|
181
|
+
// run() is intentionally not awaited, so anything thrown here would surface as an
|
|
182
|
+
// unhandled rejection. Leave the ref false so a later render can retry.
|
|
183
|
+
videoLoggerSystem
|
|
184
|
+
.getLogger('useAndroidKeepCallAliveEffect')
|
|
185
|
+
.warn('Failed to start the keep-call-alive foreground service', e);
|
|
186
|
+
}
|
|
152
187
|
};
|
|
153
188
|
|
|
154
189
|
// ensure that app is active before running the function
|
|
@@ -170,6 +205,8 @@ export const useAndroidKeepCallAliveEffect = () => {
|
|
|
170
205
|
} else if (isCallEnded) {
|
|
171
206
|
if (foregroundServiceStartedRef.current) {
|
|
172
207
|
keepCallAliveCallRef.current = undefined;
|
|
208
|
+
// let the headless task resolve so RN unwinds it, then stop the foreground service
|
|
209
|
+
endKeepCallAliveHeadlessTask();
|
|
173
210
|
// stop foreground service when the call is not active
|
|
174
211
|
stopForegroundServiceNoThrow();
|
|
175
212
|
foregroundServiceStartedRef.current = false;
|
|
@@ -188,6 +225,7 @@ export const useAndroidKeepCallAliveEffect = () => {
|
|
|
188
225
|
// stop foreground service when this effect is unmounted
|
|
189
226
|
if (foregroundServiceStartedRef.current) {
|
|
190
227
|
keepCallAliveCallRef.current = undefined;
|
|
228
|
+
endKeepCallAliveHeadlessTask();
|
|
191
229
|
stopForegroundServiceNoThrow();
|
|
192
230
|
foregroundServiceStartedRef.current = false;
|
|
193
231
|
}
|