in Apps/Contoso.Forms.Demo/Contoso.Forms.Demo/App.xaml.cs [48:123]
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;
// Country code.
if (Current.Properties.ContainsKey(Constants.CountryCode)
&& Current.Properties[Constants.CountryCode] is string countryCode)
{
AppCenter.SetCountryCode(countryCode);
}
// Manual session tracker.
if (Current.Properties.ContainsKey(Constants.EnableManualSessionTracker)
&& Current.Properties[Constants.EnableManualSessionTracker] is bool isEnabled
&& isEnabled)
{
Analytics.EnableManualSessionTracker();
}
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();
}
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);
});
}
}