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

Add Xiaomi Installation #259

Open
wants to merge 2 commits into
base: Xiaomi
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
20 changes: 20 additions & 0 deletions src/Microsoft.Azure.NotificationHubs.Tests/InstallationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,26 @@ public void CanCreateWindowsPhoneInstallationWithChannelUri()
Assert.Equal(ChannelUri, installation.PushChannel);
Assert.Equal(NotificationPlatform.Mpns, installation.Platform);
}

[Fact]
public void CanCreateXiaomiInstallation()
{
var installation = new XiaomiInstallation();

Assert.Equal(NotificationPlatform.Xiaomi, installation.Platform);
}

[Fact]
public void CanCreateXiaomiInstallationWithToken()
{
const string XiaomiDeviceToken = "h1";

var installation = new XiaomiInstallation(InstallationId, XiaomiDeviceToken);

Assert.Equal(InstallationId, installation.InstallationId);
Assert.Equal(XiaomiDeviceToken, installation.PushChannel);
Assert.Equal(NotificationPlatform.Xiaomi, installation.Platform);
}
}
}

6 changes: 6 additions & 0 deletions src/Microsoft.Azure.NotificationHubs/NotificationPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,11 @@ public enum NotificationPlatform
/// </summary>
[EnumMember(Value = "baidu")]
Baidu=6,

/// <summary>
/// Xiaomi Installation Platform
/// </summary>
[EnumMember(Value = "xiaomi")]
Xiaomi=7,
}
}
35 changes: 35 additions & 0 deletions src/Microsoft.Azure.NotificationHubs/XiaomiInstallation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for
// license information.
//------------------------------------------------------------

using System;

namespace Microsoft.Azure.NotificationHubs
{
/// <summary>
/// This class represents a Xiaomi installation.
/// </summary>
public class XiaomiInstallation : Installation
{
/// <summary>
/// Creates a new instance of the XiaomiInstallation class.
/// </summary>
public XiaomiInstallation()
{
Platform = NotificationPlatform.Xiaomi;
}

/// <summary>
/// Creates a new instance of the XiaomiInstallation class.
/// </summary>
/// <param name="installationId">The unique identifier for the installation.</param>
/// <param name="xiaomiRegistrationId">The Xiaomi registration ID to use for the PushChannel.</param>
public XiaomiInstallation(string installationId, string xiaomiRegistrationId) : this()
{
InstallationId = installationId ?? throw new ArgumentNullException(nameof(installationId));
PushChannel = xiaomiRegistrationId ?? throw new ArgumentNullException(nameof(xiaomiRegistrationId));
}
}
}