@@ -411,6 +411,7 @@ public void testApnsMessageWithPayload() throws IOException {
411411 .putCustomData ("cd1" , "cd-v1" )
412412 .putAllCustomData (ImmutableMap .<String , Object >of ("cd2" , "cd-v2" , "cd3" , true ))
413413 .setAps (Aps .builder ().build ())
414+ .setLiveActivityToken ("test-live-activity-token" )
414415 .build ())
415416 .setTopic ("test-topic" )
416417 .build ();
@@ -421,10 +422,11 @@ public void testApnsMessageWithPayload() throws IOException {
421422 .put ("cd3" , true )
422423 .put ("aps" , ImmutableMap .of ())
423424 .build ();
424- Map <String , Object > data = ImmutableMap .<String , Object >of (
425- "headers" , ImmutableMap .of ("k1" , "v1" , "k2" , "v2" , "k3" , "v3" ),
426- "payload" , payload
427- );
425+ Map <String , Object > data = ImmutableMap .<String , Object >builder ()
426+ .put ("headers" , ImmutableMap .of ("k1" , "v1" , "k2" , "v2" , "k3" , "v3" ))
427+ .put ("payload" , payload )
428+ .put ("live-activity-token" , "test-live-activity-token" )
429+ .build ();
428430 assertJsonEquals (ImmutableMap .of ("topic" , "test-topic" , "apns" , data ), message );
429431 }
430432
@@ -442,6 +444,7 @@ public void testApnsMessageWithPayloadAndAps() throws IOException {
442444 .setSound ("test-sound" )
443445 .setThreadId ("test-thread-id" )
444446 .build ())
447+ .setLiveActivityToken ("test-live-activity-token-aps" )
445448 .build ())
446449 .setTopic ("test-topic" )
447450 .build ();
@@ -459,7 +462,10 @@ public void testApnsMessageWithPayloadAndAps() throws IOException {
459462 assertJsonEquals (
460463 ImmutableMap .of (
461464 "topic" , "test-topic" ,
462- "apns" , ImmutableMap .<String , Object >of ("payload" , payload )),
465+ "apns" , ImmutableMap .<String , Object >builder ()
466+ .put ("payload" , payload )
467+ .put ("live-activity-token" , "test-live-activity-token-aps" )
468+ .build ()),
463469 message );
464470
465471 message = Message .builder ()
@@ -825,6 +831,7 @@ public void testImageInApnsNotification() throws IOException {
825831 .setApnsConfig (
826832 ApnsConfig .builder ().setAps (Aps .builder ().build ())
827833 .setFcmOptions (ApnsFcmOptions .builder ().setImage (TEST_IMAGE_URL_APNS ).build ())
834+ .setLiveActivityToken ("test-live-activity-token-image" )
828835 .build ()).build ();
829836
830837 ImmutableMap <String , Object > notification =
@@ -837,6 +844,7 @@ public void testImageInApnsNotification() throws IOException {
837844 ImmutableMap .<String , Object >builder ()
838845 .put ("fcm_options" , ImmutableMap .of ("image" , TEST_IMAGE_URL_APNS ))
839846 .put ("payload" , ImmutableMap .of ("aps" , ImmutableMap .of ()))
847+ .put ("live-activity-token" , "test-live-activity-token-image" )
840848 .build ();
841849 ImmutableMap <String , Object > expected =
842850 ImmutableMap .<String , Object >builder ()
@@ -847,6 +855,34 @@ public void testImageInApnsNotification() throws IOException {
847855 assertJsonEquals (expected , message );
848856 }
849857
858+ @ Test
859+ public void testApnsMessageWithOnlyLiveActivityToken () throws IOException {
860+ Message message = Message .builder ()
861+ .setApnsConfig (ApnsConfig .builder ()
862+ .setAps (Aps .builder ().build ())
863+ .setLiveActivityToken ("only-live-activity" )
864+ .build ())
865+ .setTopic ("test-topic" )
866+ .build ();
867+ Map <String , Object > expectedApns = ImmutableMap .<String , Object >builder ()
868+ .put ("live-activity-token" , "only-live-activity" )
869+ .put ("payload" , ImmutableMap .of ("aps" , ImmutableMap .of ()))
870+ .build ();
871+ assertJsonEquals (ImmutableMap .of ("topic" , "test-topic" , "apns" , expectedApns ), message );
872+
873+ // Test without live activity token
874+ message = Message .builder ()
875+ .setApnsConfig (ApnsConfig .builder ()
876+ .setAps (Aps .builder ().build ())
877+ .build ())
878+ .setTopic ("test-topic" )
879+ .build ();
880+ expectedApns = ImmutableMap .<String , Object >builder ()
881+ .put ("payload" , ImmutableMap .of ("aps" , ImmutableMap .of ()))
882+ .build ();
883+ assertJsonEquals (ImmutableMap .of ("topic" , "test-topic" , "apns" , expectedApns ), message );
884+ }
885+
850886 @ Test
851887 public void testInvalidColorInAndroidNotificationLightSettings () {
852888 try {
@@ -923,7 +959,10 @@ public void testExtendedAndroidNotificationParameters() throws IOException {
923959 .build ())
924960 .put ("default_light_settings" , false )
925961 .put ("visibility" , "public" )
926- .put ("notification_count" , new BigDecimal (10 ))
962+ // There is a problem with the JsonParser assignment to BigDecimal takes priority over
963+ // all other number types and so this integer value is interpreted as a BigDecimal
964+ // rather than an Integer.
965+ .put ("notification_count" , BigDecimal .valueOf (10L ))
927966 .put ("proxy" , "DENY" )
928967 .build ())
929968 .build ();
@@ -932,7 +971,7 @@ public void testExtendedAndroidNotificationParameters() throws IOException {
932971 }
933972
934973 private static void assertJsonEquals (
935- Map expected , Object actual ) throws IOException {
974+ Map <?, ?> expected , Object actual ) throws IOException {
936975 assertEquals (expected , toMap (actual ));
937976 }
938977
0 commit comments