Skip to content

Commit eddb874

Browse files
Merge pull request #87 from TransactionProcessing/task/#85_getappcenterkeysfromconfig
Get App Center Keys from config
2 parents f986f6f + 6301b90 commit eddb874

File tree

4 files changed

+51
-18
lines changed

4 files changed

+51
-18
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
namespace TransactionMobile.Maui.BusinessLogic.Models;
2+
3+
public class AppCenterConfiguration
4+
{
5+
public String AndroidKey { get; set; }
6+
public String iOSKey { get; set; }
7+
public String MacOSKey { get; set; }
8+
public String WindowsKey { get; set; }
9+
10+
public String GetAppCenterKey() {
11+
List<String> apiKeys = new List<String>();
12+
if (String.IsNullOrEmpty(AndroidKey) == false) {
13+
apiKeys.Add($"android={this.AndroidKey};");
14+
}
15+
if (String.IsNullOrEmpty(iOSKey) == false)
16+
{
17+
apiKeys.Add($"ios={this.iOSKey};");
18+
}
19+
if (String.IsNullOrEmpty(WindowsKey) == false)
20+
{
21+
apiKeys.Add($"uwp={this.WindowsKey};");
22+
}
23+
if (String.IsNullOrEmpty(MacOSKey) == false)
24+
{
25+
apiKeys.Add($"macos={this.MacOSKey};");
26+
}
27+
28+
return String.Join("+", apiKeys);
29+
}
30+
}

TransactionMobile.Maui.BusinessLogic/Models/Configuration.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,6 @@ public class Configuration
1919
public Boolean EnableAutoUpdates { get; set; }
2020

2121
public Boolean ShowDebugMessages { get; set; }
22+
23+
public AppCenterConfiguration AppCenterConfig { get; set; }
2224
}

TransactionMobile.Maui.BusinessLogic/Services/DummyServices/DummyConfigurationService.cs

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,24 @@ public class DummyConfigurationService : IConfigurationService
77
#region Methods
88

99
public async Task<Configuration> GetConfiguration(String deviceIdentifier,
10-
CancellationToken cancellationToken)
11-
{
12-
return new Configuration
13-
{
14-
ClientId = "dummyClientId",
15-
ClientSecret = "dummyClientSecret",
16-
EnableAutoUpdates = true,
17-
ShowDebugMessages = true,
18-
EstateManagementUri = "http://localhost:5000",
19-
EstateReportingUri = "http://localhost:5006",
20-
LogLevel = LogLevel.Debug,
21-
SecurityServiceUri = "http://localhost:5001",
22-
TransactionProcessorAclUri = "http://localhost:5003"
23-
};
10+
CancellationToken cancellationToken) {
11+
return new Configuration {
12+
ClientId = "dummyClientId",
13+
ClientSecret = "dummyClientSecret",
14+
EnableAutoUpdates = false,
15+
ShowDebugMessages = true,
16+
EstateManagementUri = "http://localhost:5000",
17+
EstateReportingUri = "http://localhost:5006",
18+
LogLevel = LogLevel.Debug,
19+
SecurityServiceUri = "http://localhost:5001",
20+
TransactionProcessorAclUri = "http://localhost:5003",
21+
AppCenterConfig = new AppCenterConfiguration {
22+
AndroidKey = String.Empty,
23+
MacOSKey = String.Empty,
24+
WindowsKey = String.Empty,
25+
iOSKey = String.Empty
26+
}
27+
};
2428
}
2529

2630
public async Task PostDiagnosticLogs(String deviceIdentifier,

TransactionMobile.Maui.BusinessLogic/ViewModels/HomePageViewModel.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,7 @@ public async Task Initialise(CancellationToken cancellationToken) {
5555

5656
try {
5757
if (this.IsIOS() == false) {
58-
// TODO: Move the keys to config service
59-
AppCenter.Start("android=f920cc96-de56-42fe-87d4-b49105761205;" + "ios=dd940171-ca8c-4219-9851-f83769464f37;" +
60-
"uwp=3ad27ea3-3f24-4579-a88a-530025bd00d4;" + "macos=244fdee2-f897-431a-8bab-5081fc90b329;",
61-
typeof(Distribute));
58+
AppCenter.Start(configuration.AppCenterConfig.GetAppCenterKey(), typeof(Distribute));
6259
}
6360
}
6461
catch(Exception ex) {

0 commit comments

Comments
 (0)