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

can't navigate to call screen after picking call from notification when app is killed #454

Open
Ahtsham0715 opened this issue Jul 30, 2024 · 27 comments

Comments

@Ahtsham0715
Copy link

I have a phone app and I implemented calls using flutter_webrtc and sip_ua it works fine in foreground mode but when the app is killed I used flutter_callkit_incoming to show call notification, upon call accept I'll be able to pick the call but can't navigate to call screen because when the app starts from killed state it does not have Call data which is required to pass to callscreen.

@Ahtsham0715 Ahtsham0715 changed the title can't navigate to call screen after picking call from noticiation when app is killed can't navigate to call screen after picking call from notification when app is killed Jul 30, 2024
@victortive
Copy link
Contributor

You can save the call data in shared preferences and when the flutter app opens, you can read from the call data shared preferences and then pick up the call.

  1. Get notification
  2. Open app
  3. Register SIP
  4. Depending on server. Read call data from preferences or the server sends the incoming call again once connected

@Vinayak0-0
Copy link

@victortive shared one way to get it done.

Another way is to run the SIP as a background service.

@Ahtsham0715
Copy link
Author

I tried both but nothing worked

@pogenz45
Copy link

when reconnect sip after have notification, tell server send the call again, this'll work. i solved this
I tried the way @Vinayak0-0 tell. Keep socket connect, it's worked
But it work in 1 extension situation. when ring ingroup(ring many extensions), it's not work with that way

@pogenz45
Copy link

The best way is keep connect socket (Use flutter_foreground_task), listen state call in background and show notification when call coming.
When accept the call, use findCall function to reconnect the call in background
But still now, i not resolve this because not handle flutter_foreground_task when findCall (Helper not same when reopen app so no find the call)
Anyone solve this problem

@Vinayak006
Copy link

@pogenz45
If you keep the SipUAHelper in background, it will be same as when the background service was started.

TaskHandler will be like:

class MyTaskHandler extends TaskHandler implements SipUaHelperListener {
  final SIPUAHelper sipuaHelper = SIPUAHelper();
  .....
  .....
}

That way the helper will be same as it was created.

@pogenz45
Copy link

@pogenz45 If you keep the SipUAHelper in background, it will be same as when the background service was started.

TaskHandler will be like:

class MyTaskHandler extends TaskHandler implements SipUaHelperListener {
  final SIPUAHelper sipuaHelper = SIPUAHelper();
  .....
  .....
}

That way the helper will be same as it was created.

but in main state,how can i get this sipuaHelper?

@Vinayak006
Copy link

@pogenz45 , you don't need the helper in main isolate. You should handle everything related to helper in background isolate and send the necessary data to main isolate to update the UI

@pogenz45
Copy link

@pogenz45 If you keep the SipUAHelper in background, it will be same as when the background service was started.
TaskHandler will be like:

class MyTaskHandler extends TaskHandler implements SipUaHelperListener {
  final SIPUAHelper sipuaHelper = SIPUAHelper();
  .....
  .....
}

That way the helper will be same as it was created.

but in main state,how can i get this sipuaHelper?

@pogenz45 If you keep the SipUAHelper in background, it will be same as when the background service was started.

TaskHandler will be like:

class MyTaskHandler extends TaskHandler implements SipUaHelperListener {
  final SIPUAHelper sipuaHelper = SIPUAHelper();
  .....
  .....
}

That way the helper will be same as it was created.

Do you have gmail or any contract method?
I want to ask more about this problem
Please

@Vinayak006
Copy link

@pogenz45 If you keep the SipUAHelper in background, it will be same as when the background service was started.
TaskHandler will be like:

class MyTaskHandler extends TaskHandler implements SipUaHelperListener {
  final SIPUAHelper sipuaHelper = SIPUAHelper();
  .....
  .....
}

That way the helper will be same as it was created.

but in main state,how can i get this sipuaHelper?

@pogenz45 If you keep the SipUAHelper in background, it will be same as when the background service was started.
TaskHandler will be like:

class MyTaskHandler extends TaskHandler implements SipUaHelperListener {
  final SIPUAHelper sipuaHelper = SIPUAHelper();
  .....
  .....
}

That way the helper will be same as it was created.

Do you have gmail or any contract method? I want to ask more about this problem Please

[email protected]

@pogenz45
Copy link

@pogenz45 , you don't need the helper in main isolate. You should handle everything related to helper in background isolate and send the necessary data to main isolate to update the UI

But how can you h

@pogenz45 If you keep the SipUAHelper in background, it will be same as when the background service was started.
TaskHandler will be like:

class MyTaskHandler extends TaskHandler implements SipUaHelperListener {
  final SIPUAHelper sipuaHelper = SIPUAHelper();
  .....
  .....
}

That way the helper will be same as it was created.

but in main state,how can i get this sipuaHelper?

