Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No Audio on iOS #84

Closed
NIyerAD opened this issue Aug 21, 2019 · 6 comments
Closed

No Audio on iOS #84

NIyerAD opened this issue Aug 21, 2019 · 6 comments

Comments

@NIyerAD
Copy link

NIyerAD commented Aug 21, 2019

"react-native-callkeep": "^2.0.3"
"react-native-webrtc": "^1.75.0"

I am not receiving any audio when I answer an inbound call on iOS (android is fine). I do get the following in the logs.
[RNCallKeep][configureAudioSession] Activating audio session
[RNCallKeep][CXProviderDelegate][provider:didActivateAudioSession]

@rcidt
Copy link

rcidt commented Aug 22, 2019

I am getting the same thing. It definitely has to do with the Audio Session. I think the call will have no audio if the SIP call is established before the Audio Session is activated.

I need to start handling the call after the didActivateAudioSession event fires, but it only fires on the first call I make, subsequent calls do not trigger the event. Looking into a solution.


Update:

The reason didActivateAudioSession only fired the first time a call was handled was due to another bug where endCall(UUID) wasn't actually disconnecting the CallKit Session. I fixed that bug by calling endAllCalls() instead.

Now every time I end a call, the CallKit Session is terminated along with the Audio Session.

My code now looks something like this

const audioHandler = () => {
    // we only want this listener fired once per call, so make sure to remove it
    Call.removeEventListener('didActivateAudioSession', audioHandler)
    // do whatever you need to do to handle the incoming/outgoing call
    ...            
}
Call.addEventListener('didActivateAudioSession', audioHandler)

Hope this helps anyone with this bug.

Overall there seem to be a lot of bugs with CallKit/this lib. But either way it looks like we wont have to deal with this long, this feature is going away May 2020 since iOS will no longer support it due to privacy concerns.

@NIyerAD
Copy link
Author

NIyerAD commented Aug 27, 2019

Thanks for your help, @rcidt. I thought it may have been something to do with the audio session. I'm handling the call after didActivateAudioSession event fires but there's still no audio. This happens when the first incoming call arrives so I don't think that it's an issue with ending all of the calls first.

@NIyerAD NIyerAD closed this as completed Oct 8, 2019
@fukemy
Copy link

fukemy commented Oct 20, 2022

hi @NIyerAD , can u provide the solution? Im stucking with no audio inside my app at 7 days

@ashirkhan94
Copy link

ashirkhan94 commented Dec 29, 2022

Hi,
Any update on this, I am facing the same issue
thanks in advance

@abpbackup
Copy link

Same here

@ssimoe50
Copy link

I was looking for similar issues to mine. I found this one. Honestly it didn't fix my issue, but put me in a different perspective.
So in a way it help me rethink my normal approach when working with CallKeep and WebRTC on iOS (on Android I've a custom integrated dialer and call UI so I don't use Callkeep). I got 2 service files: CallkeepService (for all the listeners and events) and DialerService (for all the WebRTC and Audio management)

For other people that might face it here is what I've done:

  • I've completely rework my call flow for iOS only. On Android, didn't had any issues. So this is focus only on iOS keep that in mind...
  • When I receive my first notification, a VoIP notification (highly recommended!), I add the Callkeep code, initialize/setup and to display the call UI from Apple's CallKit directly on the AppDelegate. --> See react-native-voip-push-notification to be able to use Apple's PushKit for VoIP.
  • Implement the Callkeep listeners as soon as possible (I've went with the root index.json my project, just import my CallkeepService and call the setup method). Important to not forget to implement the didLoadWithEvents listener for when the app has been manually or forced close (ie. not in background, so completely closed), so when the app loads you can get the events that have been triggered prior to JS startup. (Usually you'll have at least 3 important events to look: RNCallKeepDidDisplayIncomingCall,RNCallKeepPerformAnswerCallAction,RNCallKeepPerformEndCallAction).
  • These 3 events from the listener didLoadWithEvents or both answerCall and endCall listeners are related to the user actions on the Apple's CallKit (ie. call screen).
  • While the device is handling the actions on CallKit, you might already be receiving some background notifications related to the WebRTC process, don't process anything or signal back anything just yet! (This is where I was mostly doing it wrong! I was creating the peerconnection, even tho I wasn't yet adding tracks or the localdescription...)
  • So I just store all the data offer and all the candidates on my DialerService file, but I didn't do anything yet!
  • Only after the answerCall or the RNCallKeepPerformAnswerCallAction (when the user has answered on Apple's CallKit) I will start to process the offer and all the candidates , and after of course signal back with an answer.
  • And then just follow the "normal" WebRTC process.
  • Important to alert too, that I don't use any audio methods from CallKeep! All the audio management I do using react-native-incall-manager. This is so much better!
  • On my DialerService file I really only use 3 methods from Callkeep: RNCallKeep.rejectCall, RNCallKeep.endCall, RNCallKeep.endCalls (this last one it's on my clean up method just in case something got stuck).

Well this is more or less what I did! I spent 4 full days working on this, I'm writing here at the very end and late in the night, so I apologize if my train though is a little messy and confusing, but I think I got most of it out.

Hope this might help someone else, other than me!
Cheers mates!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants