Skip to content

Additional improvements in headless mode #226

@jpudysz

Description

@jpudysz

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 take callUUID 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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions