diff --git a/push-notifications/README.md b/push-notifications/README.md index 22d5fe7dd..5f7847719 100644 --- a/push-notifications/README.md +++ b/push-notifications/README.md @@ -35,7 +35,7 @@ Android 13 requires a permission check in order to receive push notifications. This plugin will use the following project variables (defined in your app's `variables.gradle` file): -- `firebaseMessagingVersion` version of `com.google.firebase:firebase-messaging` (default: `23.3.1`) +- `firebaseMessagingVersion` version of `com.google.firebase:firebase-messaging` (default: `24.1.0`) --- diff --git a/push-notifications/android/build.gradle b/push-notifications/android/build.gradle index d63f5c0d0..b965d0f36 100644 --- a/push-notifications/android/build.gradle +++ b/push-notifications/android/build.gradle @@ -4,7 +4,7 @@ ext { androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.0' androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.2.1' androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.6.1' - firebaseMessagingVersion = project.hasProperty('firebaseMessagingVersion') ? rootProject.ext.firebaseMessagingVersion : '23.3.1' + firebaseMessagingVersion = project.hasProperty('firebaseMessagingVersion') ? rootProject.ext.firebaseMessagingVersion : '24.1.0' } buildscript { 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 761c3331c..8b6823179 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 @@ -126,33 +126,31 @@ public void unregister(PluginCall call) { @PluginMethod public void getDeliveredNotifications(PluginCall call) { JSArray notifications = new JSArray(); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - StatusBarNotification[] activeNotifications = notificationManager.getActiveNotifications(); + StatusBarNotification[] activeNotifications = notificationManager.getActiveNotifications(); - for (StatusBarNotification notif : activeNotifications) { - JSObject jsNotif = new JSObject(); + for (StatusBarNotification notif : activeNotifications) { + JSObject jsNotif = new JSObject(); - jsNotif.put("id", notif.getId()); - jsNotif.put("tag", notif.getTag()); + jsNotif.put("id", notif.getId()); + jsNotif.put("tag", notif.getTag()); - Notification notification = notif.getNotification(); - if (notification != null) { - jsNotif.put("title", notification.extras.getCharSequence(Notification.EXTRA_TITLE)); - jsNotif.put("body", notification.extras.getCharSequence(Notification.EXTRA_TEXT)); - jsNotif.put("group", notification.getGroup()); - jsNotif.put("groupSummary", 0 != (notification.flags & Notification.FLAG_GROUP_SUMMARY)); + Notification notification = notif.getNotification(); + if (notification != null) { + jsNotif.put("title", notification.extras.getCharSequence(Notification.EXTRA_TITLE)); + jsNotif.put("body", notification.extras.getCharSequence(Notification.EXTRA_TEXT)); + jsNotif.put("group", notification.getGroup()); + jsNotif.put("groupSummary", 0 != (notification.flags & Notification.FLAG_GROUP_SUMMARY)); - JSObject extras = new JSObject(); + JSObject extras = new JSObject(); - for (String key : notification.extras.keySet()) { - extras.put(key, notification.extras.getString(key)); - } - - jsNotif.put("data", extras); + for (String key : notification.extras.keySet()) { + extras.put(key, notification.extras.getString(key)); } - notifications.put(jsNotif); + jsNotif.put("data", extras); } + + notifications.put(jsNotif); } JSObject result = new JSObject();