diff --git a/src/Microsoft.Azure.NotificationHubs/BrowserTemplateRegistrationDescription.cs b/src/Microsoft.Azure.NotificationHubs/BrowserTemplateRegistrationDescription.cs index 2ed51f8..2d20778 100644 --- a/src/Microsoft.Azure.NotificationHubs/BrowserTemplateRegistrationDescription.cs +++ b/src/Microsoft.Azure.NotificationHubs/BrowserTemplateRegistrationDescription.cs @@ -15,6 +15,7 @@ namespace Microsoft.Azure.NotificationHubs { + [DataContract(Name = ManagementStrings.BrowserTemplateRegistrationDescription, Namespace = ManagementStrings.Namespace)] public class BrowserTemplateRegistrationDescription : BrowserRegistrationDescription { /// diff --git a/src/Microsoft.Azure.NotificationHubs/INotificationHubClient.cs b/src/Microsoft.Azure.NotificationHubs/INotificationHubClient.cs index f8d542e..26d5265 100644 --- a/src/Microsoft.Azure.NotificationHubs/INotificationHubClient.cs +++ b/src/Microsoft.Azure.NotificationHubs/INotificationHubClient.cs @@ -249,6 +249,54 @@ public interface INotificationHubClient /// A task that represents the asynchronous operation. Task CreateBaiduTemplateRegistrationAsync(string userId, string channelId, string jsonPayload, IEnumerable tags); + /// + /// Asynchronously creates a browser native registration. + /// + /// String containing the endpoint associated with the push subscription. + /// Value used to retrieve the authentication secret. + /// Value used to retrieve the public key. + /// + /// The task that completes the asynchronous operation. + /// + Task CreateBrowserNativeRegistrationAsync(string endpoint, string auth, string p256dh); + + /// + /// Asynchronously creates a browser native registration. + /// + /// String containing the endpoint associated with the push subscription. + /// Value used to retrieve the authentication secret. + /// Value used to retrieve the public key. + /// A to observe while waiting for a task to complete. + /// + /// The task that completes the asynchronous operation. + /// + Task CreateBrowserNativeRegistrationAsync(string endpoint, string auth, string p256dh, CancellationToken cancellationToken); + + /// + /// Asynchronously creates a browser native registration. + /// + /// String containing the endpoint associated with the push subscription. + /// Value used to retrieve the authentication secret. + /// Value used to retrieve the public key. + /// The tags. + /// + /// The task that completes the asynchronous operation. + /// + Task CreateBrowserNativeRegistrationAsync(string endpoint, string auth, string p256dh, IEnumerable tags); + + /// + /// Asynchronously creates a browser native registration. + /// + /// String containing the endpoint associated with the push subscription. + /// Value used to retrieve the authentication secret. + /// Value used to retrieve the public key. + /// The tags. + /// A to observe while waiting for a task to complete. + /// + /// The task that completes the asynchronous operation. + /// + Task CreateBrowserNativeRegistrationAsync(string endpoint, string auth, string p256dh, IEnumerable tags, CancellationToken cancellationToken); + /// /// Asynchronously creates FCM native registration. /// @@ -1340,6 +1388,67 @@ public interface INotificationHubClient /// Task SendBaiduNativeNotificationAsync(string message, string tagExpression, CancellationToken cancellationToken); + /// + /// Sends a browser notification. To specify an expiry, use the method. + /// + /// This is a valid browser push notification payload. + /// + /// which describes the result of the Send operation. + /// + Task SendBrowserNotificationAsync(string jsonPayload); + + /// + /// Sends a browser notification. To specify an expiry, use the method. + /// + /// This is a valid browser push notification payload. + /// A to observe while waiting for a task to complete. + /// + /// which describes the result of the Send operation. + /// + Task SendBrowserNotificationAsync(string jsonPayload, CancellationToken cancellationToken); + + /// + /// Sends a browser notification. To specify an expiry, use the method. + /// + /// This is a valid browser push notification payload. + /// A non-empty set of tags (maximum 20 tags). Each string in the set can contain a single tag. + /// + /// which describes the result of the Send operation. + /// + Task SendBrowserNotificationAsync(string jsonPayload, IEnumerable tags); + + /// + /// Sends a browser notification. To specify an expiry, use the method. + /// + /// This is a valid browser push notification payload. + /// A non-empty set of tags (maximum 20 tags). Each string in the set can contain a single tag. + /// A to observe while waiting for a task to complete. + /// + /// which describes the result of the Send operation. + /// + Task SendBrowserNotificationAsync(string jsonPayload, IEnumerable tags, CancellationToken cancellationToken); + + /// + /// Sends a browser notification. To specify an expiry, use the method. + /// + /// This is a valid browser push notification payload. + /// A tag expression is any boolean expression constructed using the logical operators AND (&&), OR (||), NOT (!), and round parentheses. For example: (A || B) && !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. + /// + /// which describes the result of the Send operation. + /// + Task SendBrowserNotificationAsync(string jsonPayload, string tagExpression); + + /// + /// Sends a browser notification. To specify an expiry, use the method. + /// + /// This is a valid browser push notification payload. + /// A tag expression is any boolean expression constructed using the logical operators AND (&&), OR (||), NOT (!), and round parentheses. For example: (A || B) && !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. + /// A to observe while waiting for a task to complete. + /// + /// which describes the result of the Send operation. + /// + Task SendBrowserNotificationAsync(string jsonPayload, string tagExpression, CancellationToken cancellationToken); + /// /// 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 diff --git a/src/Microsoft.Azure.NotificationHubs/Messaging/EntityDescriptionSerializer.cs b/src/Microsoft.Azure.NotificationHubs/Messaging/EntityDescriptionSerializer.cs index c4b11dc..52f2932 100644 --- a/src/Microsoft.Azure.NotificationHubs/Messaging/EntityDescriptionSerializer.cs +++ b/src/Microsoft.Azure.NotificationHubs/Messaging/EntityDescriptionSerializer.cs @@ -97,6 +97,14 @@ public EntityDescriptionSerializer() typeof(BaiduTemplateRegistrationDescription).Name, this.CreateSerializer()); + this.entirySerializers.Add( + typeof(BrowserRegistrationDescription).Name, + this.CreateSerializer()); + + this.entirySerializers.Add( + typeof(BrowserTemplateRegistrationDescription).Name, + this.CreateSerializer()); + this.entirySerializers.Add( typeof(NotificationHubJob).Name, this.CreateSerializer()); diff --git a/src/Microsoft.Azure.NotificationHubs/NotificationHubClient.cs b/src/Microsoft.Azure.NotificationHubs/NotificationHubClient.cs index c3cb50f..298599f 100644 --- a/src/Microsoft.Azure.NotificationHubs/NotificationHubClient.cs +++ b/src/Microsoft.Azure.NotificationHubs/NotificationHubClient.cs @@ -787,6 +787,85 @@ public Task SendBaiduNativeNotificationAsync(string message return SendNotificationAsync(new BaiduNotification(message), tags, cancellationToken); } + /// + /// Sends a browser notification. To specify an expiry, use the method. + /// + /// This is a valid browser push notification payload. + /// + /// which describes the result of the Send operation. + /// + public Task SendBrowserNotificationAsync(string jsonPayload) + { + return SendNotificationAsync(new BrowserNotification(jsonPayload)); + } + + /// + /// Sends a browser notification. To specify an expiry, use the method. + /// + /// This is a valid browser push notification payload. + /// A to observe while waiting for a task to complete. + /// + /// which describes the result of the Send operation. + /// + public Task SendBrowserNotificationAsync(string jsonPayload, CancellationToken cancellationToken) + { + return SendNotificationAsync(new BrowserNotification(jsonPayload), cancellationToken); + } + + /// + /// Sends a browser notification. To specify an expiry, use the method. + /// + /// This is a valid browser push notification payload. + /// A non-empty set of tags (maximum 20 tags). Each string in the set can contain a single tag. + /// + /// which describes the result of the Send operation. + /// + public Task SendBrowserNotificationAsync(string jsonPayload, IEnumerable tags) + { + return SendNotificationAsync(new BrowserNotification(jsonPayload), tags); + } + + /// + /// Sends a browser notification. To specify an expiry, use the method. + /// + /// This is a valid browser push notification payload. + /// A non-empty set of tags (maximum 20 tags). Each string in the set can contain a single tag. + /// A to observe while waiting for a task to complete. + /// + /// which describes the result of the Send operation. + /// + public Task SendBrowserNotificationAsync(string jsonPayload, IEnumerable tags, CancellationToken cancellationToken) + { + return SendNotificationAsync(new BrowserNotification(jsonPayload), tags, cancellationToken); + } + + /// + /// Sends a browser notification. To specify an expiry, use the method. + /// + /// This is a valid browser push notification payload. + /// A tag expression is any boolean expression constructed using the logical operators AND (&&), OR (||), NOT (!), and round parentheses. For example: (A || B) && !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. + /// + /// which describes the result of the Send operation. + /// + public Task SendBrowserNotificationAsync(string jsonPayload, string tagExpression) + { + return SendNotificationAsync(new BrowserNotification(jsonPayload), tagExpression); + } + + /// + /// Sends a browser notification. To specify an expiry, use the method. + /// + /// This is a valid browser push notification payload. + /// A tag expression is any boolean expression constructed using the logical operators AND (&&), OR (||), NOT (!), and round parentheses. For example: (A || B) && !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. + /// A to observe while waiting for a task to complete. + /// + /// which describes the result of the Send operation. + /// + public Task SendBrowserNotificationAsync(string jsonPayload, string tagExpression, CancellationToken cancellationToken) + { + return SendNotificationAsync(new BrowserNotification(jsonPayload), tagExpression, cancellationToken); + } + /// /// Sends the Amazon Device Messaging (ADM) native notification. /// @@ -2141,6 +2220,66 @@ public Task CreateBaiduTemplateRegistratio #endregion + /// + /// Asynchronously creates browser registration. + /// + /// String containing the endpoint associated with the push subscription. + /// Value used to retrieve the authentication secret. + /// Value used to retrieve the public key. + /// + /// The task that completes the asynchronous operation. + /// + public Task CreateBrowserNativeRegistrationAsync(string endpoint, string auth, string p256dh) + { + return CreateRegistrationAsync(new BrowserRegistrationDescription(new BrowserPushSubscription { Auth = auth, Endpoint = endpoint, P256DH = p256dh })); + } + + /// + /// Asynchronously creates browser registration. + /// + /// String containing the endpoint associated with the push subscription. + /// Value used to retrieve the authentication secret. + /// Value used to retrieve the public key. + /// A to observe while waiting for a task to complete. + /// + /// The task that completes the asynchronous operation. + /// + public Task CreateBrowserNativeRegistrationAsync(string endpoint, string auth, string p256dh, CancellationToken cancellationToken) + { + return CreateRegistrationAsync(new BrowserRegistrationDescription(new BrowserPushSubscription { Auth = auth, Endpoint = endpoint, P256DH = p256dh }), cancellationToken); + } + + /// + /// Asynchronously creates browser registration. + /// + /// String containing the endpoint associated with the push subscription. + /// Value used to retrieve the authentication secret. + /// Value used to retrieve the public key. + /// The tags. + /// + /// The task that completes the asynchronous operation. + /// + public Task CreateBrowserNativeRegistrationAsync(string endpoint, string auth, string p256dh, IEnumerable tags) + { + return CreateRegistrationAsync(new BrowserRegistrationDescription(new BrowserPushSubscription { Auth = auth, Endpoint = endpoint, P256DH = p256dh }, tags)); + } + + /// + /// Asynchronously creates browser registration. + /// + /// String containing the endpoint associated with the push subscription. + /// Value used to retrieve the authentication secret. + /// Value used to retrieve the public key. + /// The tags. + /// A to observe while waiting for a task to complete. + /// + /// The task that completes the asynchronous operation. + /// + public Task CreateBrowserNativeRegistrationAsync(string endpoint, string auth, string p256dh, IEnumerable tags, CancellationToken cancellationToken) + { + return CreateRegistrationAsync(new BrowserRegistrationDescription(new BrowserPushSubscription { Auth = auth, Endpoint = endpoint, P256DH = p256dh }, tags), cancellationToken); + } + /// /// Asynchronously creates MPNS native registration. /// diff --git a/src/Microsoft.Azure.NotificationHubs/RegistrationDescription.cs b/src/Microsoft.Azure.NotificationHubs/RegistrationDescription.cs index 1b8ec3d..de7d314 100644 --- a/src/Microsoft.Azure.NotificationHubs/RegistrationDescription.cs +++ b/src/Microsoft.Azure.NotificationHubs/RegistrationDescription.cs @@ -40,6 +40,8 @@ namespace Microsoft.Azure.NotificationHubs [KnownType(typeof(BaiduTemplateRegistrationDescription))] [KnownType(typeof(FcmV1RegistrationDescription))] [KnownType(typeof(FcmV1TemplateRegistrationDescription))] + [KnownType(typeof(BrowserRegistrationDescription))] + [KnownType(typeof(BrowserTemplateRegistrationDescription))] public abstract class RegistrationDescription : EntityDescription { internal const string TemplateRegistrationType = "template";