华为AGC的解体服务反对跨平台,依照文档整顿了个Xamarin插件集成的文档,有须要的开发者能够参考。
环境配置和我的项目设置
1.装置Xamarin环境
次要是先装置visual studio for MAC,而后装置Mobile development with .NET,具体能够参考Xamarin环境搭建。
2.AGC创立我的项目工程,并且开明华为剖析服务。
这部分是基本操作,能够参见创立我的项目和开明华为剖析
3.集成AGC Xamarin NuGet包
点击创立的我的项目工程,右键抉择”Manage NuGet Packages”
抉择对应的包后装置:
持续增加HA包,留神须要抉择1.2.0.300版本:
4.增加Json文件到我的项目目录下
5.将“Build Action”设置为“BundleResource”。
6.设置利用包名。
7.配置收费预配证书
如果没有申请付费证书,能够应用收费证书,具体参见:
https://developer.huawei.com/…
集成实现
1.布局界面设计
双击main.storyboard拉起Xcode创立3个按键“MakeCrash”,” CatchException”,” CustomReport”。
2.代码调用
编辑 ViewController.cs 文件, 调用 AGCCrash.GetSharedInstance.TestIt 制作一次解体事件,调用 AGCCrash.GetSharedInstance.SetUserId 自定义用户标识,调用 AGCCrash.GetSharedInstance.SetCustomKey 自定义键值对,调用 AGCCrash.GetSharedInstance.Log 自定义日志级别,调用 AGCCrash.GetSharedInstance. RecordException 产生并记录一次非重大异样。
using System;
using UIKit;
using Huawei.Agconnect.Crash;
using Foundation;
namespace crashios0512
{
public partial class ViewController : UIViewController
{
public ViewController(IntPtr handle) : base(handle)
{
}
public override void ViewDidLoad()
{
base.ViewDidLoad();
// Perform any additional setup after loading the view, typically from a nib.
}
public override void DidReceiveMemoryWarning()
{
base.DidReceiveMemoryWarning();
// Release any cached data, images, etc that aren't in use.
}
partial void MakeCrash(UIKit.UIButton sender)
{
AGCCrash.GetSharedInstance().TestIt();
}
partial void CatchException(UIKit.UIButton sender)
{
AGCCrash.GetSharedInstance().RecordError(new Foundation.NSError());
}
partial void CustomReport(UIKit.UIButton sender)
{
AGCCrash.GetSharedInstance().SetUserId("testuser");
AGCCrash.GetSharedInstance().Log("default info level");
AGCCrash.GetSharedInstance().SetCustomValue(new NSString("test"), "this is string value");
AGCCrash.GetSharedInstance().LogWithLevel(AGCCrashLogLevel.Warning, "this is warning log level");
AGCCrash.GetSharedInstance().SetCustomValue(new NSNumber(123), "this is number");
}
}
}
解体报告查看
集成完后点击按键制作解体和非重大异样,并产生自定义报告,能够在AGC页面查看
1.解体概览
2.问题概览
3.查看解体详情堆栈
4.查看自定义键值对
5.查看自定义日志级别
6.查看自定义用户标识
欲了解更多详情,请参见:
1、华为AGC 解体服务文档:https://developer.huawei.com/…
2、华为AGC-解体服务codelab:https://developer.huawei.com/…
更多精彩内容,请见华为开发者官方论坛→https://developer.huawei.com/…
发表回复