Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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()
Expand All @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions FirebaseAdmin/FirebaseAdmin.Tests/Messaging/MessageTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ public void AndroidConfig()
{ "k1", "v1" },
{ "k2", "v2" },
},
DirectBootOk = true,
Notification = new AndroidNotification()
{
Title = "title",
Expand Down Expand Up @@ -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()
{
Expand Down Expand Up @@ -424,6 +426,7 @@ public void AndroidConfigDeserialization()
{
{ "key", "value" },
},
DirectBootOk = false,
Notification = new AndroidNotification()
{
Title = "title",
Expand All @@ -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);
}

Expand Down
8 changes: 8 additions & 0 deletions FirebaseAdmin/FirebaseAdmin/Messaging/AndroidConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ public sealed class AndroidConfig
[JsonProperty("data")]
public IReadOnlyDictionary<string, string> Data { get; set; }

/// <summary>
/// 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.
/// </summary>
[JsonProperty("direct_boot_ok")]
public bool? DirectBootOk { get; set; }

/// <summary>
/// Gets or sets the Android notification to be included in the message.
/// </summary>
Expand Down Expand Up @@ -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;
Expand Down