From a9a2c4d856dea88697e688f990144bee0448af2c Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Wed, 9 Oct 2013 00:44:15 +0400
Subject: HTTPS for WP8
---
Juick/Classes/HttpsHelper.cs | 12 ++++++++++++
Juick/Juick.csproj | 1 +
Juick/ViewModels/AppViewModel.cs | 19 +++++++------------
3 files changed, 20 insertions(+), 12 deletions(-)
create mode 100644 Juick/Classes/HttpsHelper.cs
diff --git a/Juick/Classes/HttpsHelper.cs b/Juick/Classes/HttpsHelper.cs
new file mode 100644
index 0000000..18689fd
--- /dev/null
+++ b/Juick/Classes/HttpsHelper.cs
@@ -0,0 +1,12 @@
+using System;
+
+namespace Juick.Classes
+{
+ static class HttpsHelper
+ {
+ public static bool CanUseHttps
+ {
+ get { return Environment.OSVersion.Version.Major >= 8; }
+ }
+ }
+}
diff --git a/Juick/Juick.csproj b/Juick/Juick.csproj
index c89c775..5270c65 100644
--- a/Juick/Juick.csproj
+++ b/Juick/Juick.csproj
@@ -86,6 +86,7 @@
+
diff --git a/Juick/ViewModels/AppViewModel.cs b/Juick/ViewModels/AppViewModel.cs
index e3a58bb..2aff819 100644
--- a/Juick/ViewModels/AppViewModel.cs
+++ b/Juick/ViewModels/AppViewModel.cs
@@ -38,13 +38,8 @@ namespace Juick.ViewModels
pushChannel = new HttpNotificationChannel(channelName);
// Register for all the events before attempting to open the channel.
- pushChannel.ChannelUriUpdated += (sender, e) => {
- EnableNotifications();
- };
- pushChannel.ErrorOccurred += (sender, e) =>
- {
- DisableNotifications();
- };
+ pushChannel.ChannelUriUpdated += (sender, e) => EnableNotifications();
+ pushChannel.ErrorOccurred += (sender, e) => DisableNotifications();
// Register for this notification only if you need to receive the notifications while your application is running.
// Register for this notification only if you need to receive the notifications while your application is running.
@@ -76,10 +71,7 @@ namespace Juick.ViewModels
else
{
// The channel was already open, so just register for all the events.
- pushChannel.ChannelUriUpdated += (sender, e) =>
- {
- EnableNotifications();
- };
+ pushChannel.ChannelUriUpdated += (sender, e) => EnableNotifications();
pushChannel.ErrorOccurred += (sender, e) => DisableNotifications();
// Register for this notification only if you need to receive the notifications while your application is running.
@@ -149,11 +141,14 @@ namespace Juick.ViewModels
}
private RestClient _cl;
+
+ private readonly string _juickUri = HttpsHelper.CanUseHttps ? "https://api.juick.com" : "http://api.juick.com";
+
public RestClient Client
{
get
{
- return _cl ?? (_cl = new RestClient("http://api.juick.com")
+ return _cl ?? (_cl = new RestClient(_juickUri)
{
UserAgent = "Juick 1.1/Windows Phone " + Environment.OSVersion.Version
});
--
cgit v1.2.3