Skip to content
This repository was archived by the owner on Jul 2, 2022. It is now read-only.

Commit b12a31d

Browse files
committed
Pull Features from GitHub
1 parent bf24729 commit b12a31d

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

CodeHub.iOS/Services/FeaturesService.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,17 @@
44
using System;
55
using System.Threading.Tasks;
66
using Foundation;
7+
using System.Net.Http;
78

89
namespace CodeHub.iOS.Services
910
{
1011
public class FeaturesService : IFeaturesService
1112
{
1213
private readonly IDefaultValueService _defaultValueService;
13-
private readonly IHttpClientService _httpClientService;
14-
private readonly IJsonSerializationService _jsonSerializationService;
1514

16-
17-
public FeaturesService(IDefaultValueService defaultValueService, IHttpClientService httpClientService, IJsonSerializationService jsonSerializationService)
15+
public FeaturesService(IDefaultValueService defaultValueService)
1816
{
1917
_defaultValueService = defaultValueService;
20-
_httpClientService = httpClientService;
21-
_jsonSerializationService = jsonSerializationService;
2218
}
2319

2420
public bool IsPushNotificationsActivated
@@ -58,14 +54,17 @@ public bool IsActivated(string id)
5854

5955
public async Task<IEnumerable<string>> GetAvailableFeatureIds()
6056
{
61-
var ids = new List<string>();
62-
ids.Add(FeatureIds.EnterpriseSupport);
63-
var client = _httpClientService.Create();
57+
var client = new HttpClient();
6458
client.Timeout = new TimeSpan(0, 0, 15);
65-
var response = await client.GetAsync("http://push.codehub-app.com/in-app?version=" + NSBundle.MainBundle.InfoDictionary["CFBundleShortVersionString"].ToString());
59+
60+
var response = await client.GetAsync("https://raw.githubusercontent.com/thedillonb/CodeHub/gh-pages/features.json");
6661
var data = await response.Content.ReadAsStringAsync();
67-
ids.AddRange(_jsonSerializationService.Deserialize<List<string>>(data));
68-
return ids;
62+
var features = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, List<string>>>(data);
63+
64+
var version = NSBundle.MainBundle.InfoDictionary["CFBundleShortVersionString"].ToString();
65+
if (!features.ContainsKey(version))
66+
return new [] { FeatureIds.EnterpriseSupport };
67+
return features[version];
6968
}
7069
}
7170
}

0 commit comments

Comments
 (0)