Event Listeners are not called on JS side, even when Events are emitted from Native Emitter on iOS.
Bug report
-
[x] I've checked the example to reproduce the issue. https://github.com/react-native-webrtc/react-native-callkeep/issues/432
-
Reproduced on:
-
[ ] Android
-
[x] iOS
Description
We are building a calling feature for iOS App.
I was not getting any events from CallKeep, not even DidDisplayIncomingCall.
I tried creating a fresh app from scratch and tried installing CallKeep in it. It works perfectly fine.
However, it is still not working with our setup. I debugged the Native side using Xcode and found out that the Native side is perfectly fine and sending events.
Step 1
So I used the following snippet in App.js (before component declaration) to see if the event is getting through.
import {NativeEventEmitter, NativeModules} from 'react-native';
const eventEmitter = new NativeEventEmitter(NativeModules.RNCallKeep);
const customListener = eventEmitter.addListener(
'RNCallKeepDidDisplayIncomingCall',
data => {
console.log('RNCallKeepDidDisplayIncomingCall2', data);
},
);
console.log('P: index.js:26 : customListener', customListener);
After this, when calling RNCallKeep.displayIncomingCall, this got logged from the listener I added above.
RNCallKeepDidDisplayIncomingCall2 {"callUUID": "3a1ca95e-2d29-451b-8297-f7d6a74bb0d7", "error": "", "fromPushKit": "0", "handle": "@pankajvaghela", "hasVideo": "0", "localizedCallerName": "pankaj", "payload": "", "supportsDTMF": "1", "supportsGrouping": "1", "supportsHolding": "1", "supportsUngrouping": "1"}
However, the callback in RNCallKeep.addEventListener('didReceiveStartCallAction', callback) never gets called.
Step 2
Then I checked the didDisplayIncomingCall function in actions.js and see if callback in there ever gets called, it never does.
I logged out listener objects returned from addListener returned by eventEmitter.addListener outside of the library(inside App.js) and inside the library (action.js file of CallKeep). They are similar for the most part except for some keys at the end.
Listener object when added From App :
{"context": undefined, "emitter": {"_disableCallsIntoModule": false, "_nativeModule": {"_startCallActionEventListenerAdded": [Function nonPromiseMethodWrapper], "addListener": [Function nonPromiseMethodWrapper], "answerIncomingCall": [Function nonPromiseMethodWrapper], "checkIfBusy": [Function promiseMethodWrapper], "checkSpeaker": [Function promiseMethodWrapper], "displayIncomingCall": [Function nonPromiseMethodWrapper], "endAllCalls": [Function nonPromiseMethodWrapper], "endCall": [Function nonPromiseMethodWrapper], "getAudioRoutes": [Function promiseMethodWrapper], "getCalls": [Function promiseMethodWrapper], "getConstants": [Function anonymous], "getInitialEvents": [Function promiseMethodWrapper], "isCallActive": [Function promiseMethodWrapper], "removeListeners": [Function nonPromiseMethodWrapper], "reportConnectedOutgoingCallWithUUID": [Function nonPromiseMethodWrapper], "reportConnectingOutgoingCallWithUUID": [Function nonPromiseMethodWrapper], "reportEndCallWithUUID": [Function nonPromiseMethodWrapper], "reportUpdatedCall": [Function nonPromiseMethodWrapper], "sendDTMF": [Function nonPromiseMethodWrapper], "setAudioRoute": [Function promiseMethodWrapper], "setMutedCall": [Function nonPromiseMethodWrapper], "setOnHold": [Function nonPromiseMethodWrapper], "setup": [Function nonPromiseMethodWrapper], "startCall": [Function nonPromiseMethodWrapper], "updateDisplay": [Function nonPromiseMethodWrapper]}, "_subscriber": {"_currentSubscription": null, "_subscriptionsForType": [Object]}}, "eventType": "RNCallKeepDidDisplayIncomingCall", "key": 0, "listener": [Function anonymous], "subscriber": {"_currentSubscription": null, "_subscriptionsForType": {"RCTDevMenuShown": [Array], "RNCallKeepDidDisplayIncomingCall": [Array], "appStateDidChange": [Array], "appearanceChanged": [Array], "collectBugExtraData": [Array], "collectRedBoxExtraData": [Array], "didUpdateDimensions": [Array], "keyboardWillChangeFrame": [Array], "rnfb_auth_id_token_changed": [Array], "rnfb_auth_state_changed": [Array], "rnfb_dynamic_links_link_received": [Array], "rnfb_firestore_collection_sync_event": [Array], "rnfb_firestore_document_sync_event": [Array], "rnfb_firestore_transaction_event": [Array], "rnfb_messaging_message_deleted": [Array], "rnfb_messaging_message_received": [Array], "rnfb_messaging_message_received_background": [Array], "rnfb_messaging_message_send_error": [Array], "rnfb_messaging_message_sent": [Array], "rnfb_messaging_notification_opened": [Array], "rnfb_messaging_token_refresh": [Array], "rnfb_phone_auth_state_changed": [Array], "toggleElementInspector": [Array], "url": [Array], "websocketClosed": [Array], "websocketFailed": [Array], "websocketMessage": [Array], "websocketOpen": [Array]}}}
Listener object when added From Library :
{"context": undefined, "emitter": {"_disableCallsIntoModule": false, "_nativeModule": {"_startCallActionEventListenerAdded": [Function nonPromiseMethodWrapper], "addListener": [Function nonPromiseMethodWrapper], "answerIncomingCall": [Function nonPromiseMethodWrapper], "checkIfBusy": [Function promiseMethodWrapper], "checkSpeaker": [Function promiseMethodWrapper], "displayIncomingCall": [Function nonPromiseMethodWrapper], "endAllCalls": [Function nonPromiseMethodWrapper], "endCall": [Function nonPromiseMethodWrapper], "getAudioRoutes": [Function promiseMethodWrapper], "getCalls": [Function promiseMethodWrapper], "getConstants": [Function anonymous], "getInitialEvents": [Function promiseMethodWrapper], "isCallActive": [Function promiseMethodWrapper], "removeListeners": [Function nonPromiseMethodWrapper], "reportConnectedOutgoingCallWithUUID": [Function nonPromiseMethodWrapper], "reportConnectingOutgoingCallWithUUID": [Function nonPromiseMethodWrapper], "reportEndCallWithUUID": [Function nonPromiseMethodWrapper], "reportUpdatedCall": [Function nonPromiseMethodWrapper], "sendDTMF": [Function nonPromiseMethodWrapper], "setAudioRoute": [Function promiseMethodWrapper], "setMutedCall": [Function nonPromiseMethodWrapper], "setOnHold": [Function nonPromiseMethodWrapper], "setup": [Function nonPromiseMethodWrapper], "startCall": [Function nonPromiseMethodWrapper], "updateDisplay": [Function nonPromiseMethodWrapper]}, "_subscriber": {"_currentSubscription": null, "_subscriptionsForType": [Object]}}, "eventType": "RNCallKeepDidDisplayIncomingCall", "key": 0, "listener": [Function anonymous], "subscriber": {"_currentSubscription": null, "_subscriptionsForType": {"RNCallKeepDidDisplayIncomingCall": [Array], "RNCallKeepDidPerformDTMFAction": [Array], "RNCallKeepDidPerformSetMutedCallAction": [Array], "RNCallKeepDidReceiveStartCallAction": [Array], "RNCallKeepPerformAnswerCallAction": [Array], "RNCallKeepPerformEndCallAction": [Array], "didUpdateDimensions": [Array]}}}
Notes:
- RNCallKeep.setup() was called before addEventListener
Following issues might be related to this.
- https://github.com/react-native-webrtc/react-native-callkeep/issues/509
- https://github.com/react-native-webrtc/react-native-callkeep/issues/511
- https://github.com/react-native-webrtc/react-native-callkeep/issues/432
- https://github.com/react-native-webrtc/react-native-callkeep/issues/330
- https://github.com/react-native-webrtc/react-native-callkeep/issues/406
Steps to Reproduce
Tried Reproducing this one new project, but it's working fine in a new project.
Versions
- Callkeep: 4.3.1
- React Native: 0.64.2
- iOS: 12.5.1
- Android:
- Phone model: iPhone 7
Logs
I think this could be the fix, I copied it from @Jerome91410 and from some other forks:
https://github.com/react-native-webrtc/react-native-callkeep/compare/master...brekekesoftware:master#diff-fb7096e5e7c153e684bb8a0e67377a672fdd64202a57e3b4cb7abb57199d99c7
@namnm The link you posted isn"t working for me. Can you direct me towards the commit in question where the fix can be found?
any word on this? experiencing the same
I've experienced this after reloading the app (reloading in metro bundler, not killing the app).