@@ -75,6 +75,10 @@ public void Notification()
7575 Title = "title" ,
7676 Body = "body" ,
7777 } ,
78+ FcmOptions = new FcmOptions ( )
79+ {
80+ AnalyticsLabel = "label" ,
81+ } ,
7882 } ;
7983 var expected = new JObject ( )
8084 {
@@ -86,6 +90,12 @@ public void Notification()
8690 { "body" , "body" } ,
8791 }
8892 } ,
93+ {
94+ "fcm_options" , new JObject ( )
95+ {
96+ { "analytics_label" , "label" } ,
97+ }
98+ } ,
8999 } ;
90100 this . AssertJsonEquals ( expected , message ) ;
91101 }
@@ -117,6 +127,10 @@ public void MessageDeserialization()
117127 {
118128 Data = new Dictionary < string , string > ( ) { { "key" , "value" } } ,
119129 } ,
130+ FcmOptions = new FcmOptions ( )
131+ {
132+ AnalyticsLabel = "label" ,
133+ } ,
120134 } ;
121135 var json = NewtonsoftJsonSerializer . Instance . Serialize ( original ) ;
122136 var copy = NewtonsoftJsonSerializer . Instance . Deserialize < Message > ( json ) ;
@@ -128,6 +142,7 @@ public void MessageDeserialization()
128142 original . Android . RestrictedPackageName , copy . Android . RestrictedPackageName ) ;
129143 Assert . Equal ( original . Apns . Aps . AlertString , copy . Apns . Aps . AlertString ) ;
130144 Assert . Equal ( original . Webpush . Data , copy . Webpush . Data ) ;
145+ Assert . Equal ( original . FcmOptions . AnalyticsLabel , copy . FcmOptions . AnalyticsLabel ) ;
131146 }
132147
133148 [ Fact ]
@@ -236,6 +251,10 @@ public void AndroidConfig()
236251 BodyLocArgs = new List < string > ( ) { "arg3" , "arg4" } ,
237252 ChannelId = "channel-id" ,
238253 } ,
254+ FcmOptions = new AndroidFcmOptions ( )
255+ {
256+ AnalyticsLabel = "label" ,
257+ } ,
239258 } ,
240259 } ;
241260 var expected = new JObject ( )
@@ -266,6 +285,12 @@ public void AndroidConfig()
266285 { "channel_id" , "channel-id" } ,
267286 }
268287 } ,
288+ {
289+ "fcm_options" , new JObject ( )
290+ {
291+ { "analytics_label" , "label" } ,
292+ }
293+ } ,
269294 }
270295 } ,
271296 } ;
@@ -843,6 +868,10 @@ public void ApnsConfig()
843868 { "custom-key3" , "custom-data" } ,
844869 { "custom-key4" , true } ,
845870 } ,
871+ FcmOptions = new ApnsFcmOptions ( )
872+ {
873+ AnalyticsLabel = "label" ,
874+ } ,
846875 } ,
847876 } ;
848877 var expected = new JObject ( )
@@ -879,6 +908,12 @@ public void ApnsConfig()
879908 { "custom-key4" , true } ,
880909 }
881910 } ,
911+ {
912+ "fcm_options" , new JObject ( )
913+ {
914+ { "analytics_label" , "label" } ,
915+ }
916+ } ,
882917 }
883918 } ,
884919 } ;
@@ -1650,6 +1685,25 @@ public void WebpushNotificationWithInvalidHttpsLinkUrl()
16501685 Assert . Throws < ArgumentException > ( ( ) => message . CopyAndValidate ( ) ) ;
16511686 }
16521687
1688+ [ Fact ]
1689+ public void AnalyticsLabelInvalid ( )
1690+ {
1691+ var message = new Message ( )
1692+ {
1693+ Topic = "test-topic" ,
1694+ Notification = new Notification ( )
1695+ {
1696+ Title = "title" ,
1697+ Body = "body" ,
1698+ } ,
1699+ FcmOptions = new FcmOptions ( )
1700+ {
1701+ AnalyticsLabel = "label!" ,
1702+ } ,
1703+ } ;
1704+ Assert . Throws < ArgumentException > ( ( ) => message . CopyAndValidate ( ) ) ;
1705+ }
1706+
16531707 private void AssertJsonEquals ( JObject expected , Message actual )
16541708 {
16551709 var json = NewtonsoftJsonSerializer . Instance . Serialize ( actual . CopyAndValidate ( ) ) ;
0 commit comments