flutter_callkit_incoming icon indicating copy to clipboard operation
flutter_callkit_incoming copied to clipboard

[iOS 17] Can't play a sound when accepting call using callkit in ios 17, ios 15, 16 work fine.

Open phuchuynh81qn opened this issue 1 year ago • 27 comments

[iOS 17] Can't play a sound when accepting call using callkit in ios 17 but just ios 15, 16 work fine.

phuchuynh81qn avatar Jan 10 '24 06:01 phuchuynh81qn

@hiennguyen92 Can you help me?

phuchuynh81qn avatar Jan 10 '24 06:01 phuchuynh81qn

it is works fine

hiennguyen92 avatar Jan 10 '24 10:01 hiennguyen92

@hiennguyen92 I use just audio to play sound, it work fine in ios 15,16 when accept call, but when I update it to ios 17 sound no play. So I research find err callkit with ios 17, Can you check it help me? Thank you https://github.com/ryanheise/just_audio/issues/1074

phuchuynh81qn avatar Jan 10 '24 15:01 phuchuynh81qn

Are you using WebRTC @phuchuynh81qn ?

pedromachadinho avatar Jan 10 '24 16:01 pedromachadinho

If you use webRTC, you should useManual and then configure as in the example (v2.0.1+1) didActivateAudioSession didDeactivateAudioSession

hiennguyen92 avatar Jan 11 '24 04:01 hiennguyen92

@hiennguyen92 @pedromachadinho No, I no use webRTC, I use call kit and voip to push call with device and then use just audio to play audio sound but no play audio in ios 17. I research and find issue as link: https://forums.developer.apple.com/forums/thread/738940

phuchuynh81qn avatar Jan 11 '24 04:01 phuchuynh81qn

@phuchuynh81qn In my opinion, you can try commenting out all the code in this function and then try again. it may have Interruption AVAudioSession https://github.com/hiennguyen92/flutter_callkit_incoming/blob/bf128fd69ad87b634c993ff779d69df390db9dce/ios/Classes/SwiftFlutterCallkitIncomingPlugin.swift#L428

hiennguyen92 avatar Jan 11 '24 04:01 hiennguyen92

@hiennguyen92 Thank you feedback but I try comment code of func sendDefaultAudioInterruptionNofificationToStartAudioResourceit but it still no work. Do you have any other solution?

phuchuynh81qn avatar Jan 11 '24 06:01 phuchuynh81qn

@phuchuynh81qn I'm not sure how the problem occurs. However, there seems to be an AVAudioSession dispute between the two libs. I think you can try delay play audio a bit after accepting.

hiennguyen92 avatar Jan 11 '24 07:01 hiennguyen92

@hiennguyen92 When the call goes then I accept a call and I deplay it 2s before play , I test it in ios 15,16 it works fine.

phuchuynh81qn avatar Jan 11 '24 07:01 phuchuynh81qn

@hiennguyen92 Is there a time when the call is active and Apple blocks the audio? I find many people with issues in ios 17 as link: https://github.com/hiennguyen92/flutter_callkit_incoming/issues/406

phuchuynh81qn avatar Jan 11 '24 07:01 phuchuynh81qn

a phải set AVAudioSession để dùng ạ. e thấy a dùng just_audio, mà just_audio sử dụng https://github.com/ryanheise/audio_session https://github.com/ryanheise/audio_session/blob/master/ios/Classes/DarwinAudioSession.m audio_session dùng của sharedInstance

trong lib của e có callback ra didActivateAudioSession didDeactivateAudioSession

e nghĩ a force cái lib kia, thêm 2 hàm set AVAudioSession cho nó thay cho cái sharedInstance, e nghĩ nó sẽ ok

hiennguyen92 avatar Jan 11 '24 07:01 hiennguyen92

@phuchuynh81qn hoặc a chờ nhận được event Event.actionCallToggleAudioSession: active=false, rồi hãy play audio

hiennguyen92 avatar Jan 11 '24 07:01 hiennguyen92

@hiennguyen92 A thử rồi mà nó vẫn bị á

phuchuynh81qn avatar Jan 11 '24 08:01 phuchuynh81qn

E nghĩ khi đang call nó vẫn có cái interruption. A thử khi bấm accept xong thì chờ chút a endallCall luôn rồi play audio xem sao

hiennguyen92 avatar Jan 11 '24 14:01 hiennguyen92

@hiennguyen92 A endCall thì anh play bth á nhưng a muốn khi mình bấm accept cuộc thì nó phát ra âm thanh lúc đó, ios 15,16 thì nó chạy ngon lành, ios 17 là bị cái này không hiểu lun kaka

phuchuynh81qn avatar Jan 12 '24 03:01 phuchuynh81qn

Vậy e thì nghĩ chỉ có cách như comment ở trên của e. Là a fork nó về rồi sửa cái just_section để nó sử dụng chung cái AVaudiosection

hiennguyen92 avatar Jan 12 '24 03:01 hiennguyen92

@hiennguyen92 I tried to play audio directly in Swift code but it didn't work. Can you help me? image

quanghd96 avatar Jan 13 '24 05:01 quanghd96

you can try add this inside didActiveAudioSection

do {
    try AVAudioSession.sharedInstance().setCategory(.playback, mode: .default, options: [])
    try AVAudioSession.sharedInstance().setActive(true)
} catch {
    print("Error setting up AVAudioSession: \(error.localizedDescription)")
}

set active false inside didDeactivateAudioSection

hiennguyen92 avatar Jan 13 '24 05:01 hiennguyen92

I tried. But it still not work image

quanghd96 avatar Jan 13 '24 05:01 quanghd96

@quanghd96 Nó không play đâu bác mình thử rồi á, này nhiều người bị rồi á.

phuchuynh81qn avatar Jan 15 '24 09:01 phuchuynh81qn

@phuchuynh81qn nếu chỉ có nhu cầu bấm nút nghe thì phát 1 đoạn âm thanh gì đó mà phải dùng webrtc thì hơi kiểu dùng dao mổ trâu giết gà. Bác công nhận ko?

quanghd96 avatar Jan 15 '24 09:01 quanghd96

Tại bt cái này nó ưu tiên cho các cuộc gọi ott, voip. :D

hiennguyen92 avatar Jan 16 '24 13:01 hiennguyen92

@hiennguyen92 Hello e, Trên android có cách mô lấy event cuộc gọi đến khi app đã close rồi không e ơi. A dùng thèn này nhưng thấy một số device nó không support var calls = await FlutterCallkitIncoming.activeCalls();

phuchuynh81qn avatar Jan 30 '24 03:01 phuchuynh81qn

I am having an issue and can not solve it for 3 months now :(
On iOS the onBackgroundMessage function from Fcm does't trigger at all. The notification arrive on time but the function doesn't trigger to start the incoming call screen :( Somebody please share the solution. thanks

Jazzykhan avatar Feb 10 '24 23:02 Jazzykhan

@hiennguyen92 @Jazzykhan

After accepting the CallKit answer action, I am unable to hear the other person's voice on VoIP Push and Flutter Incoming Call Kit's latest version.

But the same issue is not occurring on flutter_callkit_incoming: 2.0.0+2 Old Version.

After I tried AVAudioSession enabling True in swift level also doesn't work

kalyanchandra48 avatar Feb 22 '24 15:02 kalyanchandra48

@kalyanchandra48 It not work in ios > 17 and it just work in ios < 17 . thank you

phuchuynh39 avatar Mar 06 '24 10:03 phuchuynh39