Skip to content

Commit

Permalink
Add support for input-push-token and attributes-type
Browse files Browse the repository at this point in the history
  • Loading branch information
ifrins committed Aug 17, 2024
1 parent da5f8b9 commit e91e2f5
Showing 1 changed file with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ public abstract class ApnsPayloadBuilder {
private boolean preferStringRepresentationForAlerts = false;

private LiveActivityEvent event = null;
private String attributesType = null;
private Integer inputPushToken = null;

private Instant timestamp = null;

Expand Down Expand Up @@ -123,6 +125,8 @@ public abstract class ApnsPayloadBuilder {
private static final String DISMISSAL_DATE_KEY = "dismissal-date";
private static final String EVENT_KEY = "event";
private static final String CONTENT_STATE_KEY = "content-state";
private static final String INPUT_PUSH_TOKEN_KEY = "input-push-token";
private static final String ATTRIBUTES_TYPE_KEY = "attributes-type";

public static final String[] EMPTY_STRING_ARRAY = new String[0];

Expand Down Expand Up @@ -778,6 +782,32 @@ public ApnsPayloadBuilder setTimestamp(final Instant timestamp) {
return this;
}

/**
* <p>Sets the flag to wake up the app and receive a push token to send updates to the started Live Activity.</p>
*
* @return a reference to this payload builder
*
* @see <a href="https://developer.apple.com/documentation/activitykit/starting-and-updating-live-activities-with-activitykit-push-notifications">
* Starting and updating Live Activities with ActivityKit push notifications</a>
*/
public ApnsPayloadBuilder setInputPushToken() {
this.inputPushToken = 1;
return this;
}

/**
* <p>Sets the type of the content inside attributes that will be used to start the Live Activity..</p>
*
* @return a reference to this payload builder
*
* @see <a href="https://developer.apple.com/documentation/activitykit/starting-and-updating-live-activities-with-activitykit-push-notifications">
* Starting and updating Live Activities with ActivityKit push notifications</a>
*/
public ApnsPayloadBuilder setAttributesType(final String attributesType) {
this.attributesType = attributesType;
return this;
}

/**
* <p>Sets a timestamp for the push notification payload. The timestamp is used to discard older
* push notifications. According to Apple's documentation:</p>
Expand Down Expand Up @@ -949,6 +979,14 @@ protected Map<String, Object> buildPayloadMap() {
aps.put(ALERT_KEY, alert);
}

if (this.attributesType != null) {
aps.put(ATTRIBUTES_TYPE_KEY, this.attributesType);
}

if (this.inputPushToken != null) {
aps.put(INPUT_PUSH_TOKEN_KEY, this.inputPushToken);
}

payload.put(APS_KEY, aps);
}

Expand Down

0 comments on commit e91e2f5

Please sign in to comment.