diff --git a/pushy/src/main/java/com/eatthepath/pushy/apns/util/ApnsPayloadBuilder.java b/pushy/src/main/java/com/eatthepath/pushy/apns/util/ApnsPayloadBuilder.java index 7b4083e55..ea0e8973e 100644 --- a/pushy/src/main/java/com/eatthepath/pushy/apns/util/ApnsPayloadBuilder.java +++ b/pushy/src/main/java/com/eatthepath/pushy/apns/util/ApnsPayloadBuilder.java @@ -82,6 +82,7 @@ public abstract class ApnsPayloadBuilder { private boolean preferStringRepresentationForAlerts = false; private LiveActivityEvent event = null; + private Integer inputPushToken = null; private Instant timestamp = null; @@ -131,6 +132,7 @@ public abstract class ApnsPayloadBuilder { private static final String ATTRIBUTES_TYPE_KEY = "attributes-type"; private static final String ATTRIBUTES_KEY = "attributes"; private static final String CONTENT_STATE_KEY = "content-state"; + private static final String INPUT_PUSH_TOKEN_KEY = "input-push-token"; public static final String[] EMPTY_STRING_ARRAY = new String[0]; @@ -769,7 +771,7 @@ public ApnsPayloadBuilder addCustomProperty(final String key, final Object value * * @return a reference to this payload builder * - * @see #setAttributes(Map) + * @see #setAttributes(Map) * @see * Construct the payload that starts a Live Activity * @see ActivityKit - ActivityAttributes @@ -789,7 +791,7 @@ public ApnsPayloadBuilder setAttributesType(final String attributesType) { * * @return a reference to this payload builder * - * @see #setAttributesType(String) + * @see #setAttributesType(String) * @see * Construct the payload that starts a Live Activity * @see ActivityKit - ContentState @@ -856,6 +858,19 @@ public ApnsPayloadBuilder setTimestamp(final Instant timestamp) { return this; } + /** + *

Sets the flag to wake up the app and receive a push token to send updates to the started Live Activity.

+ * + * @return a reference to this payload builder + * + * @see + * Starting and updating Live Activities with ActivityKit push notifications + */ + public ApnsPayloadBuilder setInputPushToken() { + this.inputPushToken = 1; + return this; + } + /** *

Sets a dismissal timestamp for Live Activity notifications. According to Apple's documentation:

* @@ -964,6 +979,10 @@ protected Map buildPayloadMap() { aps.put(STALE_DATE_KEY, this.staleDate.getEpochSecond()); } + if (this.inputPushToken != null) { + aps.put(INPUT_PUSH_TOKEN_KEY, this.inputPushToken); + } + final Map alert = new HashMap<>(); { if (this.alertBody != null) { diff --git a/pushy/src/test/java/com/eatthepath/pushy/apns/util/ApnsPayloadBuilderTest.java b/pushy/src/test/java/com/eatthepath/pushy/apns/util/ApnsPayloadBuilderTest.java index ff9a4815e..8aecb650f 100644 --- a/pushy/src/test/java/com/eatthepath/pushy/apns/util/ApnsPayloadBuilderTest.java +++ b/pushy/src/test/java/com/eatthepath/pushy/apns/util/ApnsPayloadBuilderTest.java @@ -726,6 +726,15 @@ void testAddContentStateProperty() { assertEquals(subMap, serializedContentState.get(keyForMapValue)); } + @Test + void setInputPushToken() { + this.builder.setInputPushToken(); + + final Map aps = this.extractApsObjectFromPayloadString(this.builder.build()); + + assertEquals(1L, aps.get("input-push-token")); + } + @SuppressWarnings("unchecked") private Map extractApsObjectFromPayloadString(final String payloadString) { final Map payload;