protected override async void OnAppearing() { base.OnAppearing(); var acEnabled = await AppCenter.IsEnabledAsync(); DistributeEnabledSwitchCell.On = await Distribute.IsEnabledAsync(); DistributeEnabledSwitchCell.IsEnabled = acEnabled; PushEnabledSwitchCell.On = await Push.IsEnabledAsync(); PushEnabledSwitchCell.IsEnabled = acEnabled; AuthEnabledSwitchCell.On = await Auth.IsEnabledAsync(); AuthEnabledSwitchCell.IsEnabled = acEnabled; if (!Application.Current.Properties.ContainsKey(AccountId)) { SignInInformationButton.Text = "Authentication status unknown"; } else if (Application.Current.Properties[AccountId] is string) { SignInInformationButton.Text = "User is authenticated"; } else { SignInInformationButton.Text = "User is not authenticated"; } }
protected override async void OnResume() { base.OnResume(); SetContentView(Resource.Layout.Main); //InputStream input = Assets.Open("my_asset.txt"); if (!IsTaskRoot) { // Don't start the app again from icon on launcher. Intent intent = Intent; String intentAction = intent.Action; if (intent.HasCategory(Intent.CategoryLauncher) && intentAction != null && intentAction.Equals(Intent.ActionMain)) { Finish(); return; } } AppCenter.Start(Constants.appCenterSecretDroid, typeof(Analytics), typeof(Crashes)); AppCenter.Start(Constants.appCenterSecretDroid, typeof(Distribute)); await Distribute.SetEnabledAsync(true); bool enabled = await Distribute.IsEnabledAsync(); StartTimer(); }
protected override async void OnAppearing() { base.OnAppearing(); var acEnabled = await AppCenter.IsEnabledAsync(); DistributeEnabledSwitchCell.On = await Distribute.IsEnabledAsync(); DistributeEnabledSwitchCell.IsEnabled = acEnabled; PushEnabledSwitchCell.On = await Push.IsEnabledAsync(); PushEnabledSwitchCell.IsEnabled = acEnabled; AuthEnabledSwitchCell.On = await Auth.IsEnabledAsync(); AuthEnabledSwitchCell.IsEnabled = acEnabled; RumEnabledSwitchCell.On = _rumStarted && await RealUserMeasurements.IsEnabledAsync(); RumEnabledSwitchCell.IsEnabled = acEnabled; EventFilterEnabledSwitchCell.On = _eventFilterStarted && await EventFilterHolder.Implementation?.IsEnabledAsync(); EventFilterEnabledSwitchCell.IsEnabled = acEnabled && EventFilterHolder.Implementation != null; if (!Application.Current.Properties.ContainsKey(AccountId)) { SignInInformationButton.Text = "Authentication status unknown"; } else if (Application.Current.Properties[AccountId] is string) { SignInInformationButton.Text = "User is authenticated"; } else { SignInInformationButton.Text = "User is not authenticated"; } }
async void RefreshDistributeEnabled(bool _appCenterEnabled) { DistributeEnabledSwitchCell.On = await Distribute.IsEnabledAsync(); DistributeEnabledSwitchCell.IsEnabled = _appCenterEnabled; RefreshDistributeTrackUpdate(); }
protected override async void OnAppearing() { base.OnAppearing(); var acEnabled = await AppCenter.IsEnabledAsync(); DistributeEnabledSwitchCell.On = await Distribute.IsEnabledAsync(); DistributeEnabledSwitchCell.IsEnabled = acEnabled; PushEnabledSwitchCell.On = await Push.IsEnabledAsync(); PushEnabledSwitchCell.IsEnabled = acEnabled; RumEnabledSwitchCell.On = _rumStarted && await RealUserMeasurements.IsEnabledAsync(); RumEnabledSwitchCell.IsEnabled = acEnabled; EventFilterEnabledSwitchCell.On = _eventFilterStarted && await EventFilterHolder.Implementation?.IsEnabledAsync(); EventFilterEnabledSwitchCell.IsEnabled = acEnabled && EventFilterHolder.Implementation != null; if (userInfo?.AccountId != null) { SignInInformationButton.Text = "User authenticated"; } else { SignInInformationButton.Text = "User not authenticated"; } }
public async Task CheckForUpdateTest(UpdateTrack updateTrack, string urlDiff) { // Enable Distribute for debuggable builds. DistributeEvent?.Invoke(this, DistributeTestType.EnableDebuggableBuilds); // Setup network adapter. var httpNetworkAdapter = new HttpNetworkAdapter(); DependencyConfiguration.HttpNetworkAdapter = httpNetworkAdapter; var implicitCheckForUpdateTask = httpNetworkAdapter.MockRequest(request => request.Method == "GET" && request.Uri.Contains(urlDiff)); var startServiceTask = httpNetworkAdapter.MockRequestByLogType("startService"); // Start AppCenter. AppCenter.UnsetInstance(); AppCenter.LogLevel = LogLevel.Verbose; Distribute.UpdateTrack = updateTrack; // Save update token. if (updateTrack == UpdateTrack.Private) { DistributeEvent?.Invoke(this, DistributeTestType.SaveMockUpdateToken); } AppCenter.Start(Config.ResolveAppSecret(), typeof(Distribute)); // Wait for "startService" log to be sent. await startServiceTask; DistributeEvent?.Invoke(this, DistributeTestType.OnResumeActivity); // Wait when Distribute will start. await Distribute.IsEnabledAsync(); // Wait for processing event. var resultImplicit = await implicitCheckForUpdateTask; // Verify response. Assert.Equal("GET", resultImplicit.Method); Assert.Contains(urlDiff, resultImplicit.Uri); Assert.Contains(Config.ResolveAppSecret(), resultImplicit.Uri); // Wait a 5s for give time to complete internal processes // to avoid this case `A check for update is already ongoing.` await Task.Delay(5000); // Check for update. var explicitCheckForUpdateTask = httpNetworkAdapter.MockRequest(request => request.Method == "GET" && request.Uri.Contains(urlDiff)); Distribute.CheckForUpdate(); // Wait for processing event. var resultExplicit = await explicitCheckForUpdateTask; // Verify response. Assert.Equal("GET", resultExplicit.Method); Assert.Contains(urlDiff, resultExplicit.Uri); Assert.Contains(Config.ResolveAppSecret(), resultExplicit.Uri); }
public async Task CheckForUpdateTest(UpdateTrack updateTrack, string urlDiff) { // Enable Distribute for debuggable builds. DistributeEvent?.Invoke(this, DistributeTestType.EnableDebuggableBuilds); // Setup network adapter. var httpNetworkAdapter = new HttpNetworkAdapter(); DependencyConfiguration.HttpNetworkAdapter = httpNetworkAdapter; HttpResponse response = new HttpResponse() { Content = GetReleaseJson("30", "3.0.0", false, 19), StatusCode = 200 }; var implicitCheckForUpdateTask = httpNetworkAdapter.MockRequest(request => request.Method == "GET"); var explicitCheckForUpdateTask = httpNetworkAdapter.MockRequest(request => request.Method == "GET", response); var startServiceTask = httpNetworkAdapter.MockRequestByLogType("startService"); // Start AppCenter. AppCenter.UnsetInstance(); AppCenter.LogLevel = LogLevel.Verbose; Distribute.UpdateTrack = updateTrack; // Save update token. if (updateTrack == UpdateTrack.Private) { DistributeEvent?.Invoke(this, DistributeTestType.SaveMockUpdateToken); } AppCenter.Start(Config.ResolveAppSecret(), typeof(Distribute)); // Wait for "startService" log to be sent. await startServiceTask; DistributeEvent?.Invoke(this, DistributeTestType.OnResumeActivity); // Wait when Distribute will start. await Distribute.IsEnabledAsync(); // Wait for processing event. var result = await implicitCheckForUpdateTask; // Verify response. Assert.Equal("GET", result.Method); Assert.True(result.Uri.Contains(urlDiff)); Assert.True(result.Uri.Contains(Config.ResolveAppSecret())); // Check for update. Distribute.CheckForUpdate(); // Wait for processing event. result = await explicitCheckForUpdateTask; // Verify response. Assert.Equal("GET", result.Method); Assert.True(result.Uri.Contains(urlDiff)); Assert.True(result.Uri.Contains(Config.ResolveAppSecret())); }
protected override async void UpdateState() { DistributeEnabledSwitch.CheckedChange -= UpdateDistributeEnabled; DistributeEnabledSwitch.Enabled = true; DistributeEnabledSwitch.Checked = await Distribute.IsEnabledAsync(); DistributeEnabledSwitch.Enabled = await AppCenter.IsEnabledAsync(); DistributeEnabledSwitch.CheckedChange += UpdateDistributeEnabled; }
protected override async void OnAppearing() { base.OnAppearing(); var acEnabled = await AppCenter.IsEnabledAsync(); DistributeEnabledSwitchCell.On = await Distribute.IsEnabledAsync(); DistributeEnabledSwitchCell.IsEnabled = acEnabled; PushEnabledSwitchCell.On = await Push.IsEnabledAsync(); PushEnabledSwitchCell.IsEnabled = acEnabled; }
async void RefreshDistributeTrackUpdate() { var isDistributeEnable = await Distribute.IsEnabledAsync(); if (!isDistributeEnable) { UpdateTrackPicker.IsEnabled = false; return; } UpdateTrackPicker.IsEnabled = true; UpdateTrackPicker.SelectedIndex = TrackUpdateUtils.ToPickerUpdateTrackIndex(TrackUpdateUtils.GetPersistedUpdateTrack() ?? UpdateTrack.Public); }
public async Task DisableAuthomaticCheckUpdateTest() { // Enable Distribute for debuggable builds. DistributeEvent?.Invoke(this, DistributeTestType.EnableDebuggableBuilds); // Setup network adapter. var httpNetworkAdapter = new HttpNetworkAdapter(); DependencyConfiguration.HttpNetworkAdapter = httpNetworkAdapter; HttpResponse response = new HttpResponse() { Content = GetReleaseJson("30", "3.0.0", false, 19), StatusCode = 200 }; var explicitCheckForUpdateTask = httpNetworkAdapter.MockRequest(request => request.Method == "GET", response, 30); var startServiceTask = httpNetworkAdapter.MockRequestByLogType("startService"); // Start AppCenter. AppCenter.UnsetInstance(); AppCenter.LogLevel = LogLevel.Verbose; Distribute.DisableAutomaticCheckForUpdate(); AppCenter.Start(Config.ResolveAppSecret(), typeof(Distribute)); // Wait for "startService" log to be sent. await startServiceTask; Assert.Equal(1, httpNetworkAdapter.CallCount); DistributeEvent?.Invoke(this, DistributeTestType.OnResumeActivity); // Wait when Distribute will start. await Distribute.IsEnabledAsync(); // Wait a 5s and verify that we will not have new calls. await Task.Delay(5000); Assert.Equal(1, httpNetworkAdapter.CallCount); // Check for update. Distribute.CheckForUpdate(); // Wait for processing event. var result = await explicitCheckForUpdateTask; // Verify response. Assert.Equal(2, httpNetworkAdapter.CallCount); Assert.Equal("GET", result.Method); Assert.True(result.Uri.Contains("releases/latest")); Assert.True(result.Uri.Contains(Config.ResolveAppSecret())); }
protected override async void OnAppearing() { base.OnAppearing(); var acEnabled = await AppCenter.IsEnabledAsync(); DistributeEnabledSwitchCell.On = await Distribute.IsEnabledAsync(); DistributeEnabledSwitchCell.IsEnabled = acEnabled; PushEnabledSwitchCell.On = await Push.IsEnabledAsync(); PushEnabledSwitchCell.IsEnabled = acEnabled; RumEnabledSwitchCell.On = _rumStarted && await RealUserMeasurements.IsEnabledAsync(); RumEnabledSwitchCell.IsEnabled = acEnabled; EventFilterEnabledSwitchCell.On = _eventFilterStarted && await EventFilterHolder.Implementation?.IsEnabledAsync(); EventFilterEnabledSwitchCell.IsEnabled = acEnabled && EventFilterHolder.Implementation != null; }
public async Task SetUpdateTrackPrivateTest() { // Enable Distribute for debuggable builds. DistributeEvent?.Invoke(this, DistributeTestType.EnableDebuggableBuilds); // Save data to preference. DistributeEvent?.Invoke(this, DistributeTestType.CheckUpdateAsync); // Setup network adapter. var httpNetworkAdapter = new HttpNetworkAdapter(); DependencyConfiguration.HttpNetworkAdapter = httpNetworkAdapter; var eventTask = httpNetworkAdapter.MockRequest(request => request.Method == "GET"); var startServiceTask = httpNetworkAdapter.MockRequestByLogType("startService"); // Start AppCenter. AppCenter.UnsetInstance(); AppCenter.LogLevel = LogLevel.Verbose; Distribute.UpdateTrack = UpdateTrack.Private; // MockUpdateToken. DistributeEvent?.Invoke(this, DistributeTestType.SaveMockUpdateToken); AppCenter.Start(Config.ResolveAppSecret(), typeof(Distribute)); // Wait for "startService" log to be sent. await startServiceTask; DistributeEvent?.Invoke(this, DistributeTestType.OnResumeActivity); // Wait when Distribute will start. await Distribute.IsEnabledAsync(); // Wait for processing event. var result = await eventTask; // Verify response. Assert.Equal("GET", result.Method); Assert.DoesNotContain("public", result.Uri); Assert.Contains("releases/private/latest?release_hash", result.Uri); Assert.Contains(Config.ResolveAppSecret(), result.Uri); // Clear. DistributeEvent?.Invoke(this, DistributeTestType.Clear); }
protected override async void OnAppearing() { base.OnAppearing(); var mcEnabled = await MobileCenter.IsEnabledAsync(); DistributeEnabledSwitchCell.On = await Distribute.IsEnabledAsync(); DistributeEnabledSwitchCell.IsEnabled = mcEnabled; PushEnabledSwitchCell.On = await Push.IsEnabledAsync(); PushEnabledSwitchCell.IsEnabled = mcEnabled; if (XamarinDevice.RuntimePlatform == XamarinDevice.Android) { if (!Application.Current.Properties.ContainsKey(FirebaseEnabledKey)) { Application.Current.Properties[FirebaseEnabledKey] = false; } FirebaseAnalyticsEnabledSwitchCell.On = (bool)Application.Current.Properties[FirebaseEnabledKey]; } RumEnabledSwitchCell.On = await RealUserMeasurements.IsEnabledAsync(); RumEnabledSwitchCell.IsEnabled = mcEnabled; }
protected override async void UpdateState() { DistributeEnabledSwitch.CheckedChange -= UpdateDistributeEnabled; DistributeEnabledSwitch.Enabled = true; DistributeEnabledSwitch.Checked = await Distribute.IsEnabledAsync(); DistributeEnabledSwitch.Enabled = await AppCenter.IsEnabledAsync(); DistributeEnabledSwitch.CheckedChange += UpdateDistributeEnabled; PushEnabledSwitch.CheckedChange -= UpdatePushEnabled; PushEnabledSwitch.Enabled = true; PushEnabledSwitch.Checked = await Push.IsEnabledAsync(); PushEnabledSwitch.Enabled = await AppCenter.IsEnabledAsync(); PushEnabledSwitch.CheckedChange += UpdatePushEnabled; FirebaseAnalyticsEnabledSwitch.CheckedChange -= UpdateFirebaseAnalyticsEnabled; var enableAnalytics = Preferences.SharedPreferences.GetBoolean(Constants.FirebaseAnalyticsEnabledKey, false); FirebaseAnalyticsEnabledSwitch.Checked = enableAnalytics; FirebaseAnalyticsEnabledSwitch.CheckedChange += UpdateFirebaseAnalyticsEnabled; }
public static async Task <bool> CheckIfUpdateServiceEnabledAsync() => await Distribute.IsEnabledAsync();
/// <summary> /// Raises the <see cref="NavigatedTo"/> event. /// </summary> /// <param name="e"> /// The <see cref="NavigatedToEventArgs"/> instance containing the event data. /// </param> /// <param name="viewModelState"> /// State of the view ViewModel. /// </param> /// <returns> /// A <see cref="Task"/> representing the asynchronous operation. /// </returns> public override async Task <bool> PopulateViewModelAsync() { // cache Header Data record HeaderData = DV.HeaderDV.HeaderDataModel.HLink; // Assembly level stuff var assembly = GetType().GetTypeInfo().Assembly; var assemblyName = new AssemblyName(assembly.FullName); CardListLineCollection t = new CardListLineCollection { new CardListLine("Application Name", AppInfo.Name), new CardListLine("Package Name", AppInfo.PackageName), new CardListLine("First Launch Ever?", VersionTracking.IsFirstLaunchEver), new CardListLine("First Launch Current Version?", VersionTracking.IsFirstLaunchForCurrentVersion), new CardListLine("First Launch Current Build?", VersionTracking.IsFirstLaunchForCurrentBuild), new CardListLine("Current Version", VersionTracking.CurrentVersion), new CardListLine("Current Build", VersionTracking.CurrentBuild), new CardListLine("Previous Version", VersionTracking.PreviousVersion), new CardListLine("Previous Build", VersionTracking.PreviousBuild), new CardListLine("First Version Installed", VersionTracking.FirstInstalledVersion), new CardListLine("First Build Installed", VersionTracking.FirstInstalledBuild), // // TODO new CardListLine("versionHistory", VersionTracking.VersionHistory), // // TODO new CardListLine("buildHistory", VersionTracking.BuildHistory), new CardListLine("Major Version", assemblyName.Version.Major), new CardListLine("Minor Version", assemblyName.Version.Minor), new CardListLine("Major Revision", assemblyName.Version.MajorRevision), new CardListLine("Middle Revision", assemblyName.Version.Revision), new CardListLine("Minor Revision", assemblyName.Version.MinorRevision), new CardListLine("App Center update status", await Distribute.IsEnabledAsync().ConfigureAwait(false)), new CardListLine("App Center update track", Distribute.UpdateTrack.ToString()), }; t.Title = "Application Versions"; ApplicationVersionList = t; // TODO Ugly - Trigger SetProperty //// Set WhatsNew text Set MarkdownView information that is not easily set in XAML //MarkdownTheme tt = new DarkMarkdownTheme //{ // BackgroundColor = CommonRoutines.ResourceColourGet("CardBackGroundNote") //}; //// Check for updates //await Distribute.SetEnabledAsync(true); //Distribute.CheckForUpdate(); return(true); }
partial void UpdateEnabled() { Distribute.SetEnabledAsync(DistributeEnabledSwitch.On).Wait(); DistributeEnabledSwitch.On = Distribute.IsEnabledAsync().Result; }
public override void ViewDidAppear(bool animated) { base.ViewDidAppear(animated); DistributeEnabledSwitch.On = Distribute.IsEnabledAsync().Result; DistributeEnabledSwitch.Enabled = AppCenter.IsEnabledAsync().Result; }
private async void UpdatePushEnabled(object sender, CompoundButton.CheckedChangeEventArgs e) { await Push.SetEnabledAsync(e.IsChecked); PushEnabledSwitch.Checked = await Distribute.IsEnabledAsync(); }