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
14 changes: 14 additions & 0 deletions src/main/java/com/notnoop/apns/PayloadBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.notnoop.apns.internal.Utilities;

Expand Down Expand Up @@ -262,6 +263,19 @@ public PayloadBuilder instantDeliveryOrSilentNotification() {
return this;
}

/**
* In order for the push notification to get picked up by UNNotificationServiceExtension, the
* aps dictionary must include 'mutable-content' key with value set to 1.
*
* @see https://developer.apple.com/reference/usernotifications/unnotificationserviceextension
*
* @return this
*/
public PayloadBuilder mutableContent() {
aps.put("mutable-content", 1);
return this;
}

/**
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this comment below is helpful, I would delete it since it doesn't have anything to setting mutable-content.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it's just auto-formatted the javadoc of the .method below. I'll clean it up in a bit. Thanks

* Set the notification localized key for the alert body
* message.
Expand Down
10 changes: 10 additions & 0 deletions src/test/java/com/notnoop/apns/PayloadBuilderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -570,4 +570,14 @@ public void instantMessageWithAlert() {
final String actual = builder.toString();
assertEqualsJson(expected, actual);
}

@Test
public void mutableConentMessage() {
final PayloadBuilder builder = new PayloadBuilder();
builder.mutableContent();

final String expected = "{\"aps\":{\"mutable-content\":1}}";
final String actual = builder.toString();
assertEqualsJson(expected, actual);
}
}