diff --git a/FirebaseAdmin/FirebaseAdmin.IntegrationTests/FirebaseMessagingTest.cs b/FirebaseAdmin/FirebaseAdmin.IntegrationTests/FirebaseMessagingTest.cs index aeaf1798..7e9afc42 100644 --- a/FirebaseAdmin/FirebaseAdmin.IntegrationTests/FirebaseMessagingTest.cs +++ b/FirebaseAdmin/FirebaseAdmin.IntegrationTests/FirebaseMessagingTest.cs @@ -45,6 +45,7 @@ public async Task Send() Priority = Priority.Normal, TimeToLive = TimeSpan.FromHours(1), RestrictedPackageName = "com.google.firebase.testing", + DirectBootOk = true, }, }; var id = await FirebaseMessaging.DefaultInstance.SendAsync(message, dryRun: true); @@ -69,6 +70,7 @@ public async Task SendEach() Priority = Priority.Normal, TimeToLive = TimeSpan.FromHours(1), RestrictedPackageName = "com.google.firebase.testing", + DirectBootOk = false, }, }; var message2 = new Message() @@ -84,6 +86,7 @@ public async Task SendEach() Priority = Priority.Normal, TimeToLive = TimeSpan.FromHours(1), RestrictedPackageName = "com.google.firebase.testing", + DirectBootOk = true, }, }; var response = await FirebaseMessaging.DefaultInstance.SendEachAsync(new[] { message1, message2 }, dryRun: true); diff --git a/FirebaseAdmin/FirebaseAdmin.Tests/Messaging/MessageTest.cs b/FirebaseAdmin/FirebaseAdmin.Tests/Messaging/MessageTest.cs index aca5ea8a..fbf190a9 100644 --- a/FirebaseAdmin/FirebaseAdmin.Tests/Messaging/MessageTest.cs +++ b/FirebaseAdmin/FirebaseAdmin.Tests/Messaging/MessageTest.cs @@ -260,6 +260,7 @@ public void AndroidConfig() { "k1", "v1" }, { "k2", "v2" }, }, + DirectBootOk = true, Notification = new AndroidNotification() { Title = "title", @@ -310,6 +311,7 @@ public void AndroidConfig() { "ttl", "0.010000000s" }, { "restricted_package_name", "test-pkg-name" }, { "data", new JObject() { { "k1", "v1" }, { "k2", "v2" } } }, + { "direct_boot_ok", true }, { "notification", new JObject() { @@ -424,6 +426,7 @@ public void AndroidConfigDeserialization() { { "key", "value" }, }, + DirectBootOk = false, Notification = new AndroidNotification() { Title = "title", @@ -437,6 +440,7 @@ public void AndroidConfigDeserialization() Assert.Equal(original.Priority, copy.Priority); Assert.Equal(original.TimeToLive, copy.TimeToLive); Assert.Equal(original.Data, copy.Data); + Assert.Equal(original.DirectBootOk, copy.DirectBootOk); Assert.Equal(original.Notification.Title, copy.Notification.Title); } diff --git a/FirebaseAdmin/FirebaseAdmin/Messaging/AndroidConfig.cs b/FirebaseAdmin/FirebaseAdmin/Messaging/AndroidConfig.cs index b52141a3..a67fa054 100644 --- a/FirebaseAdmin/FirebaseAdmin/Messaging/AndroidConfig.cs +++ b/FirebaseAdmin/FirebaseAdmin/Messaging/AndroidConfig.cs @@ -60,6 +60,13 @@ public sealed class AndroidConfig [JsonProperty("data")] public IReadOnlyDictionary Data { get; set; } + /// + /// Gets or sets a boolean indicating whether messages will be allowed to be delivered to + /// the app while the device is in direct boot mode. + /// + [JsonProperty("direct_boot_ok")] + public bool? DirectBootOk { get; set; } + /// /// Gets or sets the Android notification to be included in the message. /// @@ -165,6 +172,7 @@ internal AndroidConfig CopyAndValidate() TimeToLive = this.TimeToLive, RestrictedPackageName = this.RestrictedPackageName, Data = this.Data?.Copy(), + DirectBootOk = this.DirectBootOk, FcmOptions = this.FcmOptions?.CopyAndValidate(), }; var totalSeconds = copy.TimeToLive?.TotalSeconds ?? 0;