react-native-callkeep icon indicating copy to clipboard operation
react-native-callkeep copied to clipboard

Sending `RNCallKeepDidChangeAudioRoute` with no listeners registered

Open sametcl2 opened this issue 3 years ago • 12 comments

Bug report

  • [x] I've checked the example to reproduce the issue.

  • Reproduced on:

  • [ ] Android

  • [x] iOS

Description

In iOS CallKit screen shows up. After answering call I got the error Sending RNCallKeepDidChangeAudioRoute with no listeners registered.

Steps to Reproduce

Versions

- Callkeep: 4.3.12
- React Native: 0.71.1
- iOS: 15.7
- Android:
- Phone model: iPhone 7

Logs

Sending `RNCallKeepDidChangeAudioRoute` with no listeners registered.

sametcl2 avatar Sep 29 '23 15:09 sametcl2

@sametcl2 I'm experiencing the same behavior, were you able to figure out why this happens?

stevenbdf avatar Oct 07 '23 01:10 stevenbdf

@sametcl2 I'm experiencing the same behavior, were you able to figure out why this happens?

I've added listener like this, top of the listeners useEffect, it seems like solved the problem for me.

RNCallKeep.addEventListener('didChangeAudioRoute', ({ output }) => { console.log('didChangeAudioRoute'); });

sametcl2 avatar Oct 10 '23 08:10 sametcl2

when I was using only react-native-webrtc, I did not see this warning. However, right after installing react-native-callkeep, I started seeing this warning message even though I did not modify any of the code yet.

geoffcfchen avatar Oct 11 '23 07:10 geoffcfchen

@sametcl2 I'm experiencing the same behavior, were you able to figure out why this happens?

I've added listener like this, top of the listeners useEffect, it seems like solved the problem for me.

RNCallKeep.addEventListener('didChangeAudioRoute', ({ output }) => { console.log('didChangeAudioRoute'); });

I'm sorry to say but this is not working :/ I really don't know why this is happening.

sametcl2 avatar Oct 16 '23 10:10 sametcl2

@geoffcfchen is this warning preventing trigger of answerCall event?

sametcl2 avatar Oct 18 '23 09:10 sametcl2

This issue happened on my end because I was answering a phone call in AppDelegate files before the RN code started. This was caused by me having setup VoIP in iOS native code, so I instead let the JS part handle the VoIP registration of the device. It added some delay than the previous solution but this warning went away and I was able to answer the call properly

stevenbdf avatar Oct 18 '23 14:10 stevenbdf

This issue happened on my end because I was answering a phone call in AppDelegate files before the RN code started. This was caused by me having setup VoIP in iOS native code, so I instead let the JS part handle the VoIP registration of the device. It added some delay than the previous solution but this warning went away and I was able to answer the call properly

Hi @stevenbdf thanks for your answer. How did you register in js side. Can you give me example please?

sametcl2 avatar Oct 19 '23 12:10 sametcl2

Hello @stevenbdf! Thank you for comment. I understand that iOS needs to run Callkeep as quickly as possible. Otherwise, I understand that the app will be terminated. In this situation, how can I use a method to launch Callkeep after the jsBundle is loaded without the app closing?

kr-yeon avatar Dec 12 '23 00:12 kr-yeon

Hello @stevenbdf! Thank you for comment. I understand that iOS needs to run Callkeep as quickly as possible. Otherwise, I understand that the app will be terminated. In this situation, how can I use a method to launch Callkeep after the jsBundle is loaded without the app closing?

I think that's the recommendation from iOS yes. But from what I was able to experiment in my app, it is not mandatory. I had to remove the voipRegistration from the delegate file and I simply initially RNCallkeep in my React Native code. It can be done inside a screen, provider or layout that you make sure it's rendered when your app is awaken from background mode. In my case I put and invoke the RNCallKeep.setup(callKeepOptions) in a navigation Provider that's only rendered when the user is logged in.

AppDelegate.mm image

authenticated-navigation.tsx image

stevenbdf avatar Dec 12 '23 01:12 stevenbdf

안녕하세요@stevenbdf! 의견을 보내주셔서 감사합니다. iOS에서는 Callkeep을 최대한 빨리 실행해야 한다는 점을 이해합니다. 그렇지 않으면 앱이 종료되는 것으로 알고 있습니다. 이 상황에서 jsBundle이 로드된 후 앱을 닫지 않고 Callkeep을 시작하는 메서드를 어떻게 사용할 수 있습니까?

나는 그것이 iOS의 권장 사항이라고 생각합니다. 하지만 내 앱에서 실험해 본 결과 필수는 아닙니다. voipRegistration위임 파일에서 를 제거해야 했고 처음에는 React Native 코드에서 RNCallkeep을 사용했습니다. 앱이 백그라운드 모드에서 깨어날 때 렌더링되는지 확인하는 화면, 공급자 또는 레이아웃 내에서 수행할 수 있습니다. RNCallKeep.setup(callKeepOptions)제 경우에는 사용자가 로그인할 때만 렌더링되는 탐색 제공자에 를 넣고 호출했습니다 .

AppDelegate.mm 영상

authenticated-navigation.tsx 영상

Hmm... thank you. I'm having a lot of worries.

kr-yeon avatar Dec 12 '23 03:12 kr-yeon

Hello @stevenbdf! Thank you for comment. I understand that iOS needs to run Callkeep as quickly as possible. Otherwise, I understand that the app will be terminated. In this situation, how can I use a method to launch Callkeep after the jsBundle is loaded without the app closing?

I think that's the recommendation from iOS yes. But from what I was able to experiment in my app, it is not mandatory. I had to remove the voipRegistration from the delegate file and I simply initially RNCallkeep in my React Native code. It can be done inside a screen, provider or layout that you make sure it's rendered when your app is awaken from background mode. In my case I put and invoke the RNCallKeep.setup(callKeepOptions) in a navigation Provider that's only rendered when the user is logged in.

AppDelegate.mm image

authenticated-navigation.tsx image

@stevenbdf Your solution works as expected. It's amazing. Thank you. It seems that the call is executed after all event listeners are ready. Is there a possibility that bundling may be delayed?

kr-yeon avatar Dec 12 '23 06:12 kr-yeon

  1. If you want to listen to the event and do something with it, then call:
    DeviceEventEmitter.addListener('RNCallKeepDidChangeAudioRoute', data => {
      console.log(data)
    })

    RNCallKeep.addEventListener('didChangeAudioRoute', ({ output }) => {
      console.log(output)
    })
  1. If you want to silence/hide the warning, then call:
    DeviceEventEmitter.removeAllListeners('RNCallKeepDidChangeAudioRoute')
    DeviceEventEmitter.removeAllListeners('didChangeAudioRoute')

bilal-korir avatar May 16 '25 21:05 bilal-korir