Skip to content

Commit 17f9f57

Browse files
author
karisli
committed
# 5.5.7
-修复后台上传cancel失败的bug\ - 增加捞取log的功能
1 parent 3b47cb6 commit 17f9f57

File tree

81 files changed

+477
-239
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+477
-239
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 5.5.7
2+
-修复后台上传cancel失败的bug\ - 增加捞取log的功能
3+
14
# 5.5.6
25
从服务器获取签名的工具类
36

QCloudCOSXML.podspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "QCloudCOSXML"
3-
s.version = "5.5.6"
3+
s.version = "5.5.7"
44
s.summary = "QCloudCOSXML 腾讯云iOS-SDK组件"
55

66
s.homepage = "https://cloud.tencent.com/"
@@ -9,12 +9,12 @@ s.version = "5.5.6"
99
s.source = { :git => "https://github.com/tencentyun/qcloud-sdk-ios.git", :tag => s.version.to_s }
1010
s.ios.deployment_target = '8.0'
1111
s.source_files = 'QCloudCOSXML/Classes/**/*'
12-
s.dependency "QCloudCore",'5.5.6'
12+
s.dependency "QCloudCore",'5.5.7'
1313
s.static_framework = true
1414

1515
s.subspec 'Transfer' do |sbt|
1616
sbt.source_files = 'QCloudCOSXML/Classes/Transfer/**/*','QCloudCOSXML/Classes/Base/*'
17-
sbt.dependency "QCloudCore",'5.5.6'
17+
sbt.dependency "QCloudCore",'5.5.7'
1818
# sbt.static_framework=true
1919
end
2020
end

