public void OnBackgroundActivated(BackgroundActivatedEventArgs args)
        {
            var deferral = args.TaskInstance.GetDeferral();

            switch (args.TaskInstance.Task.Name)
            {
            case "ToastBackgroundTask":
                var details = args.TaskInstance.TriggerDetails as ToastNotificationActionTriggerDetail;
                if (details != null)
                {
                    string arguments = details.Argument;
                    var    userInput = details.UserInput;
                    NotificationResponse notificationResponse;
                    PushNotificationResponseEventArgs notificationArgs;
                    // Perform tasks
                    if (userInput.Any())
                    {
                        var input = userInput.FirstOrDefault();
                        var dict  = new Dictionary <string, object>()
                        {
                            { NotificationArgumentKey, details.Argument },
                            { NotificationInputsKey, details.UserInput.ToDictionary(d => d.Key, d => d.Value) }
                        };
                        notificationArgs     = new PushNotificationResponseEventArgs(dict, input.Key, result: $"{input.Value}");
                        notificationResponse = new NotificationResponse(dict, input.Key, result: $"{input.Value}");
                    }
                    else
                    {
                        var dict = new Dictionary <string, object>()
                        {
                            { NotificationArgumentKey, details.Argument }
                        };
                        notificationArgs     = new PushNotificationResponseEventArgs(dict);
                        notificationResponse = new NotificationResponse(dict);
                    }


                    OnNotificationAction?.Invoke(this, notificationArgs);

                    CrossPushNotification.Current.NotificationHandler?.OnAction(notificationResponse);
                }
                break;
            }

            deferral.Complete();
        }
        public async Task OnLaunchedOrActivated(IActivatedEventArgs e)
        {
            await RegisterBackgroundTask();

            // Handle toast activation
            if (e is ToastNotificationActivatedEventArgs)
            {
                var    details   = e as ToastNotificationActivatedEventArgs;
                string arguments = details.Argument;
                var    userInput = details.UserInput;

                NotificationResponse notificationResponse;
                PushNotificationResponseEventArgs notificationArgs;
                // Perform tasks
                if (userInput.Any())
                {
                    var input = userInput.FirstOrDefault();
                    var dict  = new Dictionary <string, object>()
                    {
                        { NotificationArgumentKey, details.Argument },
                        { NotificationInputsKey, details.UserInput.ToDictionary(d => d.Key, d => d.Value) }
                    };
                    notificationArgs     = new PushNotificationResponseEventArgs(dict, input.Key, result: $"{input.Value}");
                    notificationResponse = new NotificationResponse(dict, input.Key, result: $"{input.Value}");
                }
                else
                {
                    var dict = new Dictionary <string, object>()
                    {
                        { NotificationArgumentKey, details.Argument }
                    };
                    notificationArgs     = new PushNotificationResponseEventArgs(dict);
                    notificationResponse = new NotificationResponse(dict);
                }


                OnNotificationOpened?.Invoke(this, notificationArgs);

                CrossPushNotification.Current.NotificationHandler?.OnOpened(notificationResponse);
            }
        }