@pogenz45 If you keep the SipUAHelper in background, it will be same as when the background service was started.
TaskHandler will be like:

class MyTaskHandler extends TaskHandler implements SipUaHelperListener {
  final SIPUAHelper sipuaHelper = SIPUAHelper();
  .....
  .....
}

That way the helper will be same as it was created.

Do you have gmail or any contract method? I want to ask more about this problem Please

[email protected]

I sent a mail
Please reply me soon
Thank you

@stgni
Copy link

stgni commented Sep 2, 2024

Hello, have you found a solution for this issue? I am experiencing the same problem in the background. When you find a solution, can you share it with me?

@paulodrikey
Copy link

I’m having the same issue. When I answer with the app closed, the audio works, but it doesn’t open the call screen… has anyone managed to solve this problem?

@robsonvasquez
Copy link

I'm experiencing the same issue: the VoIP call runs, but the app can't capture the 'call' object from SIP UA, and it doesn't navigate to the call screen when initiated by CallKit. Has anyone managed to solve this?

@pogenz45
Copy link

pogenz45 commented Sep 4, 2024

I'm experiencing the same issue: the VoIP call runs, but the app can't capture the 'call' object from SIP UA, and it doesn't navigate to the call screen when initiated by CallKit. Has anyone managed to solve this?

You can only capture the call when keep connection onl
When awake app and reconnect sip, you cannot find the call through call_id or capture the call
I resolved it, when have callcoming, server will check and send request to offline_ext every 0.2s until the ext online
so when you reconnect app, you'll capture the call

@robsonvasquez
Copy link

I'm experiencing the same issue: the VoIP call runs, but the app can't capture the 'call' object from SIP UA, and it doesn't navigate to the call screen when initiated by CallKit. Has anyone managed to solve this?

You can only capture the call when keep connection onl When awake app and reconnect sip, you cannot find the call through call_id or capture the call I resolved it, when have callcoming, server will check and send request to offline_ext every 0.2s until the ext online so when you reconnect app, you'll capture the call

When I receive a notification from FCM, I register with the SIP server (Asterisk). Shortly after, I receive a call invite via SIP UA and trigger the callkit incoming notification, all while in the background. When the user accepts the call by clicking "Accept" on the callkit, my app is launched, and the call is answered using call.answer from SIP UA. I check on the native Android side if the app was initialized by the callkit library and navigate to my call screen. The call and audio traffic work, but I don't have access to the SIP UA call object that initiated the call. It seems as though the SIP call is happening in a different "thread" while the app is running on another with a new instance of the SIP UA helper. When I retrieve the call.id and try to find the call with findCall(), it returns null. However, the call is ongoing since I can hear and respond to the audio.

@pogenz45
Copy link

pogenz45 commented Sep 4, 2024

I'm experiencing the same issue: the VoIP call runs, but the app can't capture the 'call' object from SIP UA, and it doesn't navigate to the call screen when initiated by CallKit. Has anyone managed to solve this?

You can only capture the call when keep connection onl When awake app and reconnect sip, you cannot find the call through call_id or capture the call I resolved it, when have callcoming, server will check and send request to offline_ext every 0.2s until the ext online so when you reconnect app, you'll capture the call

When I receive a notification from FCM, I register with the SIP server (Asterisk). Shortly after, I receive a call invite via SIP UA and trigger the callkit incoming notification, all while in the background. When the user accepts the call by clicking "Accept" on the callkit, my app is launched, and the call is answered using call.answer from SIP UA. I check on the native Android side if the app was initialized by the callkit library and navigate to my call screen. The call and audio traffic work, but I don't have access to the SIP UA call object that initiated the call. It seems as though the SIP call is happening in a different "thread" while the app is running on another with a new instance of the SIP UA helper. When I retrieve the call.id and try to find the call with findCall(), it returns null. However, the call is ongoing since I can hear and respond to the audio.

gmail [email protected] to know more of this problem bro

@pogenz45
Copy link

pogenz45 commented Sep 4, 2024

I'm experiencing the same issue: the VoIP call runs, but the app can't capture the 'call' object from SIP UA, and it doesn't navigate to the call screen when initiated by CallKit. Has anyone managed to solve this?

You can only capture the call when keep connection onl When awake app and reconnect sip, you cannot find the call through call_id or capture the call I resolved it, when have callcoming, server will check and send request to offline_ext every 0.2s until the ext online so when you reconnect app, you'll capture the call

When I receive a notification from FCM, I register with the SIP server (Asterisk). Shortly after, I receive a call invite via SIP UA and trigger the callkit incoming notification, all while in the background. When the user accepts the call by clicking "Accept" on the callkit, my app is launched, and the call is answered using call.answer from SIP UA. I check on the native Android side if the app was initialized by the callkit library and navigate to my call screen. The call and audio traffic work, but I don't have access to the SIP UA call object that initiated the call. It seems as though the SIP call is happening in a different "thread" while the app is running on another with a new instance of the SIP UA helper. When I retrieve the call.id and try to find the call with findCall(), it returns null. However, the call is ongoing since I can hear and respond to the audio.

