76 lines
2.0 KiB
Objective-C
76 lines
2.0 KiB
Objective-C
|
|
|
|
// Created by BuglyManager Example
|
|
// Copyright © 2024 YuMi. All rights reserved.
|
|
|
|
|
|
#import "BuglyManagerExample.h"
|
|
#import "BuglyManager.h"
|
|
|
|
@implementation BuglyManagerExample
|
|
|
|
#pragma mark - 使用示例
|
|
|
|
|
|
- (void)setupBuglyDelegate {
|
|
[BuglyManager sharedManager].delegate = self;
|
|
}
|
|
|
|
|
|
- (void)reportBusinessErrorExample {
|
|
NSDictionary *context = @{
|
|
@"page": @"HomePage",
|
|
@"action": @"loadData",
|
|
@"timestamp": @([[NSDate date] timeIntervalSince1970])
|
|
};
|
|
|
|
[[BuglyManager sharedManager] reportBusinessError:@"数据加载失败"
|
|
code:1001
|
|
context:context];
|
|
}
|
|
|
|
|
|
- (void)reportNetworkErrorExample {
|
|
NSDictionary *userInfo = @{
|
|
@"requestParams": @{@"userId": @"12345"},
|
|
@"responseData": @"服务器错误"
|
|
};
|
|
|
|
[[BuglyManager sharedManager] reportNetworkError:@"user123"
|
|
api:@"user/profile"
|
|
code:500
|
|
userInfo:userInfo];
|
|
}
|
|
|
|
|
|
- (void)reportIAPErrorExample {
|
|
NSDictionary *context = @{
|
|
@"retryCount": @3,
|
|
@"productId": @"com.yumi.coin100"
|
|
};
|
|
|
|
[[BuglyManager sharedManager] reportIAPError:@"user123"
|
|
transactionId:@"txn_123456"
|
|
orderId:@"order_789"
|
|
status:2
|
|
context:context];
|
|
}
|
|
|
|
#pragma mark - BuglyManagerDelegate
|
|
|
|
- (void)buglyManager:(BuglyManager *)manager didDetectLag:(NSTimeInterval)duration {
|
|
NSLog(@"[Example] 检测到卡顿,持续时间: %.2f 秒", duration);
|
|
|
|
// TODO: 在这里实现卡顿通知逻辑
|
|
|
|
|
|
}
|
|
|
|
- (void)buglyManager:(BuglyManager *)manager didDetectBlock:(NSTimeInterval)duration {
|
|
NSLog(@"[Example] 检测到主线程阻塞,持续时间: %.2f 秒", duration);
|
|
|
|
// TODO: 在这里实现阻塞通知逻辑
|
|
}
|
|
|
|
@end
|