ios - 如何在 Xamarin.iOS 中将崩溃日志自动发送到 HokeyApp 并提供额外信息?
<p><p>我正在使用 Hockeyapp 在我的 Xamarin 应用程序中记录崩溃。<br/>
对于 Android,我使用此代码自动提交崩溃,并提供很少的额外信息:<br/>
<strong>MainActivity OnCreate 方法内部:</strong> </p>
<p><code>CrashManager.Register(this, "APP_ID", new CustomCrashListener());</code></p>
<p><strong>CustomCrashListener:</strong> </p>
<pre><code>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";
}
</code></pre>
<p>现在对于 iOS,我发现这是自动上传崩溃:</p>
<p><strong>AppDelegate 内部:</strong> </p>
<pre><code>BITHockeyManager manager = BITHockeyManager.SharedHockeyManager;
manager.Configure("APP_ID");
manager.CrashManager.CrashManagerStatus = BITCrashManagerStatus.AutoSend;
manager.StartManager();
manager.Authenticator.AuthenticateInstallation();
</code></pre>
<p>我的问题是我在 iOS 中找不到类似于 Android 的东西来通过自动发送崩溃日志来发送一些额外的小信息,<strong>在 iOS 中有什么方法可以做到这一点?</strong></p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>在您的 <code>UIApplicationDelegate</code> 类中,添加 <code>IBITHockeyManagerDelegate</code> 和/或 <code>IBITCrashManagerDelegate</code>。</p>
<h3>UIApplicationDelegate 示例:</h3>
<pre><code>
public class AppDelegate : UIApplicationDelegate, IBITHockeyManagerDelegate, IBITCrashManagerDelegate
</code></pre>
<h3>将其分配给您的 <code>BITHockeyManager.Delegate</code>:</h3>
<pre><code>var hockeyManager = BITHockeyManager.SharedHockeyManager;
hockeyManager.Delegate = (HockeyApp.iOS.BITHockeyManagerDelegate)(IBITHockeyManagerDelegate)this;
</code></pre>
<h3>实现你需要的<strong>extra info</strong>方法:</h3>
<pre><code>// From IBITHockeyManagerDelegate
public string UserIdForHockeyManager(BITHockeyManager hockeyManager, BITHockeyBaseManager componentManager)
{
return "sushihangover";
}
public string UserNameForHockeyManager(BITHockeyManager hockeyManager, BITHockeyBaseManager componentManager)
{
return "Sushi Hangover";
}
public string UserEmailForHockeyManager(BITHockeyManager hockeyManager, BITHockeyBaseManager componentManager)
{
return "[email protected]";
}
// From IBITCrashManagerDelegate
public string ApplicationLogForCrashManager(BITCrashManager crashManager)
{
return "StackOverflow rocks...";
}
</code></pre>
<p>引用:<a href="https://support.hockeyapp.net/kb/client-integration-ios-mac-os-x-tvos/hockeyapp-for-ios#crashreporting" rel="noreferrer noopener nofollow">https://support.hockeyapp.net/kb/client-integration-ios-mac-os-x-tvos/hockeyapp-for-ios#crashreporting</a> </p></p>
<p style="font-size: 20px;">关于ios - 如何在 Xamarin.iOS 中将崩溃日志自动发送到 HokeyApp 并提供额外信息?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/41714627/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/41714627/
</a>
</p>
页:
[1]