Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,12 @@ class ApsWriter @PublishedApi internal constructor(
fun threadId(value: String) = apply {
writer.stringValue("thread-id", value)
}

fun event(value: String) = apply {
writer.stringValue("event", value)
}

fun timestamp(value: Long) = apply {
writer.longValue("timestamp", value)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ enum class PushType(
* @since 0.12.0
*/
FILE_PROVIDER("fileprovider"),
/**
* @since 0.12.0
*/
LIVE_ACTIVITY("liveactivity"),
/**
* @since 0.12.0
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import com.bloomberg.pushiko.apns.model.PushType
import com.google.gson.JsonParser
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.mockito.kotlin.times
import java.time.Instant
import java.util.UUID
import kotlin.test.assertEquals
Expand Down Expand Up @@ -444,4 +445,22 @@ internal class ApnsRequestTest {
assertEquals("Hello", body["aps"].asJsonObject["alert"].asJsonObject["title"].asString)
}
}

@Test
fun apsLiveActivity() {
ApnsRequest {
deviceToken("abc123")
topic("com.foo")
pushType(PushType.LIVE_ACTIVITY)
aps {
event ("update")
timestamp(Instant.now().epochSecond)
}
}.run {
val body = JsonParser.parseString(payloadString()).asJsonObject
val aps = body["aps"].asJsonObject
assertEquals("update", aps["event"].asString)
assertTrue(aps["timestamp"].asLong >= Instant.now().epochSecond)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ internal class PushTypeTest {
assertEquals("fileprovider", PushType.FILE_PROVIDER.value)
}

@Test
fun liveActivity() {
assertEquals("liveactivity", PushType.LIVE_ACTIVITY.value)
}

@Test
fun location() {
assertEquals("location", PushType.LOCATION.value)
Expand Down