Comments (2)
Hi @hsandhu, thanks for your message!
This is normal behavior because when app is in background, code is executed independently of React context.
When you are calling handleBackgroundState, messaging().setBackgroundMessageHandler
is registering a headless JS task. The task code is independent and has no access to React context (this context does not even exist since app is in background).
But you can still listen to CallConnected
event within that function. You could copy handleBackgroundState and write something like:
import messaging from '@react-native-firebase/messaging';
import { AppRegistry, Platform } from 'react-native';
import RNCallKeep from 'react-native-callkeep';
import {
RNTwilioPhone,
TwilioPhone,
twilioPhoneEmitter,
} from 'react-native-twilio-phone';
import { name as appName } from './app.json';
import { App } from './src/App';
function handleBackgroundState() {
if (Platform.OS !== 'android') {
return;
}
messaging().setBackgroundMessageHandler(async (remoteMessage) => {
if (!remoteMessage.data) {
return;
}
RNCallKeep.registerPhoneAccount();
RNCallKeep.registerAndroidEvents();
RNCallKeep.setAvailable(true);
RNTwilioPhone.listenTwilioPhone(); // Listen to events after this line because listeners are removed here
RNTwilioPhone.listenCallKeep();
// Here you can listen to events and do what you want
twilioPhoneEmitter.addListener('CallConnected', (data) => {
console.log(data);
})
TwilioPhone.handleMessage(remoteMessage.data);
});
}
handleBackgroundState();
AppRegistry.registerComponent(appName, () => App);
from react-native-twilio-phone.
@MrHertal this is really helpful and makes sense, thank you!
from react-native-twilio-phone.
Related Issues (20)
- Upgrade ios and android Twilio SDK's to support Umatilla Oregon public edge HOT 1
- Hangup does not work HOT 2
- Video call HOT 1
- two simultaneous calls cause a crash
- Incoming call not working on ios with adhoc profile with voip certificate
- End call listener gets call automatically of RNCallKeep for android when app is in active(foreground and background) both) HOT 2
- The incoming phone call can not connect when app has been killed HOT 1
- incoming call automatic disconnect if android app is in forground.
- Caller is not able to end the call HOT 1
- How to send my own UUID? HOT 2
- Android: Not able to accept the call when call is coming in kill/background state
- can we get call uuid when ringing
- Hide my app name prompt in dialer for outgoing calls
- Official Twilio Voice React Native SDK HOT 2
- End call button doesn't work HOT 4
- Dial screen does not appear
- Unable to import HOT 1
- Failed to transform voice-android-6.0.7.aar
- Not able to accept the call when app is killed [iOS] HOT 5
- If I receive an incoming call while the application is open, I do not want to display the notification. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-twilio-phone.