ionic-team / ionic-team/capacitor-local-notifications
Local Notification Category and Action Options are exclusive instead of or'able.
- Dominant language
- Kotlin
- Stars
- 0
- Forks
- 0
- Avg merge
- 11h 50m
- Merged PRs (30d)
- 2
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.
```swift
/**
* 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)
}
```
```swift
/**
* 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
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.