2
votes

I am using Hockeyapp to log crashes in my Xamarin application.
For Android I used this code to auto submit crashes with little extra info:
Inside MainActivity OnCreate method:

CrashManager.Register(this, "APP_ID", new CustomCrashListener());

CustomCrashListener:

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

    public override string UserID => "UserID recovered from settings.";
    public override string Contact => "More info from settings.";
    public override string Description => "Custom Description";
}

Now for the iOS I have found this to auto upload crashes:

Inside AppDelegate:

BITHockeyManager manager = BITHockeyManager.SharedHockeyManager;
manager.Configure("APP_ID");
manager.CrashManager.CrashManagerStatus = BITCrashManagerStatus.AutoSend;
manager.StartManager();
manager.Authenticator.AuthenticateInstallation();

My problem is that I can't find something similar to Android in iOS to send some extra little information with the auto send of crash logs, is there any way to do that in iOS?

1

1 Answers

3
votes

On your UIApplicationDelegate class, add the IBITHockeyManagerDelegate and/or IBITCrashManagerDelegate.

UIApplicationDelegate Example:

[Register("AppDelegate")]
public class AppDelegate : UIApplicationDelegate, IBITHockeyManagerDelegate, IBITCrashManagerDelegate

Assign it to your BITHockeyManager.Delegate:

var hockeyManager = BITHockeyManager.SharedHockeyManager;
hockeyManager.Delegate = (HockeyApp.iOS.BITHockeyManagerDelegate)(IBITHockeyManagerDelegate)this;

Implement which extra info methods you need:

// From IBITHockeyManagerDelegate
[Export("userIDForHockeyManager:componentManager:")]
public string UserIdForHockeyManager(BITHockeyManager hockeyManager, BITHockeyBaseManager componentManager)
{
    return "sushihangover";
}

[Export("userNameForHockeyManager:componentManager:")]
public string UserNameForHockeyManager(BITHockeyManager hockeyManager, BITHockeyBaseManager componentManager)
{
    return "Sushi Hangover";
}

[Export("userEmailForHockeyManager:componentManager:")]
public string UserEmailForHockeyManager(BITHockeyManager hockeyManager, BITHockeyBaseManager componentManager)
{
    return "[email protected]";
}

// From IBITCrashManagerDelegate
[Export("applicationLogForCrashManager:")]
public string ApplicationLogForCrashManager(BITCrashManager crashManager)
{
    return "StackOverflow rocks...";
}

Ref: https://support.hockeyapp.net/kb/client-integration-ios-mac-os-x-tvos/hockeyapp-for-ios#crashreporting