File tree 6 files changed +50
-14
lines changed
core/src/main/java/com/onesignal/notifications
in-app-messages/src/main/java/com/onesignal/inAppMessages/internal
notifications/src/main/java/com/onesignal/notifications/internal 6 files changed +50
-14
lines changed Original file line number Diff line number Diff line change @@ -126,6 +126,12 @@ interface INotification {
126
126
*/
127
127
val ttl: Int
128
128
129
+ /* *
130
+ * When this notification is a summary notification, this will contain the list of
131
+ * notifications it summarizes.
132
+ */
133
+ val groupedNotifications: List <INotification >?
134
+
129
135
/* *
130
136
* Create a mutable copy of this notification. Typically used in [IRemoteNotificationReceivedHandler]
131
137
* or [INotificationWillShowInForegroundHandler] to modify an incoming notification prior to it
Original file line number Diff line number Diff line change @@ -3,9 +3,21 @@ package com.onesignal.inAppMessages.internal
3
3
import com.onesignal.inAppMessages.IInAppMessage
4
4
import com.onesignal.inAppMessages.IInAppMessageAction
5
5
import com.onesignal.inAppMessages.IInAppMessageClickResult
6
+ import org.json.JSONObject
6
7
7
- class InAppMessageClickResult (
8
- override val message : IInAppMessage ,
8
+ internal class InAppMessageClickResult (msg : InAppMessage , actn : InAppMessageAction ) : IInAppMessageClickResult {
9
+ override val message: IInAppMessage
10
+ get() = _message
9
11
10
12
override val action: IInAppMessageAction
11
- ) : IInAppMessageClickResult
13
+ get() = _action
14
+
15
+ private val _message : InAppMessage = msg
16
+ private val _action : InAppMessageAction = actn
17
+
18
+ fun toJSONObject (): JSONObject {
19
+ return JSONObject ()
20
+ .put(" message" , _message .toJSONObject())
21
+ .put(" action" , _action .toJSONObject())
22
+ }
23
+ }
Original file line number Diff line number Diff line change @@ -25,12 +25,7 @@ import org.json.JSONObject
25
25
open class Notification : INotification {
26
26
var notificationExtender: NotificationCompat .Extender ? = null
27
27
28
- /* *
29
- * Summary notifications grouped
30
- * Notification payload will have the most recent notification received.
31
- */
32
- var groupedNotifications: List <Notification >? = null
33
-
28
+ override var groupedNotifications: List <Notification >? = null
34
29
override var androidNotificationId = 0
35
30
override var notificationId: String? = null
36
31
override var templateName: String? = null
Original file line number Diff line number Diff line change 26
26
*/
27
27
package com.onesignal.notifications.internal
28
28
29
+ import com.onesignal.common.putSafe
29
30
import com.onesignal.notifications.INotificationAction
31
+ import org.json.JSONObject
30
32
31
33
internal class NotificationAction (
32
34
override val type : INotificationAction .ActionType ,
33
35
override val actionId : String?
34
- ) : INotificationAction
36
+ ) : INotificationAction {
37
+ fun toJSONObject (): JSONObject {
38
+ return JSONObject ()
39
+ .put(" type" , type)
40
+ .putSafe(" actionId" , actionId)
41
+ }
42
+ }
Original file line number Diff line number Diff line change @@ -4,15 +4,30 @@ import com.onesignal.notifications.INotification
4
4
import com.onesignal.notifications.INotificationAction
5
5
import com.onesignal.notifications.INotificationClickHandler
6
6
import com.onesignal.notifications.INotificationClickResult
7
+ import org.json.JSONObject
7
8
8
9
/* *
9
10
* The data provided to [INotificationClickHandler.notificationClicked] when a notification
10
11
* has been opened by the user.
11
12
*/
12
- class NotificationClickResult (
13
+ internal class NotificationClickResult (
14
+ notif : Notification ,
15
+ actn : NotificationAction
16
+ ) : INotificationClickResult {
13
17
/* * The notification that was opened by the user. **/
14
- override val notification : INotification ,
18
+ override val notification: INotification
19
+ get() = _notification
15
20
16
21
/* * The action the user took to open the notification. **/
17
22
override val action: INotificationAction
18
- ) : INotificationClickResult
23
+ get() = _action
24
+
25
+ private val _notification : Notification = notif
26
+ private val _action : NotificationAction = actn
27
+
28
+ fun toJSONObject (): JSONObject {
29
+ return JSONObject ()
30
+ .put(" notification" , _notification .toJSONObject())
31
+ .put(" action" , _action .toJSONObject())
32
+ }
33
+ }
Original file line number Diff line number Diff line change @@ -203,7 +203,7 @@ object NotificationHelper {
203
203
return " "
204
204
}
205
205
206
- fun generateNotificationOpenedResult (jsonArray : JSONArray , time : ITime ): NotificationClickResult {
206
+ internal fun generateNotificationOpenedResult (jsonArray : JSONArray , time : ITime ): NotificationClickResult {
207
207
val jsonArraySize = jsonArray.length()
208
208
var firstMessage = true
209
209
val androidNotificationId = jsonArray.optJSONObject(0 )
You can’t perform that action at this time.
0 commit comments