Skip to content

Commit 3706902

Browse files
committed
adding toJSONObject for push subscription changed event parameters
1 parent 3611eaa commit 3706902

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
package com.onesignal.user.subscriptions
22

3+
import org.json.JSONObject
4+
35
class PushSubscriptionChangedState(
46
val previous: PushSubscriptionState,
57
val current: PushSubscriptionState
6-
)
8+
) {
9+
fun toJSONObject(): JSONObject {
10+
return JSONObject()
11+
.put("previous", previous.toJSONObject())
12+
.put("current", current.toJSONObject())
13+
}
14+
}
15+

OneSignalSDK/onesignal/core/src/main/java/com/onesignal/user/subscriptions/PushSubscriptionState.kt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.onesignal.user.subscriptions
22

3+
import org.json.JSONObject
4+
35
/**
46
* A subscription state.
57
*/
@@ -24,5 +26,14 @@ class PushSubscriptionState(
2426
* user will not receive notifications through this subscription (even when the user has
2527
* granted app permission).
2628
*/
27-
val optedIn: Boolean
28-
)
29+
val optedIn: Boolean,
30+
) {
31+
fun toJSONObject(): JSONObject {
32+
return JSONObject()
33+
.put("id", id)
34+
.put("token", token)
35+
.put("optedIn", optedIn)
36+
}
37+
}
38+
39+

0 commit comments

Comments
 (0)