gmail [email protected] to know more of this problem bro

show code you handle accept button of callkit
i'll resolve with you

@stgni
Copy link

stgni commented Sep 4, 2024

Aynı sorunu yaşıyorum: VoIP araması çalışıyor, ancak uygulama SIP UA'dan 'arama' nesnesini yakalayamıyor ve CallKit tarafından başlatıldığında arama ekranına gitmiyor. Bunu çözmeyi başaran var mı?

Bağlantıyı açık tuttuğunuzda yalnızca aramayı yakalayabilirsiniz. Uygulamayı uyanıkken ve SIP'i yeniden bağladığınızda, call_id aracılığıyla aramayı bulamazsınız veya aramayı yakalayamazsınız. Sorunu çözdüm, gelen bir arama olduğunda, sunucu kontrol edecek ve dahili hat çevrimiçi olana kadar her 0,2 saniyede bir offline_ext'e istek gönderecek, böylece uygulamayı yeniden bağladığınızda aramayı yakalayacaksınız.

FCM'den bir bildirim aldığımda, SIP sunucusuna (Asterisk) kaydoluyorum. Kısa bir süre sonra, SIP UA üzerinden bir çağrı daveti alıyorum ve callkit gelen bildirimini tetikliyorum, hepsi arka planda. Kullanıcı callkit'te "Kabul Et"e tıklayarak çağrıyı kabul ettiğinde, uygulamam başlatılıyor ve çağrı SIP UA'dan call.answer kullanılarak yanıtlanıyor. Uygulamanın callkit kitaplığı tarafından başlatılıp başlatılmadığını yerel Android tarafında kontrol ediyorum ve çağrı ekranıma gidiyorum. Çağrı ve ses trafiği çalışıyor, ancak çağrıyı başlatan SIP UA çağrı nesnesine erişimim yok. SIP çağrısı farklı bir "iş parçacığında" gerçekleşirken, uygulama SIP UA yardımcısının yeni bir örneğiyle başka bir iş parçacığında çalışıyor gibi görünüyor. call.id'yi aldığımda ve findCall() ile çağrıyı bulmaya çalıştığımda, null döndürüyor. Ancak, sesi duyabildiğim ve yanıtlayabildiğim için çağrı devam ediyor.

bu sorun hakkında daha fazla bilgi edinmek için gmail [email protected]

callkit'in kabul düğmesini ele aldığınız kodu gösterin, sizinle çözeceğim

I would be very happy if you share your solution with me.

@robsonvasquez
Copy link

robsonvasquez commented Sep 4, 2024

code.zip

I'm experiencing the same issue: the VoIP call runs, but the app can't capture the 'call' object from SIP UA, and it doesn't navigate to the call screen when initiated by CallKit. Has anyone managed to solve this?

You can only capture the call when keep connection onl When awake app and reconnect sip, you cannot find the call through call_id or capture the call I resolved it, when have callcoming, server will check and send request to offline_ext every 0.2s until the ext online so when you reconnect app, you'll capture the call

When I receive a notification from FCM, I register with the SIP server (Asterisk). Shortly after, I receive a call invite via SIP UA and trigger the callkit incoming notification, all while in the background. When the user accepts the call by clicking "Accept" on the callkit, my app is launched, and the call is answered using call.answer from SIP UA. I check on the native Android side if the app was initialized by the callkit library and navigate to my call screen. The call and audio traffic work, but I don't have access to the SIP UA call object that initiated the call. It seems as though the SIP call is happening in a different "thread" while the app is running on another with a new instance of the SIP UA helper. When I retrieve the call.id and try to find the call with findCall(), it returns null. However, the call is ongoing since I can hear and respond to the audio.

gmail [email protected] to know more of this problem bro

show code you handle accept button of callkit i'll resolve with you

I'm sending a zip file with the main files of the app. If there are any further details needed, we can communicate via email, but I believe it's important to have this discussion here to help others who might face the same issue.

Here’s the code for the callkit answer button:

import 'package:flutter_callkit_incoming/entities/entities.dart';
import 'package:flutter_callkit_incoming/flutter_callkit_incoming.dart';
import 'package:flutter_webrtc/flutter_webrtc.dart';
import 'package:sip_ua/sip_ua.dart';

