Files
real-e-party-iOS/YuMi/Global/BuglyManagerExample.m.backup
2025-10-17 14:52:29 +08:00

80 lines
2.3 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// BuglyManagerExample.m
// YuMi
//
// Created by BuglyManager Example
// Copyright © 2024 YuMi. All rights reserved.
//
#import "BuglyManagerExample.h"
#import "BuglyManager.h"
@implementation BuglyManagerExample
#pragma mark - 使用示例
// 示例1设置代理监听卡顿
- (void)setupBuglyDelegate {
[BuglyManager sharedManager].delegate = self;
}
// 示例2上报业务错误
- (void)reportBusinessErrorExample {
NSDictionary *context = @{
@"page": @"HomePage",
@"action": @"loadData",
@"timestamp": @([[NSDate date] timeIntervalSince1970])
};
[[BuglyManager sharedManager] reportBusinessError:@"数据加载失败"
code:1001
context:context];
}
// 示例3上报网络错误
- (void)reportNetworkErrorExample {
NSDictionary *userInfo = @{
@"requestParams": @{@"userId": @"12345"},
@"responseData": @"服务器错误"
};
[[BuglyManager sharedManager] reportNetworkError:@"user123"
api:@"user/profile"
code:500
userInfo:userInfo];
}
// 示例4上报内购错误
- (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: 在这里实现卡顿通知逻辑
// 1. 记录到本地日志
// 2. 发送本地通知
// 3. 上报到性能监控系统
// 4. 触发用户反馈机制
}
- (void)buglyManager:(BuglyManager *)manager didDetectBlock:(NSTimeInterval)duration {
NSLog(@"[Example] 检测到主线程阻塞,持续时间: %.2f 秒", duration);
// TODO: 在这里实现阻塞通知逻辑
}
@end