Skip to content
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ This section details the usage of the Azure Notification Hubs SDK for .NET manag
### Create a namespace manager

```csharp
var namespaceManager = new NamespaceManagerClient("connection string");
var namespaceManager = new NamespaceManager("connection string");
```

### Create an Azure Notification Hub
Expand All @@ -80,7 +80,7 @@ var hub = await namespaceManager.GetNotificationHubAsync("hubname", Cancellation
### Update an Azure Notification Hub

```csharp
hub.FcmCredential = new FcmCredential("key");
hub.FcmV1Credential = new FcmV1Credential("private-key", "project-id", "client-email");
hub = await namespaceManager.UpdateNotificationHubAsync(hub, CancellationToken.None);
```

Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"MSBuild.Sdk.Extras": "3.0.44"
},
"sdk": {
"version": "6.0.100",
"version": "6.0.*",
"rollForward": "feature"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for
// license information.
//------------------------------------------------------------

Expand Down Expand Up @@ -75,7 +75,7 @@ public async Task RetryPolicyRetriesConnectionErrors()
public async Task RetryPolicyRetriesOnThrottling()
{
_mockHttp.Expect("https://sample.servicebus.windows.net/hub-name")
.Respond((HttpStatusCode)403, new Dictionary<string, string> { { "Retry-After", "1" }}, new StringContent(""));
.Respond((HttpStatusCode)403, new Dictionary<string, string> { { "Retry-After", "1" } }, new StringContent(""));
_mockHttp.Expect("https://sample.servicebus.windows.net/hub-name")
.Respond((HttpStatusCode)429, new Dictionary<string, string> { { "Retry-After", "1" } }, new StringContent(""));
_mockHttp.Expect("https://sample.servicebus.windows.net/hub-name")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public void NotificationContentTypeCorrespondsToApi()
{
Assert.Equal($"application/json;charset={Encoding.UTF8.WebName}", new AppleNotification("{\"aps\":{\"alert\":\"alert!\"}}").ContentType);
Assert.Equal($"application/json;charset={Encoding.UTF8.WebName}", new FcmNotification("{\"data\":{\"message\":\"Message\"}}").ContentType);
Assert.Equal($"application/json;charset={Encoding.UTF8.WebName}", new FcmV1Notification("{\"data\":{\"message\":\"Message\"}}").ContentType);
Assert.Equal($"application/json;charset={Encoding.UTF8.WebName}", new FcmV1Notification("{\"message\":{\"data\":{\"message\":\"Message\"}}}").ContentType);
Assert.Equal($"application/xml;charset={Encoding.UTF8.WebName}", new MpnsNotification("<wp:Notification xmlns:wp=\"WPNotification\" Version=\"2.0\"><wp:Tile Id=\"TileId\" Template=\"IconicTile\"><wp:Title Action=\"Clear\">Title</wp:Title></wp:Tile></wp:Notification>").ContentType);
Assert.Equal("application/xml", new WindowsNotification("<toast><visual><binding template=\"ToastText01\"><text id=\"1\">bodyText</text></binding> </visual></toast>").ContentType);
Assert.Equal($"application/json;charset={Encoding.UTF8.WebName}", new TemplateNotification(new Dictionary<string, string>()).ContentType);
Expand Down
222 changes: 206 additions & 16 deletions src/Microsoft.Azure.NotificationHubs.Tests/NotificationHubClientTest.cs

Large diffs are not rendered by default.

33 changes: 17 additions & 16 deletions src/Microsoft.Azure.NotificationHubs.Tests/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
{
"NotificationHubNamespaceUriString": "<insert value here before running tests>",
"NotificationHubConnectionString": "<insert value here before running tests>",
"NotificationHubListenOnlyConnectionString": "<insert value here before running tests>",
"NotificationHubName": "<insert value here before running tests>",
"AdmDeviceToken": "amzn1.adm-registration.v2.123",
"AppleDeviceToken": "62BCD3484834B7E2DC56733AC5509259230CC1BA82BA1AE7D06E91908A05A8FA",
"BaiduUserId": "userId",
"BaiduChannelId": "channelId",
"GcmDeviceToken": "amzn1.adm-registration.v2.123",
"FcmDeviceToken": "amzn1.adm-registration.v2.123",
"MpnsDeviceToken": "https://some.url",
"WindowsDeviceToken": "https://some.url",
"ContainerName": "<insert value here before running tests>",
"StorageAccount": "<insert value here before running tests>",
"StoragePassword": "<insert value here before running tests>",
"StorageEndpointString": "<insert value here before running tests>"
"NotificationHubNamespaceUriString": "<insert value here before running tests>",
"NotificationHubConnectionString": "<insert value here before running tests>",
"NotificationHubListenOnlyConnectionString": "<insert value here before running tests>",
"NotificationHubName": "<insert value here before running tests>",
"AdmDeviceToken": "amzn1.adm-registration.v2.123",
"AppleDeviceToken": "62BCD3484834B7E2DC56733AC5509259230CC1BA82BA1AE7D06E91908A05A8FA",
"BaiduUserId": "userId",
"BaiduChannelId": "channelId",
"GcmDeviceToken": "amzn1.adm-registration.v2.123",
"FcmDeviceToken": "amzn1.adm-registration.v2.123",
"FcmV1DeviceToken": "amzn1.adm-registration.v2.123",
"MpnsDeviceToken": "https://some.url",
"WindowsDeviceToken": "https://some.url",
"ContainerName": "<insert value here before running tests>",
"StorageAccount": "<insert value here before running tests>",
"StoragePassword": "<insert value here before running tests>",
"StorageEndpointString": "<insert value here before running tests>"
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Microsoft.Azure.NotificationHubs
/// Represents Notification Hub registration description for Google Cloud Messaging
/// </summary>
[DataContract(Name = ManagementStrings.GcmRegistrationDescription, Namespace = ManagementStrings.Namespace)]
[Obsolete("GcmRegistrationDescription is deprecated, please use FcmRegistrationDescription instead.")]
[Obsolete("GcmRegistrationDescription is deprecated, please use FcmV1RegistrationDescription instead.")]
public class GcmRegistrationDescription : RegistrationDescription
{
/// <summary>
Expand Down Expand Up @@ -121,6 +121,7 @@ internal override RegistrationDescription Clone()
/// Represents Notification Hub registration description for Firebase Cloud Messaging
/// </summary>
[DataContract(Name = ManagementStrings.FcmRegistrationDescription, Namespace = ManagementStrings.Namespace)]
[Obsolete("FcmRegistrationDescription is deprecated, please use FcmV1RegistrationDescription instead.")]
public class FcmRegistrationDescription : RegistrationDescription
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace Microsoft.Azure.NotificationHubs
/// Represents Notification Hub template registration description for Google Cloud Messaging
/// </summary>
[DataContract(Name = ManagementStrings.GcmTemplateRegistrationDescription, Namespace = ManagementStrings.Namespace)]
[Obsolete("GcmTemplateRegistrationDescription is deprecated, please use FcmTemplateRegistrationDescription instead.")]
[Obsolete("GcmTemplateRegistrationDescription is deprecated, please use FcmV1TemplateRegistrationDescription instead.")]
public class GcmTemplateRegistrationDescription : GcmRegistrationDescription
{
internal override string AppPlatForm
Expand Down Expand Up @@ -176,6 +176,7 @@ internal override RegistrationDescription Clone()
/// Represents Notification Hub template registration description for Firebase Cloud Messaging
/// </summary>
[DataContract(Name = ManagementStrings.FcmTemplateRegistrationDescription, Namespace = ManagementStrings.Namespace)]
[Obsolete("FcmTemplateRegistrationDescription is deprecated, please use FcmV1TemplateRegistrationDescription instead.")]
public class FcmTemplateRegistrationDescription : FcmRegistrationDescription
{
internal override string AppPlatForm
Expand Down
2 changes: 2 additions & 0 deletions src/Microsoft.Azure.NotificationHubs/FcmCredential.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
//------------------------------------------------------------

using Microsoft.Azure.NotificationHubs.Messaging;
using System;
using System.Runtime.Serialization;

namespace Microsoft.Azure.NotificationHubs
Expand All @@ -13,6 +14,7 @@ namespace Microsoft.Azure.NotificationHubs
/// Represents the Firebase Cloud Messaging credential.
/// </summary>
[DataContract(Name = ManagementStrings.FcmCredential, Namespace = ManagementStrings.Namespace)]
[Obsolete("FcmCredential is deprecated, please use FcmV1Credential instead.")]
public class FcmCredential : PnsCredential
{
internal const string AppPlatformName = "fcm";
Expand Down
1 change: 1 addition & 0 deletions src/Microsoft.Azure.NotificationHubs/FcmInstallation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace Microsoft.Azure.NotificationHubs
/// <summary>
/// This class represents a Firebase Cloud Messaging (FCM) installation.
/// </summary>
[Obsolete("FcmInstallation is deprecated, please use FcmV1Installation instead.")]
public class FcmInstallation : Installation
{
/// <summary>
Expand Down
1 change: 1 addition & 0 deletions src/Microsoft.Azure.NotificationHubs/FcmNotification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace Microsoft.Azure.NotificationHubs
/// <summary>
/// Represents a Firebase Cloud Messaging notification.
/// </summary>
[Obsolete("FcmNotification is deprecated, please use FcmV1Notification instead.")]
public sealed class FcmNotification : Notification, INativeNotification
{
static string contentType = $"application/json;charset={Encoding.UTF8.WebName}";
Expand Down
69 changes: 65 additions & 4 deletions src/Microsoft.Azure.NotificationHubs/INotificationHubClient.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for
// license information.
//----------------------------------------------------------------

Expand Down Expand Up @@ -1459,6 +1459,67 @@ public interface INotificationHubClient
/// </returns>
Task<NotificationOutcome> SendFcmNativeNotificationAsync(string jsonPayload, string tagExpression, CancellationToken cancellationToken);

/// <summary>
/// Sends Firebase Cloud Messaging (FCM) V1 native notification.
/// </summary>
/// <param name="jsonPayload">The JSON payload. Documentation on proper formatting of a FCM V1 message can be found <a href="https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#Message">here</a>.</param>
/// <returns>
/// <see cref="Microsoft.Azure.NotificationHubs.NotificationOutcome" /> which describes the result of the Send operation.
/// </returns>
Task<NotificationOutcome> SendFcmV1NativeNotificationAsync(string jsonPayload);

/// <summary>
/// Sends Firebase Cloud Messaging (FCM) V1 native notification.
/// </summary>
/// <param name="jsonPayload">The JSON payload. Documentation on proper formatting of a FCM message can be found <a href="https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#Message">here</a>.</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> SendFcmV1NativeNotificationAsync(string jsonPayload, CancellationToken cancellationToken);

/// <summary>
/// Sends FCM V1 native notification to a tag expression (a single tag "tag" is a valid tag expression).
/// </summary>
/// <param name="jsonPayload">The JSON payload. Documentation on proper formatting of a FCM message can be found <a href="https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#Message">here</a>.</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> SendFcmV1NativeNotificationAsync(string jsonPayload, string tagExpression);

/// <summary>
/// Sends FCM V1 native notification to a tag expression (a single tag "tag" is a valid tag expression).
/// </summary>
/// <param name="jsonPayload">The JSON payload. Documentation on proper formatting of a FCM message can be found <a href="https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#Message">here</a>.</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> SendFcmV1NativeNotificationAsync(string jsonPayload, string tagExpression, CancellationToken cancellationToken);

/// <summary>
/// Sends a FCM V1 native notification to a non-empty set of tags (max 20). This is equivalent to a tag expression with boolean ORs ("||").
/// </summary>
/// <param name="jsonPayload">The JSON payload. Documentation on proper formatting of a FCM message can be found <a href="https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#Message">here</a>.</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> SendFcmV1NativeNotificationAsync(string jsonPayload, IEnumerable<string> tags);

/// <summary>
/// Sends a FCM V1 native notification to a non-empty set of tags (max 20). This is equivalent to a tag expression with boolean ORs ("||").
/// </summary>
/// <param name="jsonPayload">The JSON payload. Documentation on proper formatting of a FCM message can be found <a href="https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#Message">here</a>.</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> SendFcmV1NativeNotificationAsync(string jsonPayload, IEnumerable<string> tags, CancellationToken cancellationToken);

/// <summary>
/// Sends a Microsoft Push Notification Service (MPNS) native notification. To specify headers for MPNS, use the <see cref="M:Microsoft.Azure.NotificationHubs.NotificationHubClient.SendNotificationAsync(Microsoft.Azure.NotificationHubs.Notification)" /> method.
/// </summary>
Expand Down Expand Up @@ -1667,7 +1728,7 @@ public interface INotificationHubClient
/// <summary>
/// Asynchronously sends a Windows native notification. To specify headers for WNS, use the <see cref="M:Microsoft.Azure.NotificationHubs.NotificationHubClient.SendNotificationAsync(Microsoft.Azure.NotificationHubs.Notification)" /> method.
/// </summary>
/// <param name="windowsNativePayload">The Windows native payload. This can be used to send any valid WNS notification,
/// <param name="windowsNativePayload">The Windows native payload. This can be used to send any valid WNS notification,
/// including Tile, Toast, and Badge values, as described in the WNS documentation.</param>
/// <returns>
/// <see cref="Microsoft.Azure.NotificationHubs.NotificationOutcome" /> which describes the result of the Send operation.
Expand All @@ -1677,7 +1738,7 @@ public interface INotificationHubClient
/// <summary>
/// Asynchronously sends a Windows native notification. To specify headers for WNS, use the <see cref="M:Microsoft.Azure.NotificationHubs.NotificationHubClient.SendNotificationAsync(Microsoft.Azure.NotificationHubs.Notification)" /> method.
/// </summary>
/// <param name="windowsNativePayload">The Windows native payload. This can be used to send any valid WNS notification,
/// <param name="windowsNativePayload">The Windows native payload. This can be used to send any valid WNS notification,
/// including Tile, Toast, and Badge values, as described in the WNS documentation.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> to observe while waiting for a task to complete.</param>
/// <returns>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageId>Microsoft.Azure.NotificationHubs</PackageId>
<Version>4.2.0</Version>
<Version>4.2.1</Version>
<Authors>Microsoft</Authors>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://aka.ms/NHNuget</PackageProjectUrl>
Expand Down
Loading