From ff9293c1f79f662e8a1f8fc2248f48d02f3c70e9 Mon Sep 17 00:00:00 2001 From: Rui Mendes Date: Thu, 14 May 2026 10:20:26 +0100 Subject: [PATCH 1/2] feat(push-notifications): add banner and list presentation options for iOS --- push-notifications/README.md | 10 +++++----- .../pushnotifications/PushNotificationsPlugin.java | 4 +++- .../PushNotificationsHandler.swift | 8 ++++++-- push-notifications/src/definitions.ts | 8 +++++--- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/push-notifications/README.md b/push-notifications/README.md index 9d1c29c87..ef3962c9b 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`: **Deprecated on iOS.** Use `banner` and `list` instead. On Android, this value is still used to display the notification. - `banner`: the push notification is displayed as a banner - `list`: the push notification is displayed in the notification center 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..653d4eb5d 100644 --- a/push-notifications/ios/Sources/PushNotificationsPlugin/PushNotificationsHandler.swift +++ b/push-notifications/ios/Sources/PushNotificationsPlugin/PushNotificationsHandler.swift @@ -34,11 +34,15 @@ public class PushNotificationsHandler: NSObject, NotificationHandlerProtocol { optionsArray.forEach { option in switch option { + case "banner": + presentationOptions.insert(.banner) + case "list": + presentationOptions.insert(.list) case "alert": - presentationOptions.insert(.alert) + presentationOptions.insert(.banner) + 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..a6e87a3fe 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`: **Deprecated on iOS.** Use `banner` and `list` instead. On Android, this value is still used to display the notification. + * - `banner`: the push notification is displayed as a banner + * - `list`: the push notification is displayed in the notification center * * 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 2ed0a2c32e742fbc76400b3d890b15901070d65e Mon Sep 17 00:00:00 2001 From: Rui Mendes Date: Fri, 15 May 2026 11:49:19 +0100 Subject: [PATCH 2/2] clarify banner and list behavior on Android --- push-notifications/src/definitions.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/push-notifications/src/definitions.ts b/push-notifications/src/definitions.ts index a6e87a3fe..b457933ef 100644 --- a/push-notifications/src/definitions.ts +++ b/push-notifications/src/definitions.ts @@ -15,8 +15,8 @@ declare module '@capacitor/cli' { * - `badge`: badge count on the app icon is updated (default value) * - `sound`: the device will ring/vibrate when the push notification is received * - `alert`: **Deprecated on iOS.** Use `banner` and `list` instead. On Android, this value is still used to display the notification. - * - `banner`: the push notification is displayed as a banner - * - `list`: the push notification is displayed in the notification center + * - `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. *