react-native-webrtc / react-native-callkeep

iOS CallKit framework and Android ConnectionService for React Native
ISC License
884 stars 431 forks source link

backToForeground() Android 11 (Xiaomi K20 pro) do nothing #477

Open vohoangankhanh opened 2 years ago

vohoangankhanh commented 2 years ago

Bug report

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
TirathBhuva commented 2 years ago

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

Doma-byte commented 1 month ago

Sorry, but according to the official documentation, backToForeground method is only availble for Android not for IOS