react-native-callkeep: backToForeground not working
Bug report
-
[ ✓] I’ve checked the example to reproduce the issue.
-
Reproduced on:
-
[✓ ] Android
-
iOS
Description
backToForeground does not invoke the app when the app is in background or quit state
Steps to Reproduce
I have following code in index.js
const options = {
ios: {
appName: 'App Name',
imageName: 'logo-trans'
},
android: {
alertTitle: 'Permissions required',
alertDescription: 'This application needs to access your phone accounts',
cancelButton: 'Cancel',
okButton: 'Ok',
}
};
RNCallKeep.setup(options);
messaging().setBackgroundMessageHandler(async remoteMessage => {
const { data } = remoteMessage;
if ('voip' === data?.type) {
RNCallKeep.backToForeground();
RNCallKeep.displayIncomingCall(data.uuid, data.handle, data.callerName);
return;
}
});
displayIncomingCall is invoked but RNCallKeep.backToForeground() does not do anything
Versions
- Callkeep: 4.2.0
- React Native: 0.61
- Android: 10
Logs
Paste here
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 15 (1 by maintainers)
Any update on this?
There seems to be a race condition if the app is already in the foreground when you answer the call.
Here is my understanding of what happens:
backToForeground()gets called – while the app is still in the foreground.This solutions is not elegant at all but worked for me:
This worked for me
try to enable this permission
Settings app > Other permissions > Display pop-up windows while running in the backgroundthis fixed in my case, Xiaomi 11 phone
Facing same issue and @glesperance’s workaround works.
I was already calling it in the answer call listener but didn’t work out.
I suppose we cannot call
backToForegroundbeforedisplayIncomingCallwhich I tried to do. Where I changed my approach mainly is to callbackToForegroundinanswerCalleventAny pointer here is really appreciated. No solution is working for me until now.