diff --git a/.gitignore b/.gitignore
index 6272ab93..73dcc4f5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -325,3 +325,7 @@ ASALocalRun/
# MFractors (Xamarin productivity tool) working folder
.mfractor/
+
+# Firebase
+*google-services.json
+*GoogleService-Info.plist
diff --git a/src/app/ApplicationTemplate.Business/ForcedUpdates/UpdateRequiredService.cs b/src/app/ApplicationTemplate.Business/ForcedUpdates/UpdateRequiredService.cs
index 5882edd6..f2c23db2 100644
--- a/src/app/ApplicationTemplate.Business/ForcedUpdates/UpdateRequiredService.cs
+++ b/src/app/ApplicationTemplate.Business/ForcedUpdates/UpdateRequiredService.cs
@@ -18,7 +18,13 @@ public sealed class UpdateRequiredService : IUpdateRequiredService, IDisposable
public UpdateRequiredService(IMinimumVersionReposiory minimumVersionReposiory)
{
_subscription = minimumVersionReposiory.MinimumVersionObservable
- .Subscribe(_ => UpdateRequired?.Invoke(this, EventArgs.Empty));
+ .Subscribe(version =>
+ {
+ if (version > new Version("1.1.0"))
+ {
+ UpdateRequired?.Invoke(this, EventArgs.Empty);
+ }
+ });
}
///
diff --git a/src/app/ApplicationTemplate.Mobile/ApplicationTemplate.Mobile.csproj b/src/app/ApplicationTemplate.Mobile/ApplicationTemplate.Mobile.csproj
index 6678ad4b..63c14fb7 100644
--- a/src/app/ApplicationTemplate.Mobile/ApplicationTemplate.Mobile.csproj
+++ b/src/app/ApplicationTemplate.Mobile/ApplicationTemplate.Mobile.csproj
@@ -15,6 +15,9 @@
True
partial
+
+
+
@@ -100,7 +103,15 @@
-
+
+
+
+
+
+
+
+ google-services.json
+
@@ -153,6 +164,12 @@
true
+
+
+
+ GoogleService-Info.plist
+
+
diff --git a/src/app/ApplicationTemplate.Presentation/Configuration/ApiConfiguration.cs b/src/app/ApplicationTemplate.Presentation/Configuration/ApiConfiguration.cs
index 1bab32ae..0f622457 100644
--- a/src/app/ApplicationTemplate.Presentation/Configuration/ApiConfiguration.cs
+++ b/src/app/ApplicationTemplate.Presentation/Configuration/ApiConfiguration.cs
@@ -42,8 +42,6 @@ public static IServiceCollection AddApi(this IServiceCollection services, IConfi
.AddAuthentication()
.AddPosts(configuration)
.AddUserProfile()
- .AddMinimumVersion()
- .AddKillSwitch()
.AddDadJokes(configuration);
return services;
@@ -55,18 +53,6 @@ private static IServiceCollection AddUserProfile(this IServiceCollection service
return services.AddSingleton();
}
- private static IServiceCollection AddMinimumVersion(this IServiceCollection services)
- {
- // This one doesn't have an actual remote API yet. It's always a mock implementation.
- return services.AddSingleton();
- }
-
- private static IServiceCollection AddKillSwitch(this IServiceCollection services)
- {
- // This one doesn't have an actual remote API yet. It's always a mock implementation.
- return services.AddSingleton();
- }
-
private static IServiceCollection AddAuthentication(this IServiceCollection services)
{
// This one doesn't have an actual remote API yet. It's always a mock implementation.
diff --git a/src/app/ApplicationTemplate.Shared.Views/ApplicationTemplate.Shared.Views.projitems b/src/app/ApplicationTemplate.Shared.Views/ApplicationTemplate.Shared.Views.projitems
index 059e75fd..80a48587 100644
--- a/src/app/ApplicationTemplate.Shared.Views/ApplicationTemplate.Shared.Views.projitems
+++ b/src/app/ApplicationTemplate.Shared.Views/ApplicationTemplate.Shared.Views.projitems
@@ -118,6 +118,7 @@
+
Shell.xaml
diff --git a/src/app/ApplicationTemplate.Shared.Views/Configuration/ViewServicesConfiguration.cs b/src/app/ApplicationTemplate.Shared.Views/Configuration/ViewServicesConfiguration.cs
index b6d91d4d..ca0c1ec1 100644
--- a/src/app/ApplicationTemplate.Shared.Views/Configuration/ViewServicesConfiguration.cs
+++ b/src/app/ApplicationTemplate.Shared.Views/Configuration/ViewServicesConfiguration.cs
@@ -1,4 +1,5 @@
using System.Reactive.Concurrency;
+using ApplicationTemplate.DataAccess;
using Chinook.DynamicMvvm;
using MessageDialogService;
using Microsoft.Extensions.DependencyInjection;
@@ -34,6 +35,14 @@ public static IServiceCollection AddViewServices(this IServiceCollection service
.AddSingleton()
.AddSingleton()
.AddSingleton()
+#if __ANDROID__
+ .AddSingleton()
+ .AddSingleton(s => s.GetRequiredService())
+ .AddSingleton(s => s.GetRequiredService())
+#else
+ .AddSingleton()
+ .AddSingleton()
+#endif
.AddMessageDialog();
}
diff --git a/src/app/ApplicationTemplate.Shared.Views/RemoteConfigRepository.Android.cs b/src/app/ApplicationTemplate.Shared.Views/RemoteConfigRepository.Android.cs
new file mode 100644
index 00000000..241ccb26
--- /dev/null
+++ b/src/app/ApplicationTemplate.Shared.Views/RemoteConfigRepository.Android.cs
@@ -0,0 +1,101 @@
+#if __ANDROID__
+using System;
+using System.Reactive.Subjects;
+using ApplicationTemplate.DataAccess;
+using Firebase.RemoteConfig;
+
+namespace ApplicationTemplate.Views;
+
+///
+/// RemoteConfigRepository is a repository for Firebase Remote Config.
+///
+public class RemoteConfigRepository : IKillSwitchRepository, IMinimumVersionReposiory
+{
+ private Subject _killSwitchSubject = new Subject();
+ private Subject _versionSubject = new Subject();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public RemoteConfigRepository()
+ {
+ FirebaseRemoteConfig mFirebaseRemoteConfig = FirebaseRemoteConfig.Instance;
+ FirebaseRemoteConfigSettings configSettings = new FirebaseRemoteConfigSettings.Builder()
+ .SetMinimumFetchIntervalInSeconds(3600)
+ .Build();
+ mFirebaseRemoteConfig.SetConfigSettingsAsync(configSettings);
+
+ FetchRemoteConfig();
+ ListenForRealTimeChanges();
+ }
+
+ private void FetchRemoteConfig()
+ {
+ FirebaseRemoteConfig mFirebaseRemoteConfig = FirebaseRemoteConfig.Instance;
+ mFirebaseRemoteConfig.FetchAndActivate()
+ .AddOnCompleteListener(new FetchCompleteListener(this));
+ }
+
+ private void ListenForRealTimeChanges()
+ {
+ FirebaseRemoteConfig mFirebaseRemoteConfig = FirebaseRemoteConfig.Instance;
+
+ mFirebaseRemoteConfig.AddOnConfigUpdateListener(new ConfigUpdateListener(this));
+ }
+
+ ///
+ public IObservable MinimumVersionObservable => _versionSubject;
+
+ ///
+ public void CheckMinimumVersion()
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ public IObservable ObserveKillSwitchActivation()
+ {
+ return _killSwitchSubject;
+ }
+
+ private class FetchCompleteListener : Java.Lang.Object, Android.Gms.Tasks.IOnCompleteListener
+ {
+ private readonly RemoteConfigRepository _repository;
+
+ public FetchCompleteListener(RemoteConfigRepository repository)
+ {
+ _repository = repository;
+ }
+
+ public void OnComplete(Android.Gms.Tasks.Task task)
+ {
+ if (task.IsSuccessful)
+ {
+ _repository._killSwitchSubject.OnNext(FirebaseRemoteConfig.Instance.GetBoolean("kill_switch"));
+ _repository._versionSubject.OnNext(new Version(FirebaseRemoteConfig.Instance.GetString("minimum_version")));
+ }
+ }
+ }
+
+ private class ConfigUpdateListener : Java.Lang.Object, IConfigUpdateListener
+ {
+ private readonly RemoteConfigRepository _repository;
+
+ public ConfigUpdateListener(RemoteConfigRepository repository)
+ {
+ _repository = repository;
+ }
+
+ public void OnError(FirebaseRemoteConfigException p0)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void OnUpdate(ConfigUpdate p0)
+ {
+ _repository._killSwitchSubject.OnNext(FirebaseRemoteConfig.Instance.GetBoolean("kill_switch"));
+ _repository._versionSubject.OnNext(new Version(FirebaseRemoteConfig.Instance.GetString("minimum_version")));
+ }
+ }
+}
+#endif