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

Added X-WNS-PRIORITY header for WNS notifications #920

Open
wants to merge 1 commit into
base: master
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
5 changes: 4 additions & 1 deletion PushSharp.Windows/WnsConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ public async Task Send (WnsNotification notification)

http.DefaultRequestHeaders.TryAddWithoutValidation ("X-WNS-Type", string.Format ("wns/{0}", notification.Type.ToString().ToLower ()));

if(!http.DefaultRequestHeaders.Contains("Authorization")) //prevent double values
if (notification.Priority != WnsPriority.Unspecified)
http.DefaultRequestHeaders.TryAddWithoutValidation("X-WNS-PRIORITY", ((int)notification.Priority).ToString());

if (!http.DefaultRequestHeaders.Contains("Authorization")) //prevent double values
http.DefaultRequestHeaders.TryAddWithoutValidation("Authorization", "Bearer " + accessToken);

if (notification.RequestForStatus.HasValue)
Expand Down
2 changes: 2 additions & 0 deletions PushSharp.Windows/WnsNotification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public abstract class WnsNotification : INotification

public abstract WnsNotificationType Type { get; }

public WnsPriority Priority { get; set; }

public bool IsDeviceRegistrationIdValid ()
{
return true;
Expand Down
9 changes: 9 additions & 0 deletions PushSharp.Windows/WnsNotificationStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,14 @@ public enum WnsNotificationType
Toast,
Raw
}

public enum WnsPriority
{
Unspecified = 0,
High = 1,
Meduim = 2,
Low = 3,
VeryLow = 4
}
}