From 1c7802c63712fb500e3d6ce45e00f10a5078f14a Mon Sep 17 00:00:00 2001 From: Rui Mendes Date: Fri, 15 May 2026 12:19:37 +0100 Subject: [PATCH 1/2] feat(push-notifications): remove deprecated alert and add banner and list presentation options on iOS --- push-notifications/README.md | 10 +++++----- .../pushnotifications/PushNotificationsPlugin.java | 4 +++- .../PushNotificationsHandler.swift | 7 ++++--- push-notifications/src/definitions.ts | 8 +++++--- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/push-notifications/README.md b/push-notifications/README.md index 9d1c29c87..9ab5bc5f7 100644 --- a/push-notifications/README.md +++ b/push-notifications/README.md @@ -87,9 +87,9 @@ From Android 8.0 (API level 26) and higher, notification channels are supported You can configure the way the push notifications are displayed when the app is in foreground. -| Prop | Type | Description | Since | -| ------------------------- | --------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- | -| **`presentationOptions`** | PresentationOption[] | This is an array of strings you can combine. Possible values in the array are: - `badge`: badge count on the app icon is updated (default value) - `sound`: the device will ring/vibrate when the push notification is received - `alert`: the push notification is displayed in a native dialog An empty array can be provided if none of the options are desired. badge is only available for iOS. | 1.0.0 | +| Prop | Type | Description | Since | +| ------------------------- | --------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- | +| **`presentationOptions`** | PresentationOption[] | This is an array of strings you can combine. Possible values in the array are: - `badge`: badge count on the app icon is updated (default value) - `sound`: the device will ring/vibrate when the push notification is received - `alert`: the push notification is displayed in a native dialog. Only available on Android. - `banner`: the push notification is displayed as a banner. On Android, defaults to the same behavior as `alert`. - `list`: the push notification is displayed in the notification center. On Android, defaults to the same behavior as `alert`. An empty array can be provided if none of the options are desired. badge is only available for iOS. | 1.0.0 | ### Examples @@ -99,7 +99,7 @@ In `capacitor.config.json`: { "plugins": { "PushNotifications": { - "presentationOptions": ["badge", "sound", "alert"] + "presentationOptions": ["badge", "sound", "alert", "banner", "list"] } } } @@ -115,7 +115,7 @@ import { CapacitorConfig } from '@capacitor/cli'; const config: CapacitorConfig = { plugins: { PushNotifications: { - presentationOptions: ["badge", "sound", "alert"], + presentationOptions: ["badge", "sound", "alert", "banner", "list"], }, }, }; diff --git a/push-notifications/android/src/main/java/com/capacitorjs/plugins/pushnotifications/PushNotificationsPlugin.java b/push-notifications/android/src/main/java/com/capacitorjs/plugins/pushnotifications/PushNotificationsPlugin.java index f338f4995..6d339d6df 100644 --- a/push-notifications/android/src/main/java/com/capacitorjs/plugins/pushnotifications/PushNotificationsPlugin.java +++ b/push-notifications/android/src/main/java/com/capacitorjs/plugins/pushnotifications/PushNotificationsPlugin.java @@ -20,6 +20,7 @@ import com.google.firebase.messaging.NotificationParams; import com.google.firebase.messaging.RemoteMessage; import java.util.Arrays; +import java.util.List; import org.json.JSONException; import org.json.JSONObject; @@ -247,7 +248,8 @@ public void fireNotification(RemoteMessage remoteMessage) { String body = notification.getBody(); String[] presentation = getConfig().getArray("presentationOptions"); if (presentation != null) { - if (Arrays.asList(presentation).contains("alert")) { + List presentationList = Arrays.asList(presentation); + if (presentationList.contains("alert") || presentationList.contains("banner") || presentationList.contains("list")) { Bundle bundle = null; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { try { diff --git a/push-notifications/ios/Sources/PushNotificationsPlugin/PushNotificationsHandler.swift b/push-notifications/ios/Sources/PushNotificationsPlugin/PushNotificationsHandler.swift index f3972b68a..d6a55a68f 100644 --- a/push-notifications/ios/Sources/PushNotificationsPlugin/PushNotificationsHandler.swift +++ b/push-notifications/ios/Sources/PushNotificationsPlugin/PushNotificationsHandler.swift @@ -34,11 +34,12 @@ public class PushNotificationsHandler: NSObject, NotificationHandlerProtocol { optionsArray.forEach { option in switch option { - case "alert": - presentationOptions.insert(.alert) + case "banner": + presentationOptions.insert(.banner) + case "list": + presentationOptions.insert(.list) case "badge": presentationOptions.insert(.badge) - case "sound": presentationOptions.insert(.sound) default: diff --git a/push-notifications/src/definitions.ts b/push-notifications/src/definitions.ts index 433d3920a..7216d49cf 100644 --- a/push-notifications/src/definitions.ts +++ b/push-notifications/src/definitions.ts @@ -2,7 +2,7 @@ import type { PermissionState, PluginListenerHandle } from '@capacitor/core'; -export type PresentationOption = 'badge' | 'sound' | 'alert'; +export type PresentationOption = 'badge' | 'sound' | 'alert' | 'banner' | 'list'; declare module '@capacitor/cli' { export interface PluginsConfig { @@ -14,14 +14,16 @@ declare module '@capacitor/cli' { * This is an array of strings you can combine. Possible values in the array are: * - `badge`: badge count on the app icon is updated (default value) * - `sound`: the device will ring/vibrate when the push notification is received - * - `alert`: the push notification is displayed in a native dialog + * - `alert`: the push notification is displayed in a native dialog. Only available on Android. + * - `banner`: the push notification is displayed as a banner. On Android, defaults to the same behavior as `alert`. + * - `list`: the push notification is displayed in the notification center. On Android, defaults to the same behavior as `alert`. * * An empty array can be provided if none of the options are desired. * * badge is only available for iOS. * * @since 1.0.0 - * @example ["badge", "sound", "alert"] + * @example ["badge", "sound", "alert", "banner", "list"] */ presentationOptions: PresentationOption[]; }; From 74f9f493059c58badd42af0e4a22000db3efe08c Mon Sep 17 00:00:00 2001 From: Rui Mendes Date: Fri, 15 May 2026 13:33:43 +0100 Subject: [PATCH 2/2] fix conflicts --- local-notifications/src/definitions.ts | 28 -------------------------- 1 file changed, 28 deletions(-) diff --git a/local-notifications/src/definitions.ts b/local-notifications/src/definitions.ts index 533179871..577cb8390 100644 --- a/local-notifications/src/definitions.ts +++ b/local-notifications/src/definitions.ts @@ -717,34 +717,6 @@ export interface LocalNotificationSchema { */ interruptionLevel?: InterruptionLevel; - /** - * The score the system uses to determine if the notification is the - * featured notification when the system groups the app's notifications. - * - * The value must be between 0 and 1, where 0 is the least relevant and - * 1 is the most relevant. The default value is 0. - * - * Sets `relevanceScore` on the - * [`UNMutableNotificationContent`](https://developer.apple.com/documentation/usernotifications/unmutablenotificationcontent). - * - * Only available for iOS. - * - * @since 8.1.0 - */ - relevanceScore?: number; - - /** - * The interruption level that indicates the priority and delivery timing of a notification. - * - * Sets `interruptionLevel` on the - * [`UNMutableNotificationContent`](https://developer.apple.com/documentation/usernotifications/unmutablenotificationcontent). - * - * Only available for iOS. - * - * @since 8.1.0 - */ - interruptionLevel?: InterruptionLevel; - /** * Used to group multiple notifications. *