You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: OneSignalSDK/onesignal/notifications/src/main/java/com/onesignal/notifications/internal/listeners/NotificationListener.kt
+16-14Lines changed: 16 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -75,23 +75,21 @@ internal class NotificationListener(
75
75
val deviceType =_deviceService.deviceType
76
76
77
77
for (i in0 until data.length()) {
78
-
val notificationId =NotificationFormatHelper.getOSNotificationIdFromJson(data[i] asJSONObject?)
78
+
val notificationId =NotificationFormatHelper.getOSNotificationIdFromJson(data[i] asJSONObject?) ?:continue
79
+
79
80
if (postedOpenedNotifIds.contains(notificationId)) {
80
81
continue
81
82
}
82
-
if (notificationId !=null) {
83
-
postedOpenedNotifIds.add(notificationId)
84
-
}
83
+
84
+
postedOpenedNotifIds.add(notificationId)
85
85
86
86
try {
87
-
if (notificationId !=null) {
88
-
_backend.updateNotificationAsOpened(
89
-
appId,
90
-
notificationId,
91
-
subscriptionId,
92
-
deviceType,
93
-
)
94
-
}
87
+
_backend.updateNotificationAsOpened(
88
+
appId,
89
+
notificationId,
90
+
subscriptionId,
91
+
deviceType,
92
+
)
95
93
} catch (ex:BackendException) {
96
94
Logging.error("Notification opened confirmation failed with statusCode: ${ex.statusCode} response: ${ex.response}")
97
95
}
@@ -104,8 +102,7 @@ internal class NotificationListener(
104
102
)
105
103
106
104
// Handle the first element in the data array as the latest notification
107
-
val latestNotification =if (data.length() >0) data[0] asJSONObjectelsenull
108
-
val latestNotificationId =NotificationFormatHelper.getOSNotificationIdFromJson(latestNotification)
105
+
val latestNotificationId = getLatestNotificationId(data)
109
106
110
107
if (shouldInitDirectSessionFromNotificationOpen(activity)) {
111
108
// We want to set the app entry state to NOTIFICATION_CLICK when coming from background
@@ -130,4 +127,9 @@ internal class NotificationListener(
Copy file name to clipboardExpand all lines: OneSignalSDK/onesignal/notifications/src/main/java/com/onesignal/notifications/internal/open/impl/NotificationOpenedProcessor.kt
0 commit comments