Closed
Description
Hello, I would like to create PR with additional improvements related to headless mode. Before I create PR please let me know if it's needed. My previous PR (#221 ) was left without any response so I'm trying to implement needed features on my fork and I can share them with community.
But let's go back to new improvements:
I took code from @manuquentin (#223) and added a few changes:
- I left old functionality of
backToForeground
, just added improvement for silent fail in the headless mode - I introduced a new method
openAppFromHeadlessMode
which can takecallUUID
and saves it - Whenever we want (especially after a cold boot) we can use another method
getExtrasFromHeadlessMode
and redirect to user's call UI
With this PR we would be able to drop additional dependency like react-native-invoke-app
.
Demo:
messaging().setBackgroundMessageHandler(async notificaiton => {
return startCallFromBackgroundAndroid(notificaiton.data, headlessMode)
})
const startCallFromBackgroundAndroid = (payload, isHeadless) => {
// setup RNCallKeep
// set available
RNCallKeep.addEventListener('answerCall', ({ callUUID }) => {
RNCallKeep.openAppFromHeadlessMode(callUUID)
})
}
// Later eg. after navigation did mount:
useAsyncEffect(async () => {
const extras = await RNCallKeep.getExtrasFromHeadlessMode()
if (extras) {
navigation.navigate(ScreenNames.CallScreen, {
roomUUID: extras.callUUID
})
}
}, [])
Metadata
Metadata
Assignees
Labels
No labels