Local Notification Category and Action Options are exclusive instead of or'able.

Open Beginner friendly
#6 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
ios, swift
Domain
mobile

Research direction

Read LocalNotifications.swift, focusing on makeActionOptions and makeCategoryOptions, and compare their behavior with Apple’s UNNotification option sets. Exercise combinations of the documented flags on iOS; done when multiple selected options are preserved together for both action and category options.

Written by the indexing model from the issue text.

Description

Bug Report

Plugin(s)

@capacitor/local-notifications

Capacitor Version
💊   Capacitor Doctor  💊

Latest Dependencies:

  @capacitor/cli: 7.4.3
  @capacitor/core: 7.4.3
  @capacitor/android: 7.4.3
  @capacitor/ios: 7.4.3

Installed Dependencies:

  @capacitor/cli: 7.4.3
  @capacitor/android: 7.4.3
  @capacitor/core: 7.4.3
  @capacitor/ios: 7.4.3

[success] iOS looking great! 👌
[success] Android looking great! 👌
Platform(s)

iOS

Current Behavior

The iOS implementation of makeCategoryOptions and makeActionOptions in LocalNotifications.swift currently evaluates category option flags in an exclusive “first match wins” manner instead of combining them as intended by Apple’s UNNotificationCategoryOptions.

    /**
     * Make options for UNNotificationActions
     */
    func makeActionOptions(_ action: JSObject) -> UNNotificationActionOptions {
        let foreground = action["foreground"] as? Bool ?? false
        let destructive = action["destructive"] as? Bool ?? false
        let requiresAuthentication = action["requiresAuthentication"] as? Bool ?? false

        if foreground {
            return .foreground
        }
        if destructive {
            return .destructive
        }
        if requiresAuthentication {
            return .authenticationRequired
        }
        return UNNotificationActionOptions(rawValue: 0)
    }
    /**
     * Make options for UNNotificationCategoryActions
     */
    func makeCategoryOptions(_ type: JSObject) -> UNNotificationCategoryOptions {
        let customDismiss = type["iosCustomDismissAction"] as? Bool ?? false
        let carPlay = type["iosAllowInCarPlay"] as? Bool ?? false
        let hiddenPreviewsShowTitle = type["iosHiddenPreviewsShowTitle"] as? Bool ?? false
        let hiddenPreviewsShowSubtitle = type["iosHiddenPreviewsShowSubtitle"] as? Bool ?? false

        if customDismiss {
            return .customDismissAction
        }
        if carPlay {
            return .allowInCarPlay
        }

        if hiddenPreviewsShowTitle {
            return .hiddenPreviewsShowTitle
        }
        if hiddenPreviewsShowSubtitle {
            return .hiddenPreviewsShowSubtitle
        }

        return UNNotificationCategoryOptions(rawValue: 0)
    }

What’s wrong:

  • The function returns immediately upon encountering the first truthy flag.
  • As a result, if multiple flags are set (iosCustomDismissAction + iosAllowInCarPlay, for example), only the first one is applied.
  • UNNotificationCategoryOptions is an OptionSet intended for bitwise combination (OR’ing multiple options), but the current logic prevents that.

Impact:

  • Users cannot enable multiple options for a notification category simultaneously.
  • Features like .customDismissAction + .allowInCarPlay together are effectively impossible.
  • This behavior has existed since the method’s inception, but it only surfaces if multiple flags are needed at once.
Expected Behavior

Users should be able to set mix and match the respective options.

Code Reproduction
Other Technical Details
Additional Context
Dominant language
Kotlin
Stars
0
Forks
0
Avg merge
11h 50m
Merged PRs (30d)
2

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ionic-team/capacitor-local-notifications

All issues in ionic-team/capacitor-local-notifications

Similar issues

More Kotlin issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.