void displayIncomingCall(String callUUID, String handle) async {
CallKitParams params = CallKitParams(
id: callUUID,
nameCaller: handle,
appName: 'Callkit',
avatar: 'https://i.pravatar.cc/100',
handle: '0123456789',
type: 0,
duration: 30000,
textAccept: 'Accept',
textDecline: 'Decline',
missedCallNotification: const NotificationParams(
showNotification: true,
isShowCallback: true,
subtitle: 'Missed call',
callbackText: 'Call back',
),
extra: <String, dynamic>{'userId': '1a2b3c4d'},
headers: <String, dynamic>{'apiKey': 'Abc@123!', 'platform': 'flutter'},
android: const AndroidParams(
isCustomNotification: true,
isShowLogo: false,
ringtonePath: 'system_ringtone_default',
backgroundColor: '#0955fa',
backgroundUrl: 'assets/test.png',
actionColor: '#4CAF50',
textColor: '#ffffff',
),
ios: const IOSParams(
iconName: 'CallKitLogo',
handleType: '',
supportsVideo: true,
maximumCallGroups: 2,
maximumCallsPerCallGroup: 1,
audioSessionMode: 'default',
audioSessionActive: true,
audioSessionPreferredSampleRate: 44100.0,
audioSessionPreferredIOBufferDuration: 0.005,
supportsDTMF: true,
supportsHolding: true,
supportsGrouping: false,
supportsUngrouping: false,
ringtonePath: 'system_ringtone_default',
),
);

await FlutterCallkitIncoming.showCallkitIncoming(params);
}

void handleIncomingSipCall(Call call) {
print("CALL test $call");

String? callUUID = call.id;

displayIncomingCall(callUUID!, call.remote_display_name!);

FlutterCallkitIncoming.onEvent.listen((event) async {
print("STATECALLKIT ${event} call ${call.remote_display_name}");

switch (event!.event) {
  case Event.actionCallAccept:
    final mediaConstraints = <String, dynamic>{
      'audio': true,
      'video': {
        'width': '1280',
        'height': '720',
        'facingMode': 'user',
      }
    };

    MediaStream mediaStream;

    mediaConstraints['video'] = false;

    mediaStream =
        await navigator.mediaDevices.getUserMedia(mediaConstraints);

    call.answer(mediaConstraints, mediaStream: mediaStream);
    break;
  case Event.actionCallIncoming:
    break;
  case Event.actionCallDecline:
    call.hangup();
    break;
  default:
    print('Other event: ');
    break;
}

});
}

@stgni @paulodrikey

@paulodrikey
Copy link

code.zip

I'm experiencing the same issue: the VoIP call runs, but the app can't capture the 'call' object from SIP UA, and it doesn't navigate to the call screen when initiated by CallKit. Has anyone managed to solve this?

You can only capture the call when keep connection onl When awake app and reconnect sip, you cannot find the call through call_id or capture the call I resolved it, when have callcoming, server will check and send request to offline_ext every 0.2s until the ext online so when you reconnect app, you'll capture the call

When I receive a notification from FCM, I register with the SIP server (Asterisk). Shortly after, I receive a call invite via SIP UA and trigger the callkit incoming notification, all while in the background. When the user accepts the call by clicking "Accept" on the callkit, my app is launched, and the call is answered using call.answer from SIP UA. I check on the native Android side if the app was initialized by the callkit library and navigate to my call screen. The call and audio traffic work, but I don't have access to the SIP UA call object that initiated the call. It seems as though the SIP call is happening in a different "thread" while the app is running on another with a new instance of the SIP UA helper. When I retrieve the call.id and try to find the call with findCall(), it returns null. However, the call is ongoing since I can hear and respond to the audio.

gmail [email protected] to know more of this problem bro

show code you handle accept button of callkit i'll resolve with you

I'm sending a zip file with the main files of the app. If there are any further details needed, we can communicate via email, but I believe it's important to have this discussion here to help others who might face the same issue.

Here’s the code for the callkit answer button:

import 'package:flutter_callkit_incoming/entities/entities.dart'; import 'package:flutter_callkit_incoming/flutter_callkit_incoming.dart'; import 'package:flutter_webrtc/flutter_webrtc.dart'; import 'package:sip_ua/sip_ua.dart';

void displayIncomingCall(String callUUID, String handle) async { CallKitParams params = CallKitParams( id: callUUID, nameCaller: handle, appName: 'Callkit', avatar: 'https://i.pravatar.cc/100', handle: '0123456789', type: 0, duration: 30000, textAccept: 'Accept', textDecline: 'Decline', missedCallNotification: const NotificationParams( showNotification: true, isShowCallback: true, subtitle: 'Missed call', callbackText: 'Call back', ), extra: <String, dynamic>{'userId': '1a2b3c4d'}, headers: <String, dynamic>{'apiKey': 'Abc@123!', 'platform': 'flutter'}, android: const AndroidParams( isCustomNotification: true, isShowLogo: false, ringtonePath: 'system_ringtone_default', backgroundColor: '#0955fa', backgroundUrl: 'assets/test.png', actionColor: '#4CAF50', textColor: '#ffffff', ), ios: const IOSParams( iconName: 'CallKitLogo', handleType: '', supportsVideo: true, maximumCallGroups: 2, maximumCallsPerCallGroup: 1, audioSessionMode: 'default', audioSessionActive: true, audioSessionPreferredSampleRate: 44100.0, audioSessionPreferredIOBufferDuration: 0.005, supportsDTMF: true, supportsHolding: true, supportsGrouping: false, supportsUngrouping: false, ringtonePath: 'system_ringtone_default', ), );

await FlutterCallkitIncoming.showCallkitIncoming(params); }

