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..b457933ef 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. 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[];
};