react-native-callkeep icon indicating copy to clipboard operation
react-native-callkeep copied to clipboard

backToForeground not working on android 10 but 9 is fine

Open Solumation opened this issue 4 years ago • 6 comments

Bug report

  • On android 10 (huawei p30 pro), the call ui appears when the app is open, closed and the phone is closed but the app is not brought forward. Works (ui and app opening) on android 9 (lg v30).

  • Reproduced on:

  • [x] Android

  • [ ] iOS

Description

The ui for the call works really well but the app is not brought forward on android like it does on android 9.

Steps to Reproduce

The console in the setBackgroundMessageHandler() and onMessage(0 appears in the console. For android 9 the backToForeground() clearly works.

// Watcher for incoming firebase messages when the app is closed
messaging().setBackgroundMessageHandler(async remoteMessage => {
  RNCallKeep.backToForeground();
  const getNewUuid = () => uuid.v4().toLowerCase();
  const callUUID = getNewUuid().toLowerCase();
  RNCallKeep.displayIncomingCall(callUUID, remoteMessage.data.name || "N/A", "Nita Waiting Room", 'generic', false);

  useIncommingFirebaseMessages(remoteMessage.data);
});

// Watcher for incoming firebase messages when the app is open
messaging().onMessage(async remoteMessage => {
  RNCallKeep.backToForeground();
  const getNewUuid = () => uuid.v4().toLowerCase();
  const callUUID = getNewUuid().toLowerCase();

  RNCallKeep.displayIncomingCall(callUUID, remoteMessage.data.name || "N/A", "Nita Waiting Room", 'generic', false);

  useIncommingFirebaseMessages(remoteMessage.data);
});
const useIncommingFirebaseMessages = (callData: any) => {
  const getNewUuid = () => uuid.v4().toLowerCase();
  const callUUID = getNewUuid();

  const answerCall = ({ callUUID }) => {
    hangup(callUUID)
    RootNavigation.navigate('CallPage', {
      callFromNotification: true
    });
  };

  // Click cancel incoming call
  const endCall = async ({ callUUID }) => {
    return false;

  };

  const hangup = (callUUID: any) => {
    RNCallKeep.endCall(callUUID);
    return true
  };

  RNCallKeep.addEventListener('answerCall', answerCall);
  RNCallKeep.addEventListener('endCall', endCall);

  return false
}

Versions

- Callkeep: 3.1.4
- React Native: 62.2
- iOS: -
- Android: 10 / 9
- Phone model: huawei p30 pro / lg v30

Solumation avatar Sep 21 '21 03:09 Solumation

It works for me in Android 11, and as stated does not work on Android 10. Any solution for this?

azhararmar avatar Oct 06 '21 08:10 azhararmar

Android 10 11 12 same problem. When app killed, headless.js fired with slient notification but no call ui, app don't open.

e-vural avatar Jun 13 '22 18:06 e-vural

Starting from Android 10, it seems ilke google has restricted opening app from background activity. It is recommended to use notification to replace it though.

faustaleonardo avatar Jul 14 '22 10:07 faustaleonardo

Android 10 11 12 same problem. When app killed, headless.js fired with slient notification but no call ui, app don't open.

There is a solution. Follow that link

https://github.com/react-native-webrtc/react-native-callkeep/pull/576/commits/5e465fa776094091792d0bcd1c50f8dc70c9b217

That solution not in current released version. You must add own. That works for me in Android 10-11-12.

e-vural avatar Jul 21 '22 11:07 e-vural

still not working on Android 11, RN callkeep v4.3.6 which already includes 5e465fa

Dat-Mobile avatar Feb 07 '23 09:02 Dat-Mobile

still not working on Android 11, RN callkeep v4.3.6 which already includes 5e465fa

Same issue. Have you found solution yet? Thank you for responding.

anhquangtech avatar Jul 17 '23 08:07 anhquangtech