You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sf...@apache.org on 2015/01/22 21:52:15 UTC

incubator-usergrid git commit: adding badges

Repository: incubator-usergrid
Updated Branches:
  refs/heads/USERGRID-323-Win-phone 7925e51d8 -> b841d1d6e


adding badges


Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/b841d1d6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/b841d1d6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/b841d1d6

Branch: refs/heads/USERGRID-323-Win-phone
Commit: b841d1d6e968643b46dde885304c940b9f37ebd2
Parents: 7925e51
Author: Shawn Feldman <sf...@apache.org>
Authored: Thu Jan 22 13:52:10 2015 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Thu Jan 22 13:52:10 2015 -0700

----------------------------------------------------------------------
 .../notifications/Usergrid.Notifications.sln    | 40 ++++++++++++++++
 .../Client/EntityResponse.cs                    |  4 +-
 .../Client/IUsergridClient.cs                   | 46 +++++++++++-------
 .../Usergrid.Notifications/Client/PushClient.cs | 42 +++++++++++-----
 .../Usergrid.Notifications/Client/Usergrid.cs   | 20 ++++----
 .../Usergrid.Notifications/MainPage.xaml        |  3 +-
 .../Usergrid.Notifications/MainPage.xaml.cs     | 23 +++++----
 .../notifications/packages/repositories.config  |  4 ++
 .../services/notifications/wns/WNSAdapter.java  | 50 +++++++++++++++++---
 9 files changed, 172 insertions(+), 60 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b841d1d6/sdks/dotnet/samples/notifications/Usergrid.Notifications.sln
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications.sln b/sdks/dotnet/samples/notifications/Usergrid.Notifications.sln
new file mode 100644
index 0000000..5474b5b
--- /dev/null
+++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications.sln
@@ -0,0 +1,40 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2013
+VisualStudioVersion = 12.0.31101.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Usergrid.Notifications", "Usergrid.Notifications\Usergrid.Notifications.csproj", "{EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Debug|ARM = Debug|ARM
+		Debug|x86 = Debug|x86
+		Release|Any CPU = Release|Any CPU
+		Release|ARM = Release|ARM
+		Release|x86 = Release|x86
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
+		{EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|ARM.ActiveCfg = Debug|ARM
+		{EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|ARM.Build.0 = Debug|ARM
+		{EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|ARM.Deploy.0 = Debug|ARM
+		{EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|x86.ActiveCfg = Debug|x86
+		{EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|x86.Build.0 = Debug|x86
+		{EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|x86.Deploy.0 = Debug|x86
+		{EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|Any CPU.Build.0 = Release|Any CPU
+		{EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|Any CPU.Deploy.0 = Release|Any CPU
+		{EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|ARM.ActiveCfg = Release|ARM
+		{EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|ARM.Build.0 = Release|ARM
+		{EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|ARM.Deploy.0 = Release|ARM
+		{EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|x86.ActiveCfg = Release|x86
+		{EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|x86.Build.0 = Release|x86
+		{EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|x86.Deploy.0 = Release|x86
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b841d1d6/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/EntityResponse.cs
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/EntityResponse.cs b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/EntityResponse.cs
index fdabfb5..0be267a 100644
--- a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/EntityResponse.cs
+++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/EntityResponse.cs
@@ -57,6 +57,7 @@ namespace Usergrid.Notifications.Client
         public static async Task<EntityResponse> Parse(HttpResponseMessage httpResponseMessage)
         {
             JObject jobject;
+            
             using (var stream = await httpResponseMessage.Content.ReadAsStreamAsync())
             {
                 using (var reader = new StreamReader(stream, Encoding.UTF8))
@@ -64,9 +65,8 @@ namespace Usergrid.Notifications.Client
                     jobject = JObject.Parse(reader.ReadToEnd());
                 }
             }
-            var t = new Task<EntityResponse>(() => { return new EntityResponse(httpResponseMessage, jobject); });
             
-            return await t;
+            return new EntityResponse(httpResponseMessage, jobject); 
         }
 
         public bool StatusIsOk

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b841d1d6/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/IUsergridClient.cs
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/IUsergridClient.cs b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/IUsergridClient.cs
index 1dc943d..1468e87 100644
--- a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/IUsergridClient.cs
+++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/IUsergridClient.cs
@@ -26,11 +26,10 @@ namespace Usergrid.Notifications.Client
 {
     public interface IUsergridClient
     {
-        System.Threading.Tasks.Task Authenticate(string user, string password, bool isManagement);
-        System.Threading.Tasks.Task<EntityResponse> GetJsonResponse(System.Net.Http.HttpResponseMessage response);
+        Task Authenticate(string user, string password, bool isManagement);
+        Task<EntityResponse> SendAsync(HttpMethod method, string url, object obj);
+        Task<EntityResponse> SendAsync(HttpMethod method, string url, object obj, bool useManagementUrl);
         IPushClient Push { get; }
-        System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> SendAsync(System.Net.Http.HttpMethod method, string url, object obj);
-        System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> SendAsync(System.Net.Http.HttpMethod method, string url, object obj, bool useManagementUrl);
     }
 
     public interface UsergridHttpClient
@@ -43,7 +42,7 @@ namespace Usergrid.Notifications.Client
         /// <param name="obj"></param>
         /// <param name="useManagementUrl">use management endpoint</param>
         /// <returns></returns>
-        Task<HttpResponseMessage> SendAsync(HttpMethod method, string url, object obj, bool useManagementUrl);
+        Task<EntityResponse> SendAsync(HttpMethod method, string url, object obj, bool useManagementUrl);
         /// <summary>
         /// send Http call async
         /// </summary>
@@ -51,24 +50,35 @@ namespace Usergrid.Notifications.Client
         /// <param name="url"></param>
         /// <param name="obj"></param>
         /// <returns></returns>
-        Task<HttpResponseMessage> SendAsync(HttpMethod method, string url, object obj);
-
-        /// <summary>
-        /// Parse a json response
-        /// </summary>
-        /// <param name="response"></param>
-        /// <returns></returns>
-        Task<EntityResponse> GetJsonResponse(HttpResponseMessage response);
-
+        Task<EntityResponse> SendAsync(HttpMethod method, string url, object obj);
     }
 
     public interface IPushClient
     {
-        System.Threading.Tasks.Task AddNotifier(string name, string sid, string apiKey);
-        System.Threading.Tasks.Task<bool> DeviceExists(Guid deviceId);
+        /// <summary>
+        /// Add a new notifier, admin function
+        /// </summary>
+        /// <param name="name"></param>
+        /// <param name="sid"></param>
+        /// <param name="apiKey"></param>
+        /// <returns></returns>
+        Task AddNotifier(string name, string sid, string apiKey);
+        
+        /// <summary>
+        /// the notifier you are currently using
+        /// </summary>
         string Notifier { get; set; }
-        System.Threading.Tasks.Task RegisterDevice(string notifier);
-        System.Threading.Tasks.Task<bool> SendNotification(string message);
+        
+        /// <summary>
+        /// 
+        /// </summary>
+        Guid DeviceId { get; set; }
+        
+        Task RegisterDevice(string notifier);
+        
+        Task<bool> SendNotification(string message);
+        
+        Task<bool> SendBadge(object message);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b841d1d6/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/PushClient.cs
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/PushClient.cs b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/PushClient.cs
index ce2affe..e9940e2 100644
--- a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/PushClient.cs
+++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/PushClient.cs
@@ -36,7 +36,7 @@ namespace Usergrid.Notifications.Client
         private ApplicationDataContainer settings;
         private PushNotificationChannel channel;
 
-        public PushClient(UsergridHttpClient usergrid, PushNotificationChannel channel)
+        public PushClient(UsergridHttpClient usergrid,  PushNotificationChannel channel)
         {
             this.usergrid = usergrid;
             this.settings = ApplicationData.Current.LocalSettings;
@@ -53,11 +53,27 @@ namespace Usergrid.Notifications.Client
             var payloads = new JObject();
             var payload = new JObject();
             payload.Add("toast", new JValue(message));
-            payloads.Add("winphone", payload);
+            payloads.Add(Notifier, payload);
             jsonObject.Add("payloads", payloads);
             jsonObject.Add("debug", true);
-            var response = await usergrid.SendAsync(HttpMethod.Post, String.Format("devices/{0}/notifications", this.DeviceId), jsonObject);
-            var jsonResponse = await EntityResponse.Parse(response);
+            var jsonResponse = await usergrid.SendAsync(HttpMethod.Post, String.Format("devices/{0}/notifications", this.DeviceId), jsonObject);
+            return jsonResponse.StatusIsOk;
+        }
+
+        public async Task<bool> SendBadge(object message)
+        {
+            if (DeviceId == null)
+            {
+                throw new Exception("Please call PushClient.RegisterDevice first.");
+            }
+            var jsonObject = new JObject();
+            var payloads = new JObject();
+            var payload = new JObject();
+            payload.Add("badge", new JValue(message));
+            payloads.Add(Notifier, payload);
+            jsonObject.Add("payloads", payloads);
+            jsonObject.Add("debug", true);
+            var jsonResponse = await usergrid.SendAsync(HttpMethod.Post, String.Format("devices/{0}/notifications", this.DeviceId), jsonObject);
             return jsonResponse.StatusIsOk;
         }
 
@@ -92,18 +108,16 @@ namespace Usergrid.Notifications.Client
             obj.Add("provider", new JValue("windows"));
             obj.Add("apiKey", new JValue(apiKey));
             obj.Add("logging", new JValue(true));
-            var response = await usergrid.SendAsync(HttpMethod.Post, "notifiers", obj);
-            var jsonResponse = await EntityResponse.Parse(response);
+            var jsonResponse = await usergrid.SendAsync(HttpMethod.Post, "notifiers", obj);
             if (jsonResponse.StatusIsOk)
             {
                 var body = jsonResponse.GetValue("entities").ToString();
             }
         }
 
-        public async Task<bool> DeviceExists(Guid deviceId)
+        private async Task<bool> DeviceExists(Guid deviceId)
         {
-            var response = await usergrid.SendAsync(HttpMethod.Get, "devices/" + deviceId, null);
-            var jsonResponse = await EntityResponse.Parse(response);
+            var jsonResponse = await usergrid.SendAsync(HttpMethod.Get, "devices/" + deviceId, null);
 
             if (jsonResponse.StatusIsOk)
             {
@@ -117,9 +131,8 @@ namespace Usergrid.Notifications.Client
         {
             JObject obj = new JObject();
             obj.Add(notifier + ".notifier.id", new JValue(uri));
-            var response = await usergrid.SendAsync(HttpMethod.Post, "devices/", obj);
-            EntityResponse jsonResponse = await EntityResponse.Parse(response);
-
+            var jsonResponse = await usergrid.SendAsync(HttpMethod.Post, "devices/", obj);
+            
             if (jsonResponse.StatusIsOk)
             {
                 var entity = jsonResponse.GetValue("entities").Value<JArray>()[0];
@@ -130,7 +143,10 @@ namespace Usergrid.Notifications.Client
         }
 
         public string Notifier { get; set; }
-        private Guid DeviceId { get; set; }
+        public Guid DeviceId { get; set; }
+
+
 
+    
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b841d1d6/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/Usergrid.cs
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/Usergrid.cs b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/Usergrid.cs
index a754a64..6662af7 100644
--- a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/Usergrid.cs
+++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/Usergrid.cs
@@ -65,7 +65,7 @@ namespace Usergrid.Notifications.Client
             this.appUrl = String.Format("{0}{1}/{2}/", serverUrlWithSlash, org, app);
             this.managementUrl = serverUrlWithSlash + "management/";
             this.client = new HttpClient();
-            this.push = new PushClient(this, channel);
+            this.push = new PushClient(this,channel);
         }
 
         public async Task Authenticate(string user, string password, bool isManagement)
@@ -76,12 +76,11 @@ namespace Usergrid.Notifications.Client
             jsonObject.Add("password", password);
             jsonObject.Add("grant_type", "password");
            
-            HttpResponseMessage response = await SendAsync(HttpMethod.Post,url, jsonObject, isManagement);
+            var response = await SendAsync(HttpMethod.Post,url, jsonObject, isManagement);
 
-            if (response.StatusCode == HttpStatusCode.OK)
+            if (response.StatusIsOk)
             {
-                JObject jsonResponse = await GetJsonResponse(response);
-                this.token = jsonResponse.GetValue("access_token").Value<String>();
+                this.token = response.GetValue("access_token").Value<String>();
                 client.DefaultRequestHeaders.Add("X-Authorization", token);
             }
             else
@@ -90,17 +89,17 @@ namespace Usergrid.Notifications.Client
             }
         }
 
-        public async Task<EntityResponse> GetJsonResponse(HttpResponseMessage response)
+        private async Task<EntityResponse> GetJsonResponse(HttpResponseMessage response)
         {
             return  await EntityResponse.Parse(response);
         }
 
-        public  Task<HttpResponseMessage> SendAsync(HttpMethod method, string url, object obj)
+        public async Task<EntityResponse> SendAsync(HttpMethod method, string url, object obj)
         {
-            return SendAsync(method, url, obj, false);
+            return await SendAsync(method, url, obj, false);
         }
 
-        public Task<HttpResponseMessage> SendAsync(HttpMethod method, string url, object obj, bool useManagementUrl)
+        public async Task<EntityResponse> SendAsync(HttpMethod method, string url, object obj, bool useManagementUrl)
         {
             HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Post, (useManagementUrl ? this.managementUrl : this.appUrl) + url);
             if (obj != null)
@@ -108,7 +107,8 @@ namespace Usergrid.Notifications.Client
                 message.Content = getJsonBody(obj);
             }
             message.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue( "application/json"));
-            return this.client.SendAsync(message);
+            var response = await this.client.SendAsync(message);
+            return await EntityResponse.Parse(response);
         }
    
         public IPushClient Push

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b841d1d6/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml b/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml
index 3e0affd..d64eea8 100644
--- a/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml
+++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml
@@ -10,11 +10,12 @@
 
     <Grid>
         <TextBox x:Name="pushText" HorizontalAlignment="Left" Margin="75,46,0,0" TextWrapping="Wrap" Text="Push Text" VerticalAlignment="Top" Width="261" TextChanged="pushText_TextChanged"/>
-        <Button  Content="Send" HorizontalAlignment="Left" Margin="146,121,0,0" VerticalAlignment="Top" Click="Button_Click"/>
+        <Button x:Name="SendToast"  Content="Toast" HorizontalAlignment="Left" Margin="75,118,0,0" VerticalAlignment="Top" Click="Button_Click" Width="39"/>
         <TextBox x:Name="NotifierName" HorizontalAlignment="Left" Margin="75,210,0,0" TextWrapping="Wrap" Text="Notifier Name" VerticalAlignment="Top" Width="261"/>
         <TextBox x:Name="Api_Key" HorizontalAlignment="Left" Margin="75,276,0,0" TextWrapping="Wrap" Text="Sid" VerticalAlignment="Top" Width="261"/>
         <TextBox x:Name="Sid" HorizontalAlignment="Left" Margin="75,348,0,0" TextWrapping="Wrap" Text="Api Key" VerticalAlignment="Top" Width="261"/>
         <Button x:Name="AddNotifierButton" Content="Add Notifier" HorizontalAlignment="Left" Margin="146,405,0,0" VerticalAlignment="Top" Click="AddNotifierButton_Click"/>
+        <Button x:Name="Badge" Content="Badge" HorizontalAlignment="Left" Margin="208,118,0,0" VerticalAlignment="Top" Click="Badge_Click"/>
 
     </Grid>
 </Page>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b841d1d6/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml.cs
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml.cs b/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml.cs
index 9388ef3..64eadd9 100644
--- a/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml.cs
+++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml.cs
@@ -50,13 +50,13 @@ namespace Usergrid.Notifications
             app = "sandbox";
             notifier = "winphone";
             this.NavigationCacheMode = NavigationCacheMode.Required;
-            this.setup();
+            Task t = this.setup();
         }
 
         private async Task setup()
         {
             usergrid = await Client.UsergridFactory.GetInstance(serverUrl, org, app);
-            await this.usergrid.Authenticate("superuser", "test", true);
+            await usergrid.Authenticate("superuser", "test", true);
             await usergrid.Push.RegisterDevice(notifier);
         }
 
@@ -75,22 +75,27 @@ namespace Usergrid.Notifications
             // If you are using the NavigationHelper provided by some templates,
             // this event is handled for you.
         }
-
-        private async void Button_Click(object sender, RoutedEventArgs e)
+         
+        private void pushText_TextChanged(object sender, TextChangedEventArgs e)
         {
 
-            var message = this.pushText.Text;
-            await usergrid.Push.SendNotification(message);
         }
 
-        private void pushText_TextChanged(object sender, TextChangedEventArgs e)
+        private async void AddNotifierButton_Click(object sender, RoutedEventArgs e)
         {
+            await usergrid.Push.AddNotifier(NotifierName.Text,Sid.Text,Api_Key.Text);
+        }
 
+        private async void Button_Click(object sender, RoutedEventArgs e)
+        {
+            var message = this.pushText.Text;
+            await usergrid.Push.SendNotification(message);
         }
 
-        private async void AddNotifierButton_Click(object sender, RoutedEventArgs e)
+        private async void Badge_Click(object sender, RoutedEventArgs e)
         {
-            await usergrid.Push.AddNotifier(NotifierName.Text,Sid.Text,Api_Key.Text);
+            var message = this.pushText.Text;
+            await usergrid.Push.SendBadge(1);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b841d1d6/sdks/dotnet/samples/notifications/packages/repositories.config
----------------------------------------------------------------------
diff --git a/sdks/dotnet/samples/notifications/packages/repositories.config b/sdks/dotnet/samples/notifications/packages/repositories.config
new file mode 100644
index 0000000..deb9991
--- /dev/null
+++ b/sdks/dotnet/samples/notifications/packages/repositories.config
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<repositories>
+  <repository path="..\Usergrid.Notifications\packages.config" />
+</repositories>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b841d1d6/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/WNSAdapter.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/WNSAdapter.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/WNSAdapter.java
index b331e86..e3f10d4 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/WNSAdapter.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/WNSAdapter.java
@@ -22,7 +22,9 @@ package org.apache.usergrid.services.notifications.wns;
 
 import ar.com.fernandospr.wns.WnsService;
 import ar.com.fernandospr.wns.exceptions.WnsException;
+import ar.com.fernandospr.wns.model.WnsBadge;
 import ar.com.fernandospr.wns.model.WnsToast;
+import ar.com.fernandospr.wns.model.builders.WnsBadgeBuilder;
 import ar.com.fernandospr.wns.model.builders.WnsToastBuilder;
 import org.apache.usergrid.persistence.EntityManager;
 import org.apache.usergrid.persistence.entities.Notification;
@@ -59,7 +61,8 @@ public class WNSAdapter implements ProviderAdapter {
     public void testConnection() throws ConnectionException {
         WnsToast toast = new WnsToastBuilder().bindingTemplateToastText01("test").build();
         try{
-            service.pushToast("ms-app://s-1-15-2-2411381248-444863693-3819932088-4077691928-1194867744-112853457-373132695",toast);
+            //this fails every time due to
+            service.pushToast("s-1-15-2-2411381248-444863693-3819932088-4077691928-1194867744-112853457-373132695",toast);
         }catch (Exception e){
             LOG.error(e.toString());
         }
@@ -68,8 +71,22 @@ public class WNSAdapter implements ProviderAdapter {
     @Override
     public void sendNotification(String providerId, Object payload, Notification notification, TaskTracker tracker) throws Exception {
         try {
-            WnsToast toast = new WnsToastBuilder().bindingTemplateToastText01(payload.toString()).build();
-            service.pushToast(providerId, toast);
+            TranslatedNotification translatedNotification = (TranslatedNotification) payload;
+            switch (translatedNotification.type){
+                case "toast" :
+                    WnsToast toast = new WnsToastBuilder().bindingTemplateToastText01(translatedNotification.getPayload().toString()).build();
+                    service.pushToast(providerId, toast);
+                    break;
+                case "badge" :
+                    WnsBadge badge;
+                    if(translatedNotification.getPayload() instanceof Integer){
+                        badge = new WnsBadgeBuilder().value((Integer)translatedNotification.getPayload()).build();
+                    }else{
+                        badge = new WnsBadgeBuilder().value(translatedNotification.getPayload().toString()).build();
+                    }
+                    service.pushBadge(providerId,badge);
+                    break;
+            }
             tracker.completed();
         } catch (Exception e) {
             tracker.failed(0,e.toString());
@@ -89,17 +106,24 @@ public class WNSAdapter implements ProviderAdapter {
 
     @Override
     public Object translatePayload(Object payload) throws Exception {
-        String toast = "";
+        TranslatedNotification translatedNotification = null;
         if (payload instanceof Map) {
-            toast = ((Map<String, Object>) payload).get("toast").toString();
+            Map<String, Object> map = (Map<String, Object>) payload;
+            if(map.containsKey("toast")) {
+                translatedNotification = new TranslatedNotification( map.get("toast").toString(),"toast");
+            }else{
+                if(map.containsKey("badge")){
+                    translatedNotification = new TranslatedNotification( map.get("badge"),"badge");
+                }
+            }
         } else {
             if (payload instanceof String) {
-                toast = (String) payload;
+                translatedNotification = new TranslatedNotification( (String) payload,"toast");
             }else{
                 throw new IllegalArgumentException("format is messed up");
             }
         }
-        return toast;
+        return translatedNotification;
     }
 
     @Override
@@ -127,5 +151,17 @@ public class WNSAdapter implements ProviderAdapter {
     public Notifier getNotifier() {
         return notifier;
     }
+    public class TranslatedNotification{
+        private final Object payload;
+        private final String type;
+
+        public TranslatedNotification(Object payload, String type){
+            this.payload = payload;
+            this.type = type;
+        }
+
+        public Object getPayload(){return payload;}
+        public String getType(){return type;}
+    }
 
 }