Skip to content

Commit 7d6b6b6

Browse files
committed
ios: use AVAudioSessionCategoryPlayback to support play in background
we must use playback to support background playing. make sure you have enabled 'audio' tag ( or 'voip' tag ) at XCode -> Capabilities -> BackgroundMode note: this does NOT mean you can start/activate an audio session from background. it only means iOS will not interrupt already activated playing audio session when app move to background. for start audio from background, we must use local notification
1 parent 387bd17 commit 7d6b6b6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

ios/RNInCallManager/RNInCallManager.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,12 @@ class RNInCallManager: NSObject, AVAudioPlayerDelegate {
372372
self.mRingtone.numberOfLoops = -1 // you need to stop it explicitly
373373
self.mRingtone.prepareToPlay()
374374

375-
//self.audioSessionSetCategory(AVAudioSessionCategorySoloAmbient, [.DefaultToSpeaker, .AllowBluetooth], #function)
376-
self.audioSessionSetCategory(AVAudioSessionCategorySoloAmbient, nil, #function)
375+
// --- we must use playback to support background playing.
376+
// --- make sure you have enabled 'audio' tag ( or 'voip' tag ) at XCode -> Capabilities -> BackgroundMode
377+
//self.audioSessionSetCategory(AVAudioSessionCategoryPlayback, [.DuckOthers], #function)
378+
self.audioSessionSetCategory(AVAudioSessionCategoryPlayback, nil, #function)
377379
self.audioSessionSetMode(AVAudioSessionModeDefault, #function)
380+
//self.audioSessionSetActive(true, nil, #function)
378381
self.mRingtone.play()
379382
} catch let err {
380383
NSLog("RNInCallManager.startRingtone(): caught error=\(err)")

0 commit comments

Comments
 (0)