react-native-callkeep: [Android] "Activity doesn't exist" - Failed setup RNCallkeep in killed state

Bug report

  • I’ve checked the example to reproduce the issue.

  • Reproduced on: Emulator API 27, 28

  • Android

  • iOS

Description

I trying to use callkeep for voip incoming calls. Info about incoming call will arrive throught the “data-only” notification (FCM). After received notification (handled by headless task). I trying to initialize RNCallKeep.setup but It will throw the error “Activity doesn’t exist”.

Foreground and Background works fine.

Steps to Reproduce

  1. Kill the running application.
  2. Try to initialize RNCallKeep from headless task of FCM.

Versions

- Callkeep: "git+https://github.com/react-native-webrtc/react-native-callkeep.git"
- React Native: 0.63.4
- iOS: 14.5
- Android: API 27, 28
- Phone model: Pixel 2
- @react-native-firebase/messaging: "^11.4.1",

Logs

[Thu May 06 2021 19:14:03.596]  WARN     FCM remote message
[Thu May 06 2021 19:14:03.597]  LOG      {"nativeStackAndroid":[],"userInfo":null,"message":"Activity doesn't exist","code":"E_ACTIVITY_DOES_NOT_EXIST","line":2416,"column":45,"sourceURL":"http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false"}
[Thu May 06 2021 19:14:03.950]  LOG      Running "main" with {"rootTag":1}

Code implementation

// Registering headless task
messaging().setBackgroundMessageHandler(
           async (remoteMessage: RemoteMessage) => {
                console.warn('FCM remote message');
                await CallKeepServiceI.init();
                CallKeepServiceI.displayIncomingCall();
            }
);

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 17

Most upvoted comments

Hi react-native-callkeep not working If i kill the running application. Has anyone solved the problem?

You need to manually change RNCallKeepModule.java file after installing node modules. You need to alter the hasPermissions function like this https://github.com/react-native-webrtc/react-native-callkeep/pull/576/files.

After that, in your background message handler you call theese functions before calling RNCallKeep.displayIncmoingCall(cfg) await RNCallKeep.registerPhoneAccount(YOUR_CONFIG)

await RNCallKeep.registerAndroidEvents()

await RNCallKeep.setAvailable(true)

Don’t use the RNCallKeep.setup(options); in the background. Register manually with:

RNCallKeep.registerPhoneAccount();
RNCallKeep.registerAndroidEvents();
RNCallKeep.setAvailable(true);