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); }); } }
void RefreshDistributeTrackUpdate() { UpdateTrackPicker.SelectedIndex = TrackUpdateUtils.ToPickerUpdateTrackIndex(TrackUpdateUtils.GetPersistedUpdateTrack() ?? UpdateTrack.Public); }
public OthersContentPage() { InitializeComponent(); if (XamarinDevice.RuntimePlatform == XamarinDevice.iOS) { Icon = "handbag.png"; } // Setup track update dropdown choices. foreach (var trackUpdateType in TrackUpdateUtils.GetUpdateTrackChoiceStrings()) { this.UpdateTrackPicker.Items.Add(trackUpdateType); } UpdateTrackPicker.SelectedIndex = TrackUpdateUtils.ToPickerUpdateTrackIndex(TrackUpdateUtils.GetPersistedUpdateTrack() ?? UpdateTrack.Public); }
async void ChangeUpdateTrack(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "IsFocused" && !UpdateTrackPicker.IsFocused) { var newSelectionCandidate = UpdateTrackPicker.SelectedIndex; var persistedStartType = TrackUpdateUtils.ToPickerUpdateTrackIndex(TrackUpdateUtils.GetPersistedUpdateTrack() ?? UpdateTrack.Public); if (newSelectionCandidate != persistedStartType) { var newTrackUpdateValue = TrackUpdateUtils.FromPickerUpdateTrackIndex(newSelectionCandidate); await TrackUpdateUtils.SetPersistedUpdateTrackAsync(newTrackUpdateValue); await DisplayAlert("Update Track Changed", "Please kill and restart the app for the new update track to take effect.", "OK"); } } }
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); }