react-native-callkeep
react-native-callkeep copied to clipboard
backToForeground() Android 11 (Xiaomi K20 pro) do nothing
Bug report
-
[ ] I've checked the example to reproduce the issue.
-
Reproduced on:
-
[x ] Android
-
[ ] iOS
Description
When app is in background & killed. The app received message from Firebase and I run RNCallKeep setup then RNCallKeep set active true, and RN.backToForeground() but nothing happens
Steps to Reproduce
import messaging from '@react-native-firebase/messaging'; import {AppRegistry} from 'react-native'; import {isAndroid} from 'react-native-modalize/lib/utils/devices';
import {name as appName} from './app.json'; import App from './src/App'; import {handleRemoteMessage} from './src/screens/WithStringeeClient';
isAndroid && messaging().setBackgroundMessageHandler(async remoteMessage => { handleRemoteMessage(remoteMessage); }); AppRegistry.registerComponent(appName, () => App);
in App.js
function setupCallKeep() { isAndroid && RNCallKeep.setup({ android: { alertTitle: 'Permissions required', alertDescription: 'This application needs to access your phone accounts', cancelButton: 'Cancel', okButton: 'ok', imageName: 'ic_launcher', selfManaged: false, foregroundService: { channelId: 'channelId', channelName: 'channelName', notificationTitle: 'notificationTitle', }, }, }); RNCallKeep.setAvailable(true); RNCallKeep.backToForeground(); } export function handleRemoteMessage(remoteMessage) { const data = JSON.parse(remoteMessage.data.data); const callStatus = data.callStatus; const from = data.from.number; if (callStatus === 'started') { try { setupCallKeep(); } catch (e) { console.log('initializeCallKeep error: ' + e.message); } } else if (callStatus === 'ended') { RNCallKeep.endAllCalls(); } }
Versions
- Callkeep: 4.2.0
- React Native: 0.64.2
- iOS:
- Android: 11
- Phone model: Xiaomi k20 pro
Logs
Paste here
hey, I was also stuck in the same issue the background to foreground used to work for all other devices but was not working for MI devices. In my case, this was happening because of not enabling Display pop-up windows while running in the background permission. You can refer to this thread on StackOverflow for more detail