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);
            }
        }
 public void NotificationOpened(NotificationInfo notificationInfo)
 {
     manager.Cancel(notificationInfo.Id);
     OnNotificationOpened?.Invoke(this, notificationInfo);
 }
示例#3
0
 public void NotificationOpened(NotificationInfo notificationInfo)
 {
     OnNotificationOpened?.Invoke(this, notificationInfo);
 }
示例#4
0
 protected virtual void OnNotificationOpenedEvent(NotificationEventArgs args) =>
 OnNotificationOpened?.Invoke(this, args);