예제 #1
0
        public ILocalNotificationBuilder WithActionSet(string actionSetId, string parameter)
        {
            var registeredActions = LocalNotifications.GetRegisteredActions(actionSetId).ToArray();

            if (!registeredActions.Any())
            {
                throw new InvalidOperationException($"Unable to associate notificationAction set id {actionSetId} with notification because it has not been registered.");
            }

            _actions.AddRange(registeredActions.Select(r => r.ToAction(parameter)));

            return(this);
        }
        public void Register()
        {
            var actions = RegisteredActions
                          .OfType <ButtonLocalNotificationActionRegistration>()
                          .Select(action => UNNotificationAction.FromIdentifier(action.Id, action.Title, UNNotificationActionOptions.None))
                          .ToArray();

            var category = UNNotificationCategory.FromIdentifier(
                ActionSetId,
                actions,
                new string[] { },
                UNNotificationCategoryOptions.CustomDismissAction);

            UNUserNotificationCenter.Current.SetNotificationCategories(new NSSet <UNNotificationCategory>(category));
            LocalNotifications.Initialize();
        }