usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sfeld...@apache.org
Subject [13/31] incubator-usergrid git commit: windows raw notifications client side
Date Mon, 09 Mar 2015 15:25:26 GMT
windows raw notifications client side


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

Branch: refs/heads/USERGRID-405
Commit: 615a5afdf24e7ef45196958783a775df80c3c003
Parents: 44bbd6b
Author: Shawn Feldman <sfeldman@apache.org>
Authored: Fri Mar 6 14:20:00 2015 -0700
Committer: Shawn Feldman <sfeldman@apache.org>
Committed: Fri Mar 6 14:20:00 2015 -0700

----------------------------------------------------------------------
 .../Client/IUsergridClient.cs                   |  2 +-
 .../Usergrid.Notifications/Client/PushClient.cs | 24 +++++++++++++++++++
 .../Usergrid.Notifications/MainPage.xaml        |  1 +
 .../Usergrid.Notifications/MainPage.xaml.cs     | 25 ++++++++++++++++----
 4 files changed, 46 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/615a5afd/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 3f4fb82..5efbb9b 100644
--- a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/IUsergridClient.cs
+++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/IUsergridClient.cs
@@ -108,7 +108,7 @@ namespace Usergrid.Notifications.Client
         /// <param name="message"></param>
         /// <returns></returns>
         Task<bool> SendToast(string message);
-        
+        Task<bool> SendRaw(string message);
         /// <summary>
         /// Send a badge update
         /// </summary>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/615a5afd/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 fb8860c..343e28b 100644
--- a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/PushClient.cs
+++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/PushClient.cs
@@ -85,9 +85,28 @@ namespace Usergrid.Notifications.Client
             return jsonResponse.StatusIsOk;
         }
 
+
+        public async Task<bool> SendRaw(String 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("raw", new JValue(message));
+            payloads.Add(Notifier, payload);
+            jsonObject.Add("payloads", payloads);
+            jsonObject.Add("debug", true);
+            var jsonResponse = await usergrid.SendAsync(HttpMethod.Post, String.Format("users/{1}/devices/{0}/notifications",
this.DeviceId, userId), jsonObject);
+            return jsonResponse.StatusIsOk;
+        }
+
         private async Task init()
         {
             channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync().AsTask<PushNotificationChannel>();
+            channel.PushNotificationReceived += channel_PushNotificationReceived;
             if (settings.Values[DEVICE_KEY] == null)
             {
                 Guid uuid = await registerDevice(true);
@@ -113,6 +132,11 @@ namespace Usergrid.Notifications.Client
             }
         }
 
+        void channel_PushNotificationReceived(PushNotificationChannel sender, PushNotificationReceivedEventArgs
args)
+        {
+            throw new NotImplementedException();
+        }
+
        
         private async Task<JToken> GetDevice(Guid deviceId)
         {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/615a5afd/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 f22c8b6..004eba9 100644
--- a/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml
+++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml
@@ -33,6 +33,7 @@
         <Button x:Name="SendToast"  Content="Toast" HorizontalAlignment="Left" Margin="114,88,0,0"
VerticalAlignment="Top" Click="Button_Click" Width="39"/>
         <Button x:Name="Badge" Content="Badge" HorizontalAlignment="Left" Margin="114,157,0,0"
VerticalAlignment="Top" Click="Badge_Click"/>
         <TextBlock x:Name="Result" HorizontalAlignment="Left" Margin="46,295,0,0" TextWrapping="Wrap"
Text="Did it work? " VerticalAlignment="Top" Height="49" Width="261" FontSize="25" SelectionChanged="Result_SelectionChanged"/>
+        <Button Content="Raw" HorizontalAlignment="Left" Margin="114,223,0,0" VerticalAlignment="Top"
Click="Button_Click_1"/>
 
     </Grid>
 </Page>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/615a5afd/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 a550954..ccef239 100644
--- a/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml.cs
+++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml.cs
@@ -44,17 +44,17 @@ namespace Usergrid.Notifications
         {
             this.InitializeComponent();
             //TODO: change me to your server
-            serverUrl = "https://usergrid-push.example.com";
+            serverUrl = "http://10.0.1.20:8080/";
             //TODO: change me to your org
-            org = "ugvalidate";
+            org = "test-organization";
             //TODO: change me to your app
-            app = "sandbox";
+            app = "test-app";
             //TODO: change me to your notifier name
-            notifier = "winphone";
+            notifier = "windows";
             //TODO: change me to your user
             user = "mobileuser";
             //TODO: change me to your password
-            password = "******";
+            password = "P@ssw0rd1";
             this.NavigationCacheMode = NavigationCacheMode.Required;
             usergrid = new Client.Usergrid(serverUrl, org, app, user, password, notifier);
 
@@ -120,5 +120,20 @@ namespace Usergrid.Notifications
         }
 
         public AggregateException LastException { get; set; }
+
+        private async void Button_Click_1(object sender, RoutedEventArgs e)
+        {
+            Result.Text = "Sending....";
+
+            var message = this.pushText.Text;
+            if (await usergrid.Push.SendRaw(message))
+            {
+                Result.Text = "It did! :)";
+            }
+            else
+            {
+                Result.Text = "It did not! :(";
+            }
+        }
     }
 }


Mime
View raw message