func channelManager(_ channelManager: PTChannelManager, didActivate audioSession: AVAudioSession) not called in background

I tried to press system Talk button to talk in channel when my APP in background, I see the channelManager(_ : PTChannelManager, _: UUID, didBeginTransmittingFrom _: PTChannelTransmitRequestSource) is called, but the function func channelManager(_ : PTChannelManager, didActivate _: AVAudioSession) never called.
When my APP in foreground, everything works fine. I've set the APP's capability Background Modes -> Push to Talk.

Anyone can help?

Replies

Same issue faced by me as well in background mode. when app is open it is working fine. For incoming audio incomingPushResult getting called but not didActivate. Can someone help pls?

The channelManager(_:didActivate:) method will not be called if the AVAudioSession was not able to be activated. This can occur if you have not enabled the Audio Background mode for your app and if you have not already configured your app’s AVAudioSession to include include the playAndRecord mode when the transmission begins. Make sure that you’re doing the following things in your PushToTalk app:

  • Enable the “Audio, AirPlay, and Picture in Picture” and “Push to Talk” background modes in your Xcode project
  • Enable the “Push to Talk” capability in your Xcode project
  • Request or check microphone recording permission when initially setting up the app during launch and not each time you record
  • Set the AVAudioSession category to playAndRecord during initial app start up and do not change it during the recording process. Changing the audio category during the recording process introduces significant delay.
  • We recommend the use of the AVAudioEngine API for the best recording performance

You can try to setCategory of audioSession in didBeginTransmittingFrom method.
After I added this code, didActivate may be called.

I had same issue , but It works fine by this logic.

func channelManager(_ channelManager: PTChannelManager, channelUUID: UUID, didBeginTransmittingFrom source: PTChannelTransmitRequestSource){
    try? AVAudioSession.sharedInstance().setCategory(.playAndRecord)        
}