Mauro Piccotti
Mauro Piccotti

Reputation: 1847

Visual Studio App Center: crashes and errors not working on Xamarin iOS

In my Xamarin iOS app I enabled AppCenter's Analytics and Crash how explained here: https://learn.microsoft.com/en-us/appcenter/sdk/getting-started/xamarin

Analytics works, but I'm not able to see any crash/error on the Diagnostic section of App Center web console. In troubleshooting page there is written that on iOS cannot be more than a tool for exception handling, and this is the only one. In my app I enabled FCM so there is Firebase, I tried to remove any reference to Firebase but nothing changes.

Enabling AppCenter.LogLevel = LogLevel.Verbose; I can see that when app crashes AppCenter tries to store the exception ("Storing a log to Crashes"), but after I can see a "Found an empty buffer position". At the restart I see that SendingErrorReport callback is called, but SentErrorReport and FailedToSendErrorReport are ignored.

After AppCenter.Start I tried to call await Crashes.SetEnabledAsync(true). If I let it crash and when I reopen the app I call ErrorReport crashReport = await Crashes.GetLastSessionCrashReportAsync() crash report is always null.

In Symbols section I can read "You're awesome! There are no unsymbolicated crashes". I tried to compile in Debug and in Release. I tried to launch a new Exception and to use Crashes.GenerateTestCrash.

I didn't have any problem using Analytics and Crash with a Xamarin.Forms app.

Upvotes: 4

Views: 7038

Answers (2)

AZ_
AZ_

Reputation: 21899

Finally after lot of hit and trial I have found that you have to override a different FinishedLaunching method, which provides UIApplication & NSDictionary params.

public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            AppCenter.LogLevel = LogLevel.Verbose; //just so you can see in debug //that it is running successfully
            AppCenter.Start(#your app id#, typeof(Crashes));
}

You are welcome ;-)


  1. Error logs will be uploaded the next time app loads, so crash it on a button click, then close the app and remove it from recent apps.
  2. Start the app again and wait couple of moments, then see the web UI
  3. Depending upon the OS version you also have to add following code into the info.plist

    <key>NSAppTransportSecurity</key>
      <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
      </dict>

Upvotes: 2

Artūras Paleičikas
Artūras Paleičikas

Reputation: 629

This kind configuration works me as well:

using Microsoft.AppCenter.Crashes;

AppCenter.Start(Settings.AppCenterConfigString, typeof(Analytics), typeof(Crashes) /*, typeof(Push)*/);
Crashes.NotifyUserConfirmation(UserConfirmation.AlwaysSend);

Custom Exception (Error) logging:

catch (Exception e) { Crashes.TrackError(e, ...); }

https://learn.microsoft.com/en-us/appcenter/sdk/crashes/xamarin#ask-for-the-users-consent-to-send-a-crash-log

Upvotes: 3

Related Questions