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 @@ -124,78 +124,6 @@ public async Task SendEachForMulticast()
Assert.NotNull(response.Responses[1].Exception);
}

[Fact]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to remove this test?

Copy link
Contributor Author

@Doris-Ge Doris-Ge Jul 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Because now SendAllAsync and SendMulticastAsync have been marked as obsolete, these two integration tests will fail: https://github.com/firebase/firebase-admin-dotnet/actions/runs/5661155177/job/15338452380 .
I also tried marking these two tests with "[Ignore]", but it could not build. Any suggestions?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Okay, let's remove them.

public async Task SendAll()
{
var message1 = new Message()
{
Topic = "foo-bar",
Notification = new Notification()
{
Title = "Title",
Body = "Body",
ImageUrl = "https://example.com/image.png",
},
Android = new AndroidConfig()
{
Priority = Priority.Normal,
TimeToLive = TimeSpan.FromHours(1),
RestrictedPackageName = "com.google.firebase.testing",
},
};
var message2 = new Message()
{
Topic = "fiz-buz",
Notification = new Notification()
{
Title = "Title",
Body = "Body",
},
Android = new AndroidConfig()
{
Priority = Priority.Normal,
TimeToLive = TimeSpan.FromHours(1),
RestrictedPackageName = "com.google.firebase.testing",
},
};
var response = await FirebaseMessaging.DefaultInstance.SendAllAsync(new[] { message1, message2 }, dryRun: true);
Assert.NotNull(response);
Assert.Equal(2, response.SuccessCount);
Assert.True(!string.IsNullOrEmpty(response.Responses[0].MessageId));
Assert.Matches(new Regex("^projects/.*/messages/.*$"), response.Responses[0].MessageId);
Assert.True(!string.IsNullOrEmpty(response.Responses[1].MessageId));
Assert.Matches(new Regex("^projects/.*/messages/.*$"), response.Responses[1].MessageId);
}

[Fact]
public async Task SendMulticast()
{
var multicastMessage = new MulticastMessage
{
Notification = new Notification()
{
Title = "Title",
Body = "Body",
},
Android = new AndroidConfig()
{
Priority = Priority.Normal,
TimeToLive = TimeSpan.FromHours(1),
RestrictedPackageName = "com.google.firebase.testing",
},
Tokens = new[]
{
"token1",
"token2",
},
};
var response = await FirebaseMessaging.DefaultInstance.SendMulticastAsync(multicastMessage, dryRun: true);
Assert.NotNull(response);
Assert.Equal(2, response.FailureCount);
Assert.NotNull(response.Responses[0].Exception);
Assert.NotNull(response.Responses[1].Exception);
}

[Fact]
public async Task SubscribeToTopic()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ internal static async Task SendDryRunAsync()
// [END send_dry_run]
}

internal static async Task SendAllAsync()
internal static async Task SendEachAsync()
{
var registrationToken = "YOUR_REGISTRATION_TOKEN";
// [START send_all]
Expand All @@ -144,14 +144,14 @@ internal static async Task SendAllAsync()
},
};

var response = await FirebaseMessaging.DefaultInstance.SendAllAsync(messages);
var response = await FirebaseMessaging.DefaultInstance.SendEachAsync(messages);
// See the BatchResponse reference documentation
// for the contents of response.
Console.WriteLine($"{response.SuccessCount} messages were sent successfully");
// [END send_all]
}

internal static async Task SendMulticastAsync()
internal static async Task SendEachForMulticastAsync()
{
// [START send_multicast]
// Create a list containing up to 500 registration tokens.
Expand All @@ -172,14 +172,14 @@ internal static async Task SendMulticastAsync()
},
};

var response = await FirebaseMessaging.DefaultInstance.SendMulticastAsync(message);
var response = await FirebaseMessaging.DefaultInstance.SendEachForMulticastAsync(message);
// See the BatchResponse reference documentation
// for the contents of response.
Console.WriteLine($"{response.SuccessCount} messages were sent successfully");
// [END send_multicast]
}

internal static async Task SendMulticastAndHandleErrorsAsync()
internal static async Task SendEachForMulticastAndHandleErrorsAsync()
{
// [START send_multicast_error]
// These registration tokens come from the client FCM SDKs.
Expand All @@ -199,7 +199,7 @@ internal static async Task SendMulticastAndHandleErrorsAsync()
},
};

var response = await FirebaseMessaging.DefaultInstance.SendMulticastAsync(message);
var response = await FirebaseMessaging.DefaultInstance.SendEachForMulticastAsync(message);
if (response.FailureCount > 0)
{
var failedTokens = new List<string>();
Expand Down
16 changes: 8 additions & 8 deletions FirebaseAdmin/FirebaseAdmin/Messaging/FirebaseMessaging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ public async Task<BatchResponse> SendEachForMulticastAsync(
/// <param name="messages">Up to 500 messages to send in the batch. Cannot be null.</param>
/// <returns>A <see cref="BatchResponse"/> containing details of the batch operation's
/// outcome.</returns>
/// [Obsolete(Use <see cref="SendEachAsync(IEnumerable{Message})"/> instead)]
[Obsolete("Use SendEachAsync(IEnumerable{Message} instead")]
public async Task<BatchResponse> SendAllAsync(IEnumerable<Message> messages)
{
return await this.SendAllAsync(messages, false)
Expand All @@ -362,7 +362,7 @@ public async Task<BatchResponse> SendAllAsync(IEnumerable<Message> messages)
/// operation.</param>
/// <returns>A <see cref="BatchResponse"/> containing details of the batch operation's
/// outcome.</returns>
/// [Obsolete(Use <see cref="SendEachAsync(IEnumerable{Message}, CancellationToken)"/> instead)]
[Obsolete("Use SendEachAsync(IEnumerable{Message}, CancellationToken) instead")]
public async Task<BatchResponse> SendAllAsync(IEnumerable<Message> messages, CancellationToken cancellationToken)
{
return await this.SendAllAsync(messages, false, cancellationToken)
Expand All @@ -382,7 +382,7 @@ public async Task<BatchResponse> SendAllAsync(IEnumerable<Message> messages, Can
/// but it will not be delivered to any actual recipients.</param>
/// <returns>A <see cref="BatchResponse"/> containing details of the batch operation's
/// outcome.</returns>
/// [Obsolete(Use <see cref="SendEachAsync(IEnumerable{Message}, bool)"/> instead)]
[Obsolete("Use SendEachAsync(IEnumerable{Message}, bool) instead")]
public async Task<BatchResponse> SendAllAsync(IEnumerable<Message> messages, bool dryRun)
{
return await this.SendAllAsync(messages, dryRun, default)
Expand All @@ -404,7 +404,7 @@ public async Task<BatchResponse> SendAllAsync(IEnumerable<Message> messages, boo
/// operation.</param>
/// <returns>A <see cref="BatchResponse"/> containing details of the batch operation's
/// outcome.</returns>
/// [Obsolete(Use <see cref="SendEachAsync(IEnumerable{Message}, bool, CancellationToken)"/> instead)]
[Obsolete("Use SendEachAsync(IEnumerable{Message}, bool, CancellationToken) instead")]
public async Task<BatchResponse> SendAllAsync(IEnumerable<Message> messages, bool dryRun, CancellationToken cancellationToken)
{
return await this.messagingClient.SendAllAsync(messages, dryRun, cancellationToken)
Expand All @@ -419,7 +419,7 @@ public async Task<BatchResponse> SendAllAsync(IEnumerable<Message> messages, boo
/// <param name="message">The message to be sent. Must not be null.</param>
/// <returns>A <see cref="BatchResponse"/> containing details of the batch operation's
/// outcome.</returns>
/// [Obsolete(Use <see cref="SendEachForMulticastAsync(MulticastMessage)"/> instead)]
[Obsolete("Use SendEachForMulticastAsync(MulticastMessage) instead")]
public async Task<BatchResponse> SendMulticastAsync(MulticastMessage message)
{
return await this.SendMulticastAsync(message, false)
Expand All @@ -436,7 +436,7 @@ public async Task<BatchResponse> SendMulticastAsync(MulticastMessage message)
/// operation.</param>
/// <returns>A <see cref="BatchResponse"/> containing details of the batch operation's
/// outcome.</returns>
/// [Obsolete(Use <see cref="SendEachForMulticastAsync(MulticastMessage, CancellationToken)"/> instead)]
[Obsolete("Use SendEachForMulticastAsync(MulticastMessage, CancellationToken) instead")]
public async Task<BatchResponse> SendMulticastAsync(MulticastMessage message, CancellationToken cancellationToken)
{
return await this.SendMulticastAsync(message, false, cancellationToken)
Expand All @@ -458,7 +458,7 @@ public async Task<BatchResponse> SendMulticastAsync(MulticastMessage message, Ca
/// but it will not be delivered to any actual recipients.</param>
/// <returns>A <see cref="BatchResponse"/> containing details of the batch operation's
/// outcome.</returns>
/// [Obsolete(Use <see cref="SendEachForMulticastAsync(MulticastMessage, bool)"/> instead)]
[Obsolete("Use SendEachForMulticastAsync(MulticastMessage, bool) instead")]
public async Task<BatchResponse> SendMulticastAsync(MulticastMessage message, bool dryRun)
{
return await this.SendMulticastAsync(message, dryRun, default)
Expand All @@ -482,7 +482,7 @@ public async Task<BatchResponse> SendMulticastAsync(MulticastMessage message, bo
/// operation.</param>
/// <returns>A <see cref="BatchResponse"/> containing details of the batch operation's
/// outcome.</returns>
/// [Obsolete(Use <see cref="SendEachForMulticastAsync(MulticastMessage, bool, CancellationToken)"/> instead)]
[Obsolete("Use SendEachForMulticastAsync(MulticastMessage, bool, CancellationToken) instead")]
public async Task<BatchResponse> SendMulticastAsync(
MulticastMessage message, bool dryRun, CancellationToken cancellationToken)
{
Expand Down