Skip to content

Commit c77c903

Browse files
authored
Merge pull request #1767 from OneSignal/user-model/click_event_result
[User Model] Update click event result
2 parents ab6fe90 + ef2b432 commit c77c903

File tree

3 files changed

+8
-24
lines changed

3 files changed

+8
-24
lines changed

OneSignalSDK/onesignal/core/src/main/java/com/onesignal/notifications/INotificationClickResult.kt

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,13 @@ package com.onesignal.notifications
3030
* The action a user has taken when opening a notification.
3131
*/
3232
interface INotificationClickResult {
33-
/**
34-
* The type of action the user took on this notification.
35-
*/
36-
val type: ActionType
37-
3833
/** When [type] is [ActionType.ActionButton], this will be the custom id of action taken.
3934
* See [Action Buttons | OneSignal Docs](https://documentation.onesignal.com/docs/action-buttons).
4035
**/
4136
val actionId: String?
4237

4338
/**
44-
* The type of actions the user can take on a notification.
39+
* The launch url for the notification.
4540
*/
46-
enum class ActionType {
47-
/**
48-
* The notification was clicked on.
49-
*/
50-
Opened,
51-
52-
/**
53-
* The user clicked on the call-to-action button within the notification.
54-
*/
55-
ActionButton,
56-
}
41+
val url: String?
5742
}

OneSignalSDK/onesignal/notifications/src/main/java/com/onesignal/notifications/internal/NotificationClickResult.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ import com.onesignal.notifications.INotificationClickResult
3131
import org.json.JSONObject
3232

3333
internal class NotificationClickResult(
34-
override val type: INotificationClickResult.ActionType,
3534
override val actionId: String?,
35+
override val url: String?
3636
) : INotificationClickResult {
3737
fun toJSONObject(): JSONObject {
3838
return JSONObject()
39-
.put("type", type)
4039
.putSafe("actionId", actionId)
40+
.putSafe("url", url)
4141
}
4242
}

OneSignalSDK/onesignal/notifications/src/main/java/com/onesignal/notifications/internal/common/NotificationHelper.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,16 +234,15 @@ object NotificationHelper {
234234
}
235235
}
236236

237-
val actionType =
238-
if (actionSelected != null) INotificationClickResult.ActionType.ActionButton else INotificationClickResult.ActionType.Opened
239-
val notificationAction = NotificationClickResult(actionType, actionSelected)
240-
241237
val notification = com.onesignal.notifications.internal.Notification(
242238
groupedNotifications,
243239
payload!!,
244240
androidNotificationId,
245241
time,
246242
)
247-
return NotificationClickEvent(notification, notificationAction)
243+
244+
val notificationResult = NotificationClickResult(actionSelected, notification.launchURL)
245+
246+
return NotificationClickEvent(notification, notificationResult)
248247
}
249248
}

0 commit comments

Comments
 (0)