QCloudCOSXML/Classes/Base/QCloudAbstractRequest+Quality.m

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#import "QCloudAbstractRequest+Quality.h"
99
#import <objc/runtime.h>
1010
#import "QualityDataUploader.h"
11+
1112
@implementation QCloudAbstractRequest (Quality)
1213
+ (void) load{
1314
static dispatch_once_t onceToken;
@@ -18,14 +19,6 @@ + (void) load{
1819

1920
+ (void)exchangeImplementation {
2021
Class class = [self class];
21-
SEL originalSelector = @selector(__notifySuccess:);
22-
SEL swizzledSelector = @selector(__quality__notifySuccess:);
23-
Method originNotifySuccessMethod = class_getInstanceMethod(class, @selector(__notifySuccess:));
24-
Method swizzedNotifySuccessMethod = class_getInstanceMethod(class, @selector(__quality__notifySuccess:));
25-
26-
method_exchangeImplementations(originNotifySuccessMethod, swizzedNotifySuccessMethod);
27-
28-
2922
Method originNotifyErrorMethod = class_getInstanceMethod(class, @selector(__notifyError:));
3023
Method swizzedNotifyErrorMethod = class_getInstanceMethod(class, @selector(__quality__notifyError:));
3124
method_exchangeImplementations(originNotifyErrorMethod, swizzedNotifyErrorMethod);
@@ -35,14 +28,9 @@ + (void)exchangeImplementation {
3528
}
3629

3730

38-
- (void)__quality__notifySuccess:(id)object {
39-
[self __quality__notifySuccess:(id)object];
40-
[QualityDataUploader trackRequestSuccessWithType:self.class];
41-
}
42-
4331
- (void)__quality__notifyError:(NSError *)error {
4432
[self __quality__notifyError:error];
45-
[QualityDataUploader trackRequestFailWithError:error];
33+
[QualityDataUploader trackRequestFailWithType:self.class Error:error];
4634
}
4735

4836

QCloudCOSXML/Classes/Base/QCloudCOSXMLService+Quality.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#import <QCloudCore/QualityAssuranceDefine.h>
1414
#import <QCloudCore/QCloudCore.h>
1515
#import <QCloudCore/QCloudLogger.h>
16+
#import "QCloudCOSXMLVersion.h"
1617
@implementation QCloudCOSXMLService (Quality)
1718

1819
+ (void)load {
@@ -42,6 +43,7 @@ + (void) initMTA {
4243
QCloudLogDebug(@"Quality assurence service start");
4344
TACMTAConfig* config = [TACMTAConfig getInstance];
4445
config.reportStrategy = kQAUploadStrategy;
46+
config.customerAppVersion = QCloudCOSXMLModuleVersion;
4547
[TACMTA startWithAppkey:kQAccount];
4648
}
4749
@end

QCloudCOSXML/Classes/Base/QCloudCOSXMLService.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
#import <QCloudCore/QCloudThreadSafeMutableDictionary.h>
3131
#import <QCloudCore/QCLoudError.h>
3232
#import "UIDevice+QCloudFCUUID.h"
33+
#if TARGET_OS_IPHONE
34+
#import "QCloudLogManager.h"
35+
#endif
3336
QCloudThreadSafeMutableDictionary* QCloudCOSXMLServiceCache()
3437
{
3538
static QCloudThreadSafeMutableDictionary* CloudcosxmlService = nil;
@@ -77,6 +80,9 @@ + (QCloudCOSXMLService*) registerDefaultCOSXMLWithConfiguration:(QCloudServiceCo
7780
{
7881
@synchronized (self) {
7982
COSXMLService = [[QCloudCOSXMLService alloc] initWithConfiguration:configuration];
83+
#if TARGET_OS_IPHONE
84+
[QCloudLogManager sharedInstance];
85+
#endif
8086
}
8187
return COSXMLService;
8288
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// QCloudLogDetailViewController.h
3+
// QCloudCOSXML
4+
//
5+
// Created by erichmzhang(张恒铭) on 2018/10/8.
6+
//
7+
#if TARGET_OS_IPHONE
8+
#import <UIKit/UIKit.h>
9+
10+
NS_ASSUME_NONNULL_BEGIN
11+
12+
@interface QCloudLogDetailViewController : UIViewController
13+
- (instancetype) initWithLogPath:(NSString *)logPath LogContent:(NSString *)logContent;
14+
@end
15+
16+
NS_ASSUME_NONNULL_END
17+
#endif
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
//
2+
// QCloudLogDetailViewController.m
3+
// QCloudCOSXML
4+
//
5+
// Created by erichmzhang(张恒铭) on 2018/10/8.
6+
//
7+
#if TARGET_OS_IPHONE
8+
#import "QCloudLogDetailViewController.h"
9+
@interface QCloudLogDetailViewController ()
10+
@property (nonatomic, strong) NSString *logContent;
11+
@property (nonatomic, strong) NSString *logPath;
12+
@property (nonatomic, strong) UITextView *textView;
13+
@end
14+
15+
@implementation QCloudLogDetailViewController
16+
17+
- (void)viewDidLoad {
18+
[super viewDidLoad];
19+
UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"发送" style:UIBarButtonItemStylePlain target:self action:@selector(onHandleShareLog)];
20+
self.navigationItem.rightBarButtonItem = barButtonItem;
21+
self.textView = [[UITextView alloc] initWithFrame:self.view.frame];
22+
[self.view addSubview:self.textView];
23+
}
24+
25+
- (instancetype) initWithLogPath:(NSString *)logPath LogContent:(NSString *)logContent {
26+
self = [super init];
27+
self.logContent = logContent;
28+
self.logPath = logPath;
29+
return self;
30+
}
31+
32+
- (void)onHandleShareLog {
33+
NSURL *url = [NSURL fileURLWithPath:self.logPath];
34+
NSArray *activityItems = @[url];
35+
UIActivityViewController *activityVC = [[UIActivityViewController alloc]initWithActivityItems:activityItems applicationActivities:nil];
36+
[self presentViewController:activityVC animated:YES completion:nil];
37+
38+
39+
}
40+
41+
- (void) viewDidAppear:(BOOL)animated {
42+
[super viewDidAppear:animated];
43+
self.textView.text = self.logContent;
44+
}
45+
46+
47+
48+
@end
49+
#endif
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// QCloudLogManager.h
3+
// QCloudCOSXML
4+
//
5+
// Created by erichmzhang(张恒铭) on 2018/10/8.
6+
//
7+
#if TARGET_OS_IPHONE
8+
#import <Foundation/Foundation.h>
9+
10+
NS_ASSUME_NONNULL_BEGIN
11+
12+
@interface QCloudLogManager : NSObject
13+
+ (instancetype) sharedInstance;
14+
- (NSArray *)currentLogs;
15+
- (NSString *) readLog:(NSString *)path;
16+
@end
17+
18+
NS_ASSUME_NONNULL_END
19+
#endif
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
//
2+
// QCloudLogManager.m
3+
// QCloudCOSXML
4+
//
5+
// Created by erichmzhang(张恒铭) on 2018/10/8.
6+
//
7+
#if TARGET_OS_IPHONE
8+
#import "QCloudLogManager.h"
9+
#import <QCloudCore/QCloudCore.h>
10+
#import "QCloudLogTableViewController.h"
11+
@implementation QCloudLogManager
12+
+ (instancetype) sharedInstance {
13+
static QCloudLogManager *instance;
14+
static dispatch_once_t onceToken;
15+
dispatch_once(&onceToken, ^{
16+
instance = [[QCloudLogManager alloc] init];
17+
});
18+
return instance;
19+
}
20+
21+
- (instancetype) init {
22+
self = [super init];
23+
24+
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onHandleAppBecomeActive:) name:UIApplicationDidBecomeActiveNotification object:nil];
25+
return self;
26+
}
27+
28+
- (void)dealloc {
29+
[[NSNotificationCenter defaultCenter] removeObserver:self];
30+
}
31+
- (void) onHandleAppBecomeActive :(NSNotification *)notification {
32+
if ([self shouldShowLogs]) {
33+
[UIPasteboard generalPasteboard].string = @"";
34+
[self showLogs];
35+
}
36+
}
37+
38+
39+
- (BOOL) shouldShowLogs {
40+
NSString *currentPasteBoardContent = [UIPasteboard generalPasteboard].string;
41+
if ([currentPasteBoardContent isEqualToString:@"##qcloud-cos-log-ispct##"]) {
42+
return YES;
43+
}
44+
return NO;
45+
}
46+
47+
48+
- (NSArray *)currentLogs {
49+
NSString *directoryPath = [QCloudLogger sharedLogger].logDirctoryPath;
50+
NSArray *content = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:directoryPath error:nil];
51+
return content;
52+
}
53+
54+
- (NSString *)readLog:(NSString *)path {
55+
NSData *content = [[NSFileManager defaultManager] contentsAtPath:path];
56+
return [[NSString alloc] initWithData:content encoding:NSUTF8StringEncoding];
57+
}
58+
59+
- (void) showLogs {
60+
UIAlertController* alertController = [UIAlertController alertControllerWithTitle:@"提示" message:@"确定显示log" preferredStyle:UIAlertControllerStyleAlert];
61+
UIAlertAction* actionEnsure = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction* action) {
62+
[self onHandleBeginShowlogs];
63+
}];
64+
UIAlertAction* actionCancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:nil];
65+
[alertController addAction:actionEnsure];
66+
[alertController addAction:actionCancel];
67+
UIViewController *currentViewController = [self currentViewController];
68+
[currentViewController presentViewController:alertController animated:YES completion:nil];
69+
70+
}
71+
-(void)onHandleBeginShowlogs{
72+
NSArray *currentLogPath = [self currentLogs];
73+
UIViewController *currentViewController = [self currentViewController];
74+
QCloudLogTableViewController *tableViewController = [[QCloudLogTableViewController alloc] initWithLog:currentLogPath];
75+
if ([currentViewController isKindOfClass:UINavigationController.class]) {
76+
[((UINavigationController *)currentViewController) pushViewController:tableViewController animated:YES];
77+
} else {
78+
[currentViewController presentViewController:tableViewController animated:YES completion:nil];
79+
}
80+
}
81+
- (UIViewController *)currentViewController {
82+
UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
83+
UIViewController *vc = keyWindow.rootViewController;
84+
while (vc.presentedViewController) {
85+
vc = vc.presentedViewController;
86+
87+
if ([vc isKindOfClass:[UINavigationController class]]) {
88+
vc = [(UINavigationController *)vc visibleViewController];
89+
} else if ([vc isKindOfClass:[UITabBarController class]]) {
90+
vc = [(UITabBarController *)vc selectedViewController];
91+
}
92+
}
93+
return vc;
94+
}
95+
96+
@end
97+
#endif
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// QCloudLogTableViewController.h
3+
// QCloudCOSXML
4+
//
5+
// Created by erichmzhang(张恒铭) on 2018/10/8.
6+
//
7+
#if TARGET_OS_IPHONE
8+
#import <UIKit/UIKit.h>
9+
10+
NS_ASSUME_NONNULL_BEGIN
11+
12+
@interface QCloudLogTableViewController : UIViewController
13+
- (instancetype) initWithLog:(NSArray *)logContent;
14+
@end
15+
16+
NS_ASSUME_NONNULL_END
17+
#endif

0 commit comments

Comments
 (0)