I am developing a cross-platform application using Xamarin for SIP calls. I have incoming and outgoing calls.
Although I have a problem with receiving a call when the application is running in the background.
I tried to send a request to the front when a call was received. The code I used is as follows:
In my main business
private void registerReceiver() { IncomingCallReceiver callReceiver = new IncomingCallReceiver(); IntentFilter sipIntentFilter = new IntentFilter(); sipIntentFilter.AddAction("com.NelsonApp.INCOMING_CALL"); this.RegisterReceiver(callReceiver, sipIntentFilter); }
and in my BroadcastReceiver
public override void OnReceive(Context context, Intent intent) { DialerCallListener listener = new DialerCallListener(); SIPRegistration.call = SIPRegistration.sipManager.TakeAudioCall(intent, listener); string str = SIPRegistration.call.PeerProfile.UriString; char [] strArray = {':','@'}; var value = str.Split(strArray)[1]; Intent newIntent = new Intent(context, typeof(MainActivity)); newIntent.AddFlags(ActivityFlags.FromBackground); newIntent.AddCategory(Intent.CategoryLauncher); context.StartActivity(newIntent); PlaySound myActivity = new PlaySound(); myActivity.PlayRingtone(context); MainActivity.isIncomingCall = true; MessagingCenter.Send(string.Empty, "IncomingCall", value); }
I tried with various NewTask ActivityFlags such as NewTask , SingleTop , ReorderToFront , ReceiverForeground , FromBackground , BroughtToFront . However, having noted, bring my application to the forefront.
What else can I do from here?
I tried to follow this link . Although this did not help.
source share