public async void OnToastNotificationActivated(ToastActivationType activationType, string args) { QueryString query = QueryString.Parse(args); uint activeCallID = 0; uint incomingCallID = 0; Call activeCall = null; Call incomingCall = null; Frame frame = null; switch (query[NotificationSystem.ACTION]) { case NotificationSystem.END: activeCallID = uint.Parse(query[NotificationSystem.ACTIVE_CALL_ID]); activeCall = CallSystem.CallManager.CurrentCalls.FirstOrDefault(x => x.ID == activeCallID); //if (activeCall?.AvailableActions.EndCallAvailable ?? false) //{ activeCall?.End(); //} //else //{ // //LOG //} break; case NotificationSystem.REJECT: incomingCallID = uint.Parse(query[NotificationSystem.INCOMING_CALL_ID]); incomingCall = CallSystem.CallManager.CurrentCalls.FirstOrDefault(x => x.ID == incomingCallID); incomingCall?.RejectIncoming(); break; case NotificationSystem.TEXT_REPLY: incomingCallID = uint.Parse(query[NotificationSystem.INCOMING_CALL_ID]); break; case NotificationSystem.END_AND_ANSWER: activeCallID = uint.Parse(query[NotificationSystem.ACTIVE_CALL_ID]); activeCall = CallSystem.CallManager.CurrentCalls.FirstOrDefault(x => x.ID == activeCallID); //if (activeCall?.AvailableActions.EndCallAvailable ?? false) //{ activeCall?.End(); //} //else //{ // //LOG //} goto case NotificationSystem.ANSWER; case NotificationSystem.HOLD_AND_ANSWER: activeCallID = uint.Parse(query[NotificationSystem.ACTIVE_CALL_ID]); activeCall = CallSystem.CallManager.CurrentCalls.FirstOrDefault(x => x.ID == activeCallID); //if (activeCall?.AvailableActions.HoldAvailable ?? false) //{ activeCall?.SetHold(true); //} //else //{ // //LOG //} goto case NotificationSystem.ANSWER; case NotificationSystem.ANSWER: incomingCallID = uint.Parse(query[NotificationSystem.INCOMING_CALL_ID]); incomingCall = CallSystem.CallManager.CurrentCalls.FirstOrDefault(x => x.ID == incomingCallID); //if (incomingCall?.AvailableActions.AnswerAvailable ?? false) //{ incomingCall?.AcceptIncomingEx(); //} //else //{ // //LOG //} if (activationType == ToastActivationType.Foreground) { goto case NotificationSystem.SHOW_CALL_UI; } else { break; } case NotificationSystem.SHOW_CALL_UI: CompactOverlayId = await CallUIPage.ShowInCallUI(); //frame = Window.Current.Content as Frame; //frame.Navigate(typeof(InCallUI)); break; case NotificationSystem.SHOW_INCOMING_CALL_UI: frame = Window.Current.Content as Frame; frame.Navigate(typeof(IncomingCallUI)); break; } }
private async void OnLaunchedOrActivated(IActivatedEventArgs args) { IsForeground = true; Frame frame = ConstructUI(); Dispatcher = Window.Current.Dispatcher; if (!PermissionSystem.IsAllPermissionsObtained && !await ObtainingAccess) { await Dispatcher.RunAsync(CoreDispatcherPriority.High, () => { ObtainingAccess = PermissionSystem.RequestAllPermissions(); }); await ObtainingAccess; } if (Initializating == null) { Initializating = InitializateSystems(); } await Initializating; UISystem.Initializate(Dispatcher); NotificationSystem.RemoveCallToastNotifications(); switch (args.Kind) { case ActivationKind.Launch: LaunchActivatedEventArgs launchActivationArgs = args as LaunchActivatedEventArgs; if (launchActivationArgs.PrelaunchActivated == false) { if (frame.Content == null) { if (PhoneCallManager.IsCallActive) { CompactOverlayId = await CallUIPage.ShowInCallUI(); } frame.Navigate(typeof(MainPage), launchActivationArgs.Arguments); } } break; case ActivationKind.LockScreen: LockApplicationHost = LockApplicationHost.GetForCurrentView(); LockApplicationHost.Unlocking += LockApplicationHost_Unlocking; frame.Navigate(typeof(MainPage)); break; case ActivationKind.Protocol: ProtocolActivatedEventArgs protocolActivationArgs = args as ProtocolActivatedEventArgs; switch (protocolActivationArgs.Uri.Scheme) { case TEL: frame.Navigate(typeof(MainPage), protocolActivationArgs.Uri.LocalPath); break; default: throw new NotSupportedException(); } break; case ActivationKind.ToastNotification: ToastNotificationActivatedEventArgs toastActivationArgs = args as ToastNotificationActivatedEventArgs; OnToastNotificationActivated(ToastActivationType.Foreground, toastActivationArgs.Argument); break; default: throw new NotSupportedException(); } Window.Current.Activate(); }