hiennguyen92 / flutter_callkit_incoming

Flutter Callkit Incoming
https://pub.dev/packages/flutter_callkit_incoming
MIT License
174 stars 295 forks source link

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

Open phuchuynh81qn opened 9 months ago

phuchuynh81qn commented 9 months ago

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

phuchuynh81qn commented 9 months ago

@hiennguyen92 Can you help me?

hiennguyen92 commented 9 months ago

it is works fine

phuchuynh81qn commented 9 months ago

@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

pedromachadinho commented 9 months ago

Are you using WebRTC @phuchuynh81qn ?

hiennguyen92 commented 9 months ago

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

phuchuynh81qn commented 9 months ago

@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

hiennguyen92 commented 9 months ago

@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

phuchuynh81qn commented 9 months ago

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

hiennguyen92 commented 9 months ago

@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.

phuchuynh81qn commented 9 months ago

@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 commented 9 months ago

@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

hiennguyen92 commented 9 months ago

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 commented 9 months ago

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

phuchuynh81qn commented 9 months ago

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

hiennguyen92 commented 9 months ago

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

phuchuynh81qn commented 9 months ago

@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

hiennguyen92 commented 9 months ago

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

quanghd96 commented 9 months ago

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

image
hiennguyen92 commented 9 months ago

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

quanghd96 commented 9 months ago

I tried. But it still not work

image
phuchuynh81qn commented 9 months ago

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

quanghd96 commented 9 months ago

@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?

hiennguyen92 commented 9 months ago

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

phuchuynh81qn commented 9 months ago

@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();

Jazzykhan commented 8 months ago

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

kalyanchandra48 commented 8 months ago

@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

phuchuynh39 commented 7 months ago

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