Xamarin.Forms + HockeyApp - auto submit crash reports
Asked Answered
G

1

6

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.

Gnome answered 8/6, 2017 at 13:5 Comment(0)
V
6

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();
Virge answered 8/6, 2017 at 17:14 Comment(1)
Thank you, this works well. Tested in Xamarin.Forms v2.3.4.247Sharecropper

© 2022 - 2024 — McMap. All rights reserved.