|
28 | 28 | #import "PasswordViewController.h" |
29 | 29 | #import "IntroductionViewController.h" |
30 | 30 | #import "TweetSendViewController.h" |
| 31 | +#import "ProjectToChooseListViewController.h" |
| 32 | +#import "OTPListViewController.h" |
31 | 33 |
|
32 | 34 | #import "FunctionIntroManager.h" |
33 | 35 | #import <UMengSocial/UMSocial.h> |
34 | 36 | #import <UMengSocial/UMSocialWechatHandler.h> |
35 | 37 | #import <UMengSocial/UMSocialQQHandler.h> |
36 | 38 | #import <evernote-cloud-sdk-ios/ENSDK/ENSDK.h> |
37 | 39 | #import "UMSocialSinaSSOHandler.h" |
| 40 | +#import "Coding_NetAPIManager.h" |
| 41 | +#import <EANetworkDiagno/EANetworkDiagno.h> |
38 | 42 |
|
39 | 43 | #import "Tweet.h" |
40 | 44 | #import "sys/utsname.h" |
@@ -63,15 +67,11 @@ - (void)registerPush{ |
63 | 67 |
|
64 | 68 | #pragma mark UserAgent |
65 | 69 | - (void)registerUserAgent{ |
66 | | - struct utsname systemInfo; |
67 | | - uname(&systemInfo); |
68 | | - NSString *deviceString = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding]; |
69 | | - NSString *userAgent = [NSString stringWithFormat:@"%@/%@ (%@; iOS %@; Scale/%0.2f)", [[[NSBundle mainBundle] infoDictionary] objectForKey:(__bridge NSString *)kCFBundleExecutableKey] ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(__bridge NSString *)kCFBundleIdentifierKey], (__bridge id)CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), kCFBundleVersionKey) ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(__bridge NSString *)kCFBundleVersionKey], deviceString, [[UIDevice currentDevice] systemVersion], ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] ? [[UIScreen mainScreen] scale] : 1.0f)]; |
| 70 | + NSString *userAgent = [NSString userAgentStr]; |
70 | 71 | NSDictionary *dictionary = @{@"UserAgent" : userAgent};//User-Agent |
71 | 72 | [[NSUserDefaults standardUserDefaults] registerDefaults:dictionary]; |
72 | 73 | } |
73 | 74 |
|
74 | | - |
75 | 75 | #pragma lifeCycle |
76 | 76 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions |
77 | 77 | { |
@@ -113,7 +113,6 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( |
113 | 113 | // [[RRFPSBar sharedInstance] setShowsAverage:YES]; |
114 | 114 | // [[RRFPSBar sharedInstance] setHidden:NO]; |
115 | 115 | #endif |
116 | | - |
117 | 116 | return YES; |
118 | 117 | } |
119 | 118 |
|
@@ -205,6 +204,10 @@ - (void)applicationDidBecomeActive:(UIApplication *)application |
205 | 204 | #pragma clang diagnostic pop |
206 | 205 | } |
207 | 206 | } |
| 207 | + EADeviceToServerLog *eaM = [EADeviceToServerLog shareManager]; |
| 208 | + eaM.globalKey = [Login curLoginUser].global_key; |
| 209 | + eaM.userAgentStr = [NSString userAgentStr]; |
| 210 | + [eaM tryToStart]; |
208 | 211 | } |
209 | 212 |
|
210 | 213 | - (void)applicationWillTerminate:(UIApplication *)application |
@@ -423,4 +426,34 @@ - (NSURL *)applicationDocumentsDirectory |
423 | 426 | return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]; |
424 | 427 | } |
425 | 428 |
|
| 429 | +#pragma mark 3D Touch |
| 430 | +- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void(^)(BOOL succeeded))completionHandler{ |
| 431 | + if ([shortcutItem.type isEqualToString:@"shortcut_2FA"]){ |
| 432 | + OTPListViewController *vc = [OTPListViewController new]; |
| 433 | + [BaseViewController presentVC:vc]; |
| 434 | + }else if (![Login isLogin]) { |
| 435 | + UIViewController *presentingVC = [BaseViewController presentingVC]; |
| 436 | + if (![presentingVC isKindOfClass:[LoginViewController class]]) { |
| 437 | + LoginViewController *vc = [[LoginViewController alloc] init]; |
| 438 | + vc.showDismissButton = YES; |
| 439 | + UINavigationController *nav = [[BaseNavigationController alloc] initWithRootViewController:vc]; |
| 440 | + [presentingVC presentViewController:nav animated:YES completion:nil]; |
| 441 | + } |
| 442 | + }else if ([shortcutItem.type isEqualToString:@"shortcut_task"]) { |
| 443 | + ProjectToChooseListViewController *chooseVC = [[ProjectToChooseListViewController alloc] init]; |
| 444 | + [BaseViewController goToVC:chooseVC]; |
| 445 | + }else if ([shortcutItem.type isEqualToString:@"shortcut_tweet"]){ |
| 446 | + TweetSendViewController *vc = [[TweetSendViewController alloc] init]; |
| 447 | + vc.sendNextTweet = ^(Tweet *nextTweet){ |
| 448 | + [nextTweet saveSendData];//发送前保存草稿 |
| 449 | + [[Coding_NetAPIManager sharedManager] request_Tweet_DoTweet_WithObj:nextTweet andBlock:^(id data, NSError *error) { |
| 450 | + if (data) { |
| 451 | + [Tweet deleteSendData];//发送成功后删除草稿 |
| 452 | + } |
| 453 | + }]; |
| 454 | + }; |
| 455 | + [BaseViewController presentVC:vc]; |
| 456 | + } |
| 457 | + completionHandler(YES); |
| 458 | +} |
426 | 459 | @end |
0 commit comments