File tree Expand file tree Collapse file tree 2 files changed +28
-4
lines changed
main/java/com/notnoop/apns
test/java/com/notnoop/apns Expand file tree Collapse file tree 2 files changed +28
-4
lines changed Original file line number Diff line number Diff line change 3434import java .util .Collection ;
3535import java .util .HashMap ;
3636import java .util .Map ;
37+
3738import com .fasterxml .jackson .databind .ObjectMapper ;
3839import com .notnoop .apns .internal .Utilities ;
3940
@@ -263,11 +264,24 @@ public PayloadBuilder instantDeliveryOrSilentNotification() {
263264 }
264265
265266 /**
266- * Set the notification localized key for the alert body
267- * message .
267+ * In order for the push notification to get picked up by UNNotificationServiceExtension, the
268+ * aps dictionary must include 'mutable-content' key with value set to 1 .
268269 *
269- * @param key the localizable message body key
270- * @return this
270+ * @see https://developer.apple.com/reference/usernotifications/unnotificationserviceextension
271+ *
272+ * @return this
273+ */
274+ public PayloadBuilder mutableContent () {
275+ aps .put ("mutable-content" , 1 );
276+ return this ;
277+ }
278+
279+ /**
280+ * Set the notification localized key for the alert body message.
281+ *
282+ * @param key
283+ * the localizable message body key
284+ * @return this
271285 */
272286 public PayloadBuilder localizedKey (final String key ) {
273287 customAlert .put ("loc-key" , key );
Original file line number Diff line number Diff line change @@ -570,4 +570,14 @@ public void instantMessageWithAlert() {
570570 final String actual = builder .toString ();
571571 assertEqualsJson (expected , actual );
572572 }
573+
574+ @ Test
575+ public void mutableConentMessage () {
576+ final PayloadBuilder builder = new PayloadBuilder ();
577+ builder .mutableContent ();
578+
579+ final String expected = "{\" aps\" :{\" mutable-content\" :1}}" ;
580+ final String actual = builder .toString ();
581+ assertEqualsJson (expected , actual );
582+ }
573583}
You can’t perform that action at this time.
0 commit comments