Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xamarin.Forms + HockeyApp - auto submit crash reports

I am trying to enable automatic (no user prompt) submission of hockey app crash reports on Xamarin.Forms (Android and iOS):

I have this for Android in MainActivity.cs:

var customCrashListener = new CustomCrashListener();
CrashManager.Register(this, "appId", customCrashListener);

where CustomCrashListener is:

class CustomCrashListener : CrashManagerListener
{
    public bool ShouldAutoUploadCrashes()
    {
        return true;
    }
}

This isn't sending any crash reports and HockeyApp with Xamarin documentation is thin. I am also trying to get this work on iOS.

like image 566
ethane Avatar asked Jun 08 '17 13:06

ethane


1 Answers

Included some example code below, with statements to enable debugging on the SDK's. With this enabled you can have a look at the application output to pinpoint the problem. If you are crashing directly on startup the SDK will not have time to send crash reports. Also if the App ID is incorrect you can see this behavior.

You'll need to include the override keyword in your listener callback, like in the example below. Otherwise autosend will not be enabled and a crash prompt will still appear.

Hockey.LogLevel = 3;
CrashManager.Register(this, AppID, new MyCrashManagerListener());

public class MyCrashManagerListener : CrashManagerListener
        {

            public override bool ShouldAutoUploadCrashes()
            {
                return true;
            }
        }

For iOS, you just need to set BITCrashManagerStatus in your AppDelegate.cs before StartManager():

var manager = BITHockeyManager.SharedHockeyManager;
manager.Configure(App_ID);
manager.LogLevel = BITLogLevel.Debug;
manager.CrashManager.CrashManagerStatus = BITCrashManagerStatus.AutoSend;
manager.StartManager();
like image 156
Shawn Dyas Avatar answered Oct 07 '22 19:10

Shawn Dyas