void handleIncomingSipCall(Call call) { print("CALL test $call");

String? callUUID = call.id;

displayIncomingCall(callUUID!, call.remote_display_name!);

FlutterCallkitIncoming.onEvent.listen((event) async { print("STATECALLKIT ${event} call ${call.remote_display_name}");

switch (event!.event) {
  case Event.actionCallAccept:
    final mediaConstraints = <String, dynamic>{
      'audio': true,
      'video': {
        'width': '1280',
        'height': '720',
        'facingMode': 'user',
      }
    };

    MediaStream mediaStream;

    mediaConstraints['video'] = false;

    mediaStream =
        await navigator.mediaDevices.getUserMedia(mediaConstraints);

    call.answer(mediaConstraints, mediaStream: mediaStream);
    break;
  case Event.actionCallIncoming:
    break;
  case Event.actionCallDecline:
    call.hangup();
    break;
  default:
    print('Other event: ');
    break;
}

}); }

@stgni @paulodrikey

I really have the same problem. I believe it’s a simple issue to resolve. It would be useful to document this solution.

@pogenz45
Copy link

pogenz45 commented Sep 5, 2024

code.zip

I'm experiencing the same issue: the VoIP call runs, but the app can't capture the 'call' object from SIP UA, and it doesn't navigate to the call screen when initiated by CallKit. Has anyone managed to solve this?

You can only capture the call when keep connection onl When awake app and reconnect sip, you cannot find the call through call_id or capture the call I resolved it, when have callcoming, server will check and send request to offline_ext every 0.2s until the ext online so when you reconnect app, you'll capture the call

When I receive a notification from FCM, I register with the SIP server (Asterisk). Shortly after, I receive a call invite via SIP UA and trigger the callkit incoming notification, all while in the background. When the user accepts the call by clicking "Accept" on the callkit, my app is launched, and the call is answered using call.answer from SIP UA. I check on the native Android side if the app was initialized by the callkit library and navigate to my call screen. The call and audio traffic work, but I don't have access to the SIP UA call object that initiated the call. It seems as though the SIP call is happening in a different "thread" while the app is running on another with a new instance of the SIP UA helper. When I retrieve the call.id and try to find the call with findCall(), it returns null. However, the call is ongoing since I can hear and respond to the audio.

gmail [email protected] to know more of this problem bro

show code you handle accept button of callkit i'll resolve with you

I'm sending a zip file with the main files of the app. If there are any further details needed, we can communicate via email, but I believe it's important to have this discussion here to help others who might face the same issue.
Here’s the code for the callkit answer button:
import 'package:flutter_callkit_incoming/entities/entities.dart'; import 'package:flutter_callkit_incoming/flutter_callkit_incoming.dart'; import 'package:flutter_webrtc/flutter_webrtc.dart'; import 'package:sip_ua/sip_ua.dart';
void displayIncomingCall(String callUUID, String handle) async { CallKitParams params = CallKitParams( id: callUUID, nameCaller: handle, appName: 'Callkit', avatar: 'https://i.pravatar.cc/100', handle: '0123456789', type: 0, duration: 30000, textAccept: 'Accept', textDecline: 'Decline', missedCallNotification: const NotificationParams( showNotification: true, isShowCallback: true, subtitle: 'Missed call', callbackText: 'Call back', ), extra: <String, dynamic>{'userId': '1a2b3c4d'}, headers: <String, dynamic>{'apiKey': 'Abc@123!', 'platform': 'flutter'}, android: const AndroidParams( isCustomNotification: true, isShowLogo: false, ringtonePath: 'system_ringtone_default', backgroundColor: '#0955fa', backgroundUrl: 'assets/test.png', actionColor: '#4CAF50', textColor: '#ffffff', ), ios: const IOSParams( iconName: 'CallKitLogo', handleType: '', supportsVideo: true, maximumCallGroups: 2, maximumCallsPerCallGroup: 1, audioSessionMode: 'default', audioSessionActive: true, audioSessionPreferredSampleRate: 44100.0, audioSessionPreferredIOBufferDuration: 0.005, supportsDTMF: true, supportsHolding: true, supportsGrouping: false, supportsUngrouping: false, ringtonePath: 'system_ringtone_default', ), );
await FlutterCallkitIncoming.showCallkitIncoming(params); }
void handleIncomingSipCall(Call call) { print("CALL test $call");
String? callUUID = call.id;
displayIncomingCall(callUUID!, call.remote_display_name!);
FlutterCallkitIncoming.onEvent.listen((event) async { print("STATECALLKIT ${event} call ${call.remote_display_name}");

switch (event!.event) {
  case Event.actionCallAccept:
    final mediaConstraints = <String, dynamic>{
      'audio': true,
      'video': {
        'width': '1280',
        'height': '720',
        'facingMode': 'user',
      }
    };

    MediaStream mediaStream;

    mediaConstraints['video'] = false;

    mediaStream =
        await navigator.mediaDevices.getUserMedia(mediaConstraints);

    call.answer(mediaConstraints, mediaStream: mediaStream);
    break;
  case Event.actionCallIncoming:
    break;
  case Event.actionCallDecline:
    call.hangup();
    break;
  default:
    print('Other event: ');
    break;
}

}); }
@stgni @paulodrikey

I really have the same problem. I believe it’s a simple issue to resolve. It would be useful to document this solution.

the problem is if you handle reconnect sip in function onbackground message of firebase
SipuaHelper will declare in background and when you open app, main isolate will declare new sipuahelper so this helper not ablle to find the call through call_id
Use flutter_foreground_task, my idea is when. receive notifi, start_foreground_task(reconnect sip inside this method and listen call state, also use flutter_callkit_incoming to show ring notifi) -> accept the call (set call.accept) -> now app will receive voice but not update ui yet -> use function sendDataToMain of flutterforegroundtask to update UI and function sendDataToTask to handle back of background

@stgni
Copy link

stgni commented Sep 9, 2024

kod.zip

Aynı sorunu yaşıyorum: VoIP araması çalışıyor, ancak uygulama SIP UA'dan 'arama' nesnesini yakalayamıyor ve CallKit tarafından başlatıldığında arama ekranına gitmiyor. Bunu çözmeyi başaran var mı?

Bağlantıyı açık tuttuğunuzda yalnızca aramayı yakalayabilirsiniz. Uygulamayı uyanıkken ve SIP'i yeniden bağladığınızda, call_id aracılığıyla aramayı bulamazsınız veya aramayı yakalayamazsınız. Sorunu çözdüm, gelen bir arama olduğunda, sunucu kontrol edecek ve dahili hat çevrimiçi olana kadar her 0,2 saniyede bir offline_ext'e istek gönderecek, böylece uygulamayı yeniden bağladığınızda aramayı yakalayacaksınız.

FCM'den bir bildirim aldığımda, SIP sunucusuna (Asterisk) kaydoluyorum. Kısa bir süre sonra, SIP UA üzerinden bir çağrı daveti alıyorum ve callkit gelen bildirimini tetikliyorum, hepsi arka planda. Kullanıcı callkit'te "Kabul Et"e tıklayarak çağrıyı kabul ettiğinde, uygulamam başlatılıyor ve çağrı SIP UA'dan call.answer kullanılarak yanıtlanıyor. Uygulamanın callkit kitaplığı tarafından başlatılıp başlatılmadığını yerel Android tarafında kontrol ediyorum ve çağrı ekranıma gidiyorum. Çağrı ve ses trafiği çalışıyor, ancak çağrıyı başlatan SIP UA çağrı nesnesine erişimim yok. SIP çağrısı farklı bir "iş parçacığında" gerçekleşirken, uygulama SIP UA yardımcısının yeni bir örneğiyle başka bir iş parçacığında çalışıyor gibi görünüyor. call.id'yi aldığımda ve findCall() ile çağrıyı bulmaya çalıştığımda, null döndürüyor. Ancak, sesi duyabildiğim ve yanıtlayabildiğim için çağrı devam ediyor.

bu sorun hakkında daha fazla bilgi edinmek için gmail [email protected]

callkit'in kabul düğmesini ele aldığınız kodu gösterin, sizinle çözeceğim

Uygulamanın ana dosyalarının bulunduğu bir zip dosyası gönderiyorum. Daha fazla ayrıntıya ihtiyaç varsa, e-posta yoluyla iletişim kurabiliriz, ancak aynı sorunla karşılaşabilecek diğer kişilere yardımcı olmak için bu tartışmayı burada yapmanın önemli olduğuna inanıyorum.

Callkit cevaplama butonunun kodu şu şekilde:

'paket:flutter_callkit_incoming/entities/entities.dart' öğesini içe aktarın; 'paket:flutter_callkit_incoming/flutter_callkit_incoming.dart' öğesini içe aktarın; ' paket:flutter_webrtc/flutter_webrtc.dart' öğesini içe aktarın; 'paket:sip_ua/sip_ua.dart' öğesini içe aktarın;

void displayIncomingCall(String callUUID, String handle) async { CallKitParams params = CallKitParams( id: callUUID, nameCaller: handle, appName: 'Callkit', avatar: ' https://i.pravatar.cc/100 ', handle: '0123456789', type: 0, duration: 30000, textAccept: 'Kabul Et', textDecline: 'Reddet', missingCallNotification: const NotificationParams( showNotification: true, isShowCallback: true, subtitle: 'Cevapsız çağrı', callbackText: 'Geri arama', ), extra: <String, dynamic>{'userId': '1a2b3c4d'}, headers: <String, dynamic>{'apiKey': 'Abc@123!', 'platform': 'flutter'}, android: const AndroidParams( isCustomNotification: true, isShowLogo: false, ringtonePath: 'system_ringtone_default', backgroundColor: '#0955fa', backgroundUrl: 'assets/test.png', actionColor: '#4CAF50', textColor: '#ffffff', ), ios: const IOSParams( iconName: 'CallKitLogo', handleType: '', supportsVideo: true, maximumCallGroups: 2, maximumCallsPerCallGroup: 1, audioSessionMode: 'default', audioSessionActive: true, audioSessionPreferredSampleRate: 44100.0, audioSessionPreferredIOBufferDuration: 0.005, supportsDTMF: true, desteklerTutma: true, desteklerGruplama: false, desteklerGruplama Kaldırma: false, zil sesiYolu: 'sistem_zil_sesi_varsayılanı', ), );

FlutterCallkitIncoming'i bekle.showCallkitIncoming(params); }

void handleIncomingSipCall(Çağrı çağır) { print("ÇAĞRI test $çağrı");

Dize? callUUID = call.id;

displayIncomingCall(callUUID!, call.remote_display_name!);

FlutterCallkitIncoming.onEvent.listen((olay) async { print("STATECALLKIT ${olay} çağrısı ${call.remote_display_name}");

switch (event!.event) {
  case Event.actionCallAccept:
    final mediaConstraints = <String, dynamic>{
      'audio': true,
      'video': {
        'width': '1280',
        'height': '720',
        'facingMode': 'user',
      }
    };

    MediaStream mediaStream;

    mediaConstraints['video'] = false;

    mediaStream =
        await navigator.mediaDevices.getUserMedia(mediaConstraints);

    call.answer(mediaConstraints, mediaStream: mediaStream);
    break;
  case Event.actionCallIncoming:
    break;
  case Event.actionCallDecline:
    call.hangup();
    break;
  default:
    print('Other event: ');
    break;
}

}); }

@stgni @paulodrikey

Hello, in the example you sent, when the first call comes, it establishes the voice connection that you answer, but the call greeting screen closes and the voice continues, and also when I add callkit, when a call comes, the callkit notification is instantly shown multiple times, how can I show this only once?

@pogenz45
Copy link

kod.zip

Aynı sorunu yaşıyorum: VoIP araması çalışıyor, ancak uygulama SIP UA'dan 'arama' nesnesini yakalayamıyor ve CallKit tarafından başlatıldığında arama ekranına gitmiyor. Bunu çözmeyi başaran var mı?

Bağlantıyı açık tuttuğunuzda yalnızca aramayı yakalayabilirsiniz. Uygulamayı uyanıkken ve SIP'i yeniden bağladığınızda, call_id aracılığıyla aramayı bulamazsınız veya aramayı yakalayamazsınız. Sorunu çözdüm, gelen bir arama olduğunda, sunucu kontrol edecek ve dahili hat çevrimiçi olana kadar her 0,2 saniyede bir offline_ext'e istek gönderecek, böylece uygulamayı yeniden bağladığınızda aramayı yakalayacaksınız.

FCM'den bir bildirim aldığımda, SIP sunucusuna (Asterisk) kaydoluyorum. Kısa bir süre sonra, SIP UA üzerinden bir çağrı daveti alıyorum ve callkit gelen bildirimini tetikliyorum, hepsi arka planda. Kullanıcı callkit'te "Kabul Et"e tıklayarak çağrıyı kabul ettiğinde, uygulamam başlatılıyor ve çağrı SIP UA'dan call.answer kullanılarak yanıtlanıyor. Uygulamanın callkit kitaplığı tarafından başlatılıp başlatılmadığını yerel Android tarafında kontrol ediyorum ve çağrı ekranıma gidiyorum. Çağrı ve ses trafiği çalışıyor, ancak çağrıyı başlatan SIP UA çağrı nesnesine erişimim yok. SIP çağrısı farklı bir "iş parçacığında" gerçekleşirken, uygulama SIP UA yardımcısının yeni bir örneğiyle başka bir iş parçacığında çalışıyor gibi görünüyor. call.id'yi aldığımda ve findCall() ile çağrıyı bulmaya çalıştığımda, null döndürüyor. Ancak, sesi duyabildiğim ve yanıtlayabildiğim için çağrı devam ediyor.

bu sorun hakkında daha fazla bilgi edinmek için gmail [email protected]

callkit'in kabul düğmesini ele aldığınız kodu gösterin, sizinle çözeceğim

Uygulamanın ana dosyalarının bulunduğu bir zip dosyası gönderiyorum. Daha fazla ayrıntıya ihtiyaç varsa, e-posta yoluyla iletişim kurabiliriz, ancak aynı sorunla karşılaşabilecek diğer kişilere yardımcı olmak için bu tartışmayı burada yapmanın önemli olduğuna inanıyorum.
Callkit cevaplama butonunun kodu şu şekilde:
'paket:flutter_callkit_incoming/entities/entities.dart' öğesini içe aktarın; 'paket:flutter_callkit_incoming/flutter_callkit_incoming.dart' öğesini içe aktarın; ' paket:flutter_webrtc/flutter_webrtc.dart' öğesini içe aktarın; 'paket:sip_ua/sip_ua.dart' öğesini içe aktarın;
void displayIncomingCall(String callUUID, String handle) async { CallKitParams params = CallKitParams( id: callUUID, nameCaller: handle, appName: 'Callkit', avatar: ' https://i.pravatar.cc/100 ', handle: '0123456789', type: 0, duration: 30000, textAccept: 'Kabul Et', textDecline: 'Reddet', missingCallNotification: const NotificationParams( showNotification: true, isShowCallback: true, subtitle: 'Cevapsız çağrı', callbackText: 'Geri arama', ), extra: <String, dynamic>{'userId': '1a2b3c4d'}, headers: <String, dynamic>{'apiKey': 'Abc@123!', 'platform': 'flutter'}, android: const AndroidParams( isCustomNotification: true, isShowLogo: false, ringtonePath: 'system_ringtone_default', backgroundColor: '#0955fa', backgroundUrl: 'assets/test.png', actionColor: '#4CAF50', textColor: '#ffffff', ), ios: const IOSParams( iconName: 'CallKitLogo', handleType: '', supportsVideo: true, maximumCallGroups: 2, maximumCallsPerCallGroup: 1, audioSessionMode: 'default', audioSessionActive: true, audioSessionPreferredSampleRate: 44100.0, audioSessionPreferredIOBufferDuration: 0.005, supportsDTMF: true, desteklerTutma: true, desteklerGruplama: false, desteklerGruplama Kaldırma: false, zil sesiYolu: 'sistem_zil_sesi_varsayılanı', ), );
FlutterCallkitIncoming'i bekle.showCallkitIncoming(params); }
void handleIncomingSipCall(Çağrı çağır) { print("ÇAĞRI test $çağrı");
Dize? callUUID = call.id;
displayIncomingCall(callUUID!, call.remote_display_name!);
FlutterCallkitIncoming.onEvent.listen((olay) async { print("STATECALLKIT ${olay} çağrısı ${call.remote_display_name}");

switch (event!.event) {
  case Event.actionCallAccept:
    final mediaConstraints = <String, dynamic>{
      'audio': true,
      'video': {
        'width': '1280',
        'height': '720',
        'facingMode': 'user',
      }
    };

    MediaStream mediaStream;

    mediaConstraints['video'] = false;

    mediaStream =
        await navigator.mediaDevices.getUserMedia(mediaConstraints);

    call.answer(mediaConstraints, mediaStream: mediaStream);
    break;
  case Event.actionCallIncoming:
    break;
  case Event.actionCallDecline:
    call.hangup();
    break;
  default:
    print('Other event: ');
    break;
}

}); }
@stgni @paulodrikey

Hello, in the example you sent, when the first call comes, it establishes the voice connection that you answer, but the call greeting screen closes and the voice continues, and also when I add callkit, when a call comes, the callkit notification is instantly shown multiple times, how can I show this only once?

in event accept_call of flutter_incomingcall, why don't you set navigator to call_screen and handle call.answer in that screen?

@pogenz45
Copy link

and problem multitime, just showcomingcall in stateCallEnum.CALL_INITIATION

@robsonvasquez
Copy link

robsonvasquez commented Sep 11, 2024

Here’s an example of how to use Callkit with FCM, Sipua, and WebRTC on Android. As explained in the FCM documentation, when using the onBackground method in Android, it creates a separate isolate from the main app's isolate. So, when I receive a call notification in the background, I authenticate the Sipua helper in the FCM isolate. Once the main isolate starts, I exchange information between the isolates to manage the Sipua Call and the app interface. If the notification is received while the app is in the foreground, the Sipua registration happens in the same main isolate without needing to exchange information between isolates. For iOS, according to the FCM documentation, a separate isolate is not created for onBackground, so it works normally. You only need to obtain the token to receive the PushVoIP notification on iOS.

example

@stgni @pogenz45

@pogenz45
Copy link

example

nice work, Thank you

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

8 participants