/// <summary> /// Application developers override this method to perform actions when the application starts. /// </summary> /// <remarks> /// To be added. /// </remarks> protected override async void OnStart() { // TODO: Logging Console.WriteLine("In On Start"); if (App.Configuration != null) { if (App.Configuration.EnableAutoUpdates) { Distribute.SetEnabledAsync(true).Wait(); Distribute.CheckForUpdate(); } else { Distribute.DisableAutomaticCheckForUpdate(); } Distribute.ReleaseAvailable = this.OnReleaseAvailable; Distribute.UpdateTrack = UpdateTrack.Public; AppCenter.Start("android=10210e06-8a11-422b-b005-14081dc56375;", typeof(Distribute)); } // Handle when your app starts ILoginPresenter loginPresenter = App.Container.Resolve <ILoginPresenter>(); // show the login page await loginPresenter.Start(); }
protected override void OnStart() { if (!AppCenter.Configured) { AppCenterLog.Assert(LogTag, "AppCenter.LogLevel=" + AppCenter.LogLevel); AppCenter.LogLevel = LogLevel.Verbose; AppCenterLog.Info(LogTag, "AppCenter.LogLevel=" + AppCenter.LogLevel); AppCenterLog.Info(LogTag, "AppCenter.Configured=" + AppCenter.Configured); // Set callbacks Crashes.ShouldProcessErrorReport = ShouldProcess; Crashes.ShouldAwaitUserConfirmation = ConfirmationHandler; Crashes.GetErrorAttachments = GetErrorAttachmentsCallback; Distribute.ReleaseAvailable = OnReleaseAvailable; // Event handlers Crashes.SendingErrorReport += SendingErrorReportHandler; Crashes.SentErrorReport += SentErrorReportHandler; Crashes.FailedToSendErrorReport += FailedToSendErrorReportHandler; Push.PushNotificationReceived += PrintNotification; AppCenterLog.Assert(LogTag, "AppCenter.Configured=" + AppCenter.Configured); var updateTrack = TrackUpdateUtils.GetPersistedUpdateTrack(); if (updateTrack != null) { Distribute.UpdateTrack = updateTrack.Value; } if (Current.Properties.TryGetValue(Constants.AutomaticUpdateCheckKey, out object persistedObject) && !(bool)persistedObject) { Distribute.DisableAutomaticCheckForUpdate(); } AppCenter.Start(GetTokensString(), typeof(Analytics), typeof(Crashes), typeof(Distribute)); if (Current.Properties.ContainsKey(Constants.UserId) && Current.Properties[Constants.UserId] is string id) { AppCenter.SetUserId(id); } // Work around for SetUserId race condition. AppCenter.Start(typeof(Push)); AppCenter.IsEnabledAsync().ContinueWith(enabled => { AppCenterLog.Info(LogTag, "AppCenter.Enabled=" + enabled.Result); }); AppCenter.GetInstallIdAsync().ContinueWith(installId => { AppCenterLog.Info(LogTag, "AppCenter.InstallId=" + installId.Result); }); AppCenterLog.Info(LogTag, "AppCenter.SdkVersion=" + AppCenter.SdkVersion); Crashes.HasCrashedInLastSessionAsync().ContinueWith(hasCrashed => { AppCenterLog.Info(LogTag, "Crashes.HasCrashedInLastSession=" + hasCrashed.Result); }); Crashes.GetLastSessionCrashReportAsync().ContinueWith(task => { AppCenterLog.Info(LogTag, "Crashes.LastSessionCrashReport.StackTrace=" + task.Result?.StackTrace); }); } }
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 void OnStart() { if (!AppCenter.Configured) { AppCenterLog.Assert(LogTag, "AppCenter.LogLevel=" + AppCenter.LogLevel); AppCenter.LogLevel = LogLevel.Verbose; AppCenterLog.Info(LogTag, "AppCenter.LogLevel=" + AppCenter.LogLevel); AppCenterLog.Info(LogTag, "AppCenter.Configured=" + AppCenter.Configured); // Set callbacks Crashes.ShouldProcessErrorReport = ShouldProcess; Crashes.ShouldAwaitUserConfirmation = ConfirmationHandler; Crashes.GetErrorAttachments = GetErrorAttachmentsCallback; Distribute.ReleaseAvailable = OnReleaseAvailable; Distribute.WillExitApp = OnWillExitApp; Distribute.NoReleaseAvailable = OnNoReleaseAvailable; // Event handlers Crashes.SendingErrorReport += SendingErrorReportHandler; Crashes.SentErrorReport += SentErrorReportHandler; Crashes.FailedToSendErrorReport += FailedToSendErrorReportHandler; AppCenterLog.Assert(LogTag, "AppCenter.Configured=" + AppCenter.Configured); if (!StartType.OneCollector.Equals(StartTypeUtils.GetPersistedStartType())) { AppCenter.SetLogUrl("https://in-integration.dev.avalanch.es"); } Distribute.SetInstallUrl("https://install.portal-server-core-integration.dev.avalanch.es"); Distribute.SetApiUrl("https://api-gateway-core-integration.dev.avalanch.es/v0.1"); var updateTrack = TrackUpdateUtils.GetPersistedUpdateTrack(); if (updateTrack != null) { Distribute.UpdateTrack = updateTrack.Value; } if (Current.Properties.TryGetValue(Constants.AutomaticUpdateCheckKey, out object persistedObject) && !(bool)persistedObject) { Distribute.DisableAutomaticCheckForUpdate(); } if (Current.Properties.ContainsKey(Constants.StorageMaxSize) && Current.Properties[Constants.StorageMaxSize] is long size) { AppCenter.SetMaxStorageSizeAsync(size); } AppCenter.Start(GetTokensString(), typeof(Analytics), typeof(Crashes), typeof(Distribute)); if (Current.Properties.ContainsKey(Constants.UserId) && Current.Properties[Constants.UserId] is string id) { AppCenter.SetUserId(id); } AppCenter.IsEnabledAsync().ContinueWith(enabled => { AppCenterLog.Info(LogTag, "AppCenter.Enabled=" + enabled.Result); }); AppCenter.GetInstallIdAsync().ContinueWith(installId => { AppCenterLog.Info(LogTag, "AppCenter.InstallId=" + installId.Result); }); AppCenterLog.Info(LogTag, "AppCenter.SdkVersion=" + AppCenter.SdkVersion); Crashes.HasCrashedInLastSessionAsync().ContinueWith(hasCrashed => { AppCenterLog.Info(LogTag, "Crashes.HasCrashedInLastSession=" + hasCrashed.Result); }); Crashes.GetLastSessionCrashReportAsync().ContinueWith(task => { AppCenterLog.Info(LogTag, "Crashes.LastSessionCrashReport.StackTrace=" + task.Result?.StackTrace); }); } }