如何使用额外信息自动将崩溃日志发送到Xamarin.iOS中的HokeyApp?

时间:2017-01-18 08:34:59

标签: ios xamarin xamarin.ios hockeyapp

我正在使用Hockeyapp来记录我的Xamarin应用程序中的崩溃 对于Android,我使用此代码自动提交崩溃,只需要额外的信息:
内部MainActivity OnCreate方法:

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";
}

现在对于iOS我发现这是自动上传崩溃:

内部AppDelegate:

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

我的问题是,我无法在iOS中找到类似于Android的内容,通过自动发送崩溃日志发送一些额外的信息,在iOS中有什么方法可以做到这一点吗?

1 个答案:

答案 0 :(得分:3)

UIApplicationDelegate课程中,添加IBITHockeyManagerDelegate和/或IBITCrashManagerDelegate

UIApplicationDelegate示例:

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

将其分配给BITHockeyManager.Delegate

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

实施您需要的额外信息方法:

// 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 "sushihangover@hacktheplanet.me";
}

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

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