Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend web push support #320

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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 @@ -15,6 +15,7 @@

namespace Microsoft.Azure.NotificationHubs
{
[DataContract(Name = ManagementStrings.BrowserTemplateRegistrationDescription, Namespace = ManagementStrings.Namespace)]
public class BrowserTemplateRegistrationDescription : BrowserRegistrationDescription
{
/// <summary>
Expand Down
109 changes: 109 additions & 0 deletions src/Microsoft.Azure.NotificationHubs/INotificationHubClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,54 @@ public interface INotificationHubClient
/// <returns>A task that represents the asynchronous operation.</returns>
Task<BaiduTemplateRegistrationDescription> CreateBaiduTemplateRegistrationAsync(string userId, string channelId, string jsonPayload, IEnumerable<string> tags);

/// <summary>
/// Asynchronously creates a browser native registration.
/// </summary>
/// <param name="endpoint">String containing the endpoint associated with the push subscription.</param>
/// <param name="auth">Value used to retrieve the authentication secret.</param>
/// <param name="p256dh">Value used to retrieve the public key.</param>
/// <returns>
/// The task that completes the asynchronous operation.
/// </returns>
Task<BrowserRegistrationDescription> CreateBrowserNativeRegistrationAsync(string endpoint, string auth, string p256dh);

/// <summary>
/// Asynchronously creates a browser native registration.
/// </summary>
/// <param name="endpoint">String containing the endpoint associated with the push subscription.</param>
/// <param name="auth">Value used to retrieve the authentication secret.</param>
/// <param name="p256dh">Value used to retrieve the public key.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> to observe while waiting for a task to complete.</param>
/// <returns>
/// The task that completes the asynchronous operation.
/// </returns>
Task<BrowserRegistrationDescription> CreateBrowserNativeRegistrationAsync(string endpoint, string auth, string p256dh, CancellationToken cancellationToken);

/// <summary>
/// Asynchronously creates a browser native registration.
/// </summary>
/// <param name="endpoint">String containing the endpoint associated with the push subscription.</param>
/// <param name="auth">Value used to retrieve the authentication secret.</param>
/// <param name="p256dh">Value used to retrieve the public key.</param>
/// <param name="tags">The tags.</param>
/// <returns>
/// The task that completes the asynchronous operation.
/// </returns>
Task<BrowserRegistrationDescription> CreateBrowserNativeRegistrationAsync(string endpoint, string auth, string p256dh, IEnumerable<string> tags);

/// <summary>
/// Asynchronously creates a browser native registration.
/// </summary>
/// <param name="endpoint">String containing the endpoint associated with the push subscription.</param>
/// <param name="auth">Value used to retrieve the authentication secret.</param>
/// <param name="p256dh">Value used to retrieve the public key.</param>
/// <param name="tags">The tags.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> to observe while waiting for a task to complete.</param>
/// <returns>
/// The task that completes the asynchronous operation.
/// </returns>
Task<BrowserRegistrationDescription> CreateBrowserNativeRegistrationAsync(string endpoint, string auth, string p256dh, IEnumerable<string> tags, CancellationToken cancellationToken);

/// <summary>
/// Asynchronously creates FCM native registration.
/// </summary>
Expand Down Expand Up @@ -1340,6 +1388,67 @@ public interface INotificationHubClient
/// </returns>
Task<NotificationOutcome> SendBaiduNativeNotificationAsync(string message, string tagExpression, CancellationToken cancellationToken);

/// <summary>
/// Sends a browser notification. To specify an expiry, use the <see cref="M:Microsoft.Azure.NotificationHubs.NotificationHubClient.SendNotificationAsync(Microsoft.Azure.NotificationHubs.Notification)" /> method.
/// </summary>
/// <param name="jsonPayload">This is a valid browser push notification payload.</param>
/// <returns>
/// <see cref="Microsoft.Azure.NotificationHubs.NotificationOutcome" /> which describes the result of the Send operation.
/// </returns>
Task<NotificationOutcome> SendBrowserNotificationAsync(string jsonPayload);

/// <summary>
/// Sends a browser notification. To specify an expiry, use the <see cref="M:Microsoft.Azure.NotificationHubs.NotificationHubClient.SendNotificationAsync(Microsoft.Azure.NotificationHubs.Notification)" /> method.
/// </summary>
/// <param name="jsonPayload">This is a valid browser push notification payload.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> to observe while waiting for a task to complete.</param>
/// <returns>
/// <see cref="Microsoft.Azure.NotificationHubs.NotificationOutcome" /> which describes the result of the Send operation.
/// </returns>
Task<NotificationOutcome> SendBrowserNotificationAsync(string jsonPayload, CancellationToken cancellationToken);

/// <summary>
/// Sends a browser notification. To specify an expiry, use the <see cref="M:Microsoft.Azure.NotificationHubs.NotificationHubClient.SendNotificationAsync(Microsoft.Azure.NotificationHubs.Notification)" /> method.
/// </summary>
/// <param name="jsonPayload">This is a valid browser push notification payload.</param>
/// <param name="tags">A non-empty set of tags (maximum 20 tags). Each string in the set can contain a single tag.</param>
/// <returns>
/// <see cref="Microsoft.Azure.NotificationHubs.NotificationOutcome" /> which describes the result of the Send operation.
/// </returns>
Task<NotificationOutcome> SendBrowserNotificationAsync(string jsonPayload, IEnumerable<string> tags);

/// <summary>
/// Sends a browser notification. To specify an expiry, use the <see cref="M:Microsoft.Azure.NotificationHubs.NotificationHubClient.SendNotificationAsync(Microsoft.Azure.NotificationHubs.Notification)" /> method.
/// </summary>
/// <param name="jsonPayload">This is a valid browser push notification payload.</param>
/// <param name="tags">A non-empty set of tags (maximum 20 tags). Each string in the set can contain a single tag.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> to observe while waiting for a task to complete.</param>
/// <returns>
/// <see cref="Microsoft.Azure.NotificationHubs.NotificationOutcome" /> which describes the result of the Send operation.
/// </returns>
Task<NotificationOutcome> SendBrowserNotificationAsync(string jsonPayload, IEnumerable<string> tags, CancellationToken cancellationToken);

/// <summary>
/// Sends a browser notification. To specify an expiry, use the <see cref="M:Microsoft.Azure.NotificationHubs.NotificationHubClient.SendNotificationAsync(Microsoft.Azure.NotificationHubs.Notification)" /> method.
/// </summary>
/// <param name="jsonPayload">This is a valid browser push notification payload.</param>
/// <param name="tagExpression">A tag expression is any boolean expression constructed using the logical operators AND (&amp;&amp;), OR (||), NOT (!), and round parentheses. For example: (A || B) &amp;&amp; !C. If an expression uses only ORs, it can contain at most 20 tags. Other expressions are limited to 6 tags. Note that a single tag "A" is a valid expression.</param>
/// <returns>
/// <see cref="Microsoft.Azure.NotificationHubs.NotificationOutcome" /> which describes the result of the Send operation.
/// </returns>
Task<NotificationOutcome> SendBrowserNotificationAsync(string jsonPayload, string tagExpression);

/// <summary>
/// Sends a browser notification. To specify an expiry, use the <see cref="M:Microsoft.Azure.NotificationHubs.NotificationHubClient.SendNotificationAsync(Microsoft.Azure.NotificationHubs.Notification)" /> method.
/// </summary>
/// <param name="jsonPayload">This is a valid browser push notification payload.</param>
/// <param name="tagExpression">A tag expression is any boolean expression constructed using the logical operators AND (&amp;&amp;), OR (||), NOT (!), and round parentheses. For example: (A || B) &amp;&amp; !C. If an expression uses only ORs, it can contain at most 20 tags. Other expressions are limited to 6 tags. Note that a single tag "A" is a valid expression.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> to observe while waiting for a task to complete.</param>
/// <returns>
/// <see cref="Microsoft.Azure.NotificationHubs.NotificationOutcome" /> which describes the result of the Send operation.
/// </returns>
Task<NotificationOutcome> SendBrowserNotificationAsync(string jsonPayload, string tagExpression, CancellationToken cancellationToken);

/// <summary>
/// Sends a notification directly to all devices listed in deviceHandles (a valid tokens as expressed by the Notification type).
/// Users of this API do not use Registrations or Installations. Instead, users of this API manage all devices
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ public EntityDescriptionSerializer()
typeof(BaiduTemplateRegistrationDescription).Name,
this.CreateSerializer<BaiduTemplateRegistrationDescription>());

this.entirySerializers.Add(
typeof(BrowserRegistrationDescription).Name,
this.CreateSerializer<BrowserRegistrationDescription>());

this.entirySerializers.Add(
typeof(BrowserTemplateRegistrationDescription).Name,
this.CreateSerializer<BrowserTemplateRegistrationDescription>());

this.entirySerializers.Add(
typeof(NotificationHubJob).Name,
this.CreateSerializer<NotificationHubJob>());
Expand Down
Loading