IosAnalyticsDebugger
示例
要运行示例项目,首先克隆仓库,然后在示例目录中运行pod install
。
要求
安装
IosAnalyticsDebugger可通过CocoaPods获得。要安装,只需将以下行添加到Podfile中。
pod 'IosAnalyticsDebugger'
创建调试实例
Obj-C
AnalyticsDebugger * debugger = [AnalyticsDebugger new];
Swift
let debugger = AnalyticsDebugger()
请记住在某个地方保留对AnalyticsDebugger
实例的引用,例如在您的应用程序代理中。否则,它将无法响应触摸。
显示调试器
Obj-C
[debugger showBubbleDebugger];
或
[debugger showBarDebugger];
Swift
debugger.showBubble()
或
debugger.showBarDebugger()
隐藏调试器
Obj-C
[debugger hideDebugger];
Swift
debugger.hide()
发布事件
Obj-C
NSMutableArray * props = [NSMutableArray new];
[props addObject:[[DebuggerProp alloc] initWithId:@"id0" withName:@"id0 event" withValue:@"value 0"]];
[props addObject:[[DebuggerProp alloc] initWithId:@"id1" withName:@"id1 event" withValue:@"value 1"]];
NSMutableArray * errors = [NSMutableArray new];
[errors addObject:[[DebuggerPropError alloc] initWithPropertyId:@"id0" withMessage:@"error in event id0"]];
[debugger publishEvent:@"Test Event" withTimestamp:[NSNumber numberWithDouble:[[NSDate date] timeIntervalSince1970]]
withProperties:props withErrors:errors];
Swift
debugger.publishEvent("Test Event", withTimestamp: NSNumber(value: NSDate().timeIntervalSince1970),
withProperties: [DebuggerProp(id: "id0", withName: "prop 0", withValue: "value 0"),
DebuggerProp(id: "id1", withName: "prop 1", withValue: "value 1")],
withErrors: [DebuggerPropError(propertyId: "id0", withMessage: "error in event with id0")]);
与 Avo 一起使用
当使用 Avo 生成的代码时,您将调用 init
方法。实际方法接口取决于您的方案设置,但将会有带有 debugger
参数的 init 方法,您可以在其中传入 AnalyticsDebugger
的实例。
Obj-C
[Avo initAvoWithEnv:AVOEnvDev ... debugger:debugger];
Swift
Avo.initAvo(env: AvoEnv.dev, ..., debugger: debugger)
之后,Avo 函数调用的事件将自动可在调试器 UI 中访问。
作者
Avo (https://www.avo.app), [email protected]
许可证
IosAnalyticsDebugger 在 MIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。