Commit a73b676d44fe36ee0c2e925bdd324a59d2ab1457
Merge branch 'master' of bj.gitlab.cnlive.com:ios-team/ScioLive
Showing
6 changed files
with
113 additions
and
4 deletions
CNLiveScioLive.xcodeproj/project.pbxproj
| ... | ... | @@ -7,6 +7,7 @@ |
| 7 | 7 | objects = { |
| 8 | 8 | |
| 9 | 9 | /* Begin PBXBuildFile section */ |
| 10 | + 0802446D2624267800BD68E8 /* SdkMgr.m in Sources */ = {isa = PBXBuildFile; fileRef = 0802446C2624267800BD68E8 /* SdkMgr.m */; }; | |
| 10 | 11 | 080AB4C6217AD4F4008BA78F /* TemplateShareManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 080AB4C5217AD4F4008BA78F /* TemplateShareManager.m */; }; |
| 11 | 12 | 080AB4C7217AD4F4008BA78F /* TemplateShareManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 080AB4C5217AD4F4008BA78F /* TemplateShareManager.m */; }; |
| 12 | 13 | 080AB4C8217AD4F4008BA78F /* TemplateShareManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 080AB4C5217AD4F4008BA78F /* TemplateShareManager.m */; }; |
| ... | ... | @@ -754,6 +755,8 @@ |
| 754 | 755 | /* End PBXCopyFilesBuildPhase section */ |
| 755 | 756 | |
| 756 | 757 | /* Begin PBXFileReference section */ |
| 758 | + 0802446B2624267800BD68E8 /* SdkMgr.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SdkMgr.h; sourceTree = "<group>"; }; | |
| 759 | + 0802446C2624267800BD68E8 /* SdkMgr.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SdkMgr.m; sourceTree = "<group>"; }; | |
| 757 | 760 | 080AB4C4217AD4F4008BA78F /* TemplateShareManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TemplateShareManager.h; sourceTree = "<group>"; }; |
| 758 | 761 | 080AB4C5217AD4F4008BA78F /* TemplateShareManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TemplateShareManager.m; sourceTree = "<group>"; }; |
| 759 | 762 | 083847DF215C5DDD00186618 /* VPImageCropperViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VPImageCropperViewController.h; sourceTree = "<group>"; }; |
| ... | ... | @@ -1279,6 +1282,15 @@ |
| 1279 | 1282 | /* End PBXFrameworksBuildPhase section */ |
| 1280 | 1283 | |
| 1281 | 1284 | /* Begin PBXGroup section */ |
| 1285 | + 0802446A262425DB00BD68E8 /* DeviceUUID */ = { | |
| 1286 | + isa = PBXGroup; | |
| 1287 | + children = ( | |
| 1288 | + 0802446B2624267800BD68E8 /* SdkMgr.h */, | |
| 1289 | + 0802446C2624267800BD68E8 /* SdkMgr.m */, | |
| 1290 | + ); | |
| 1291 | + path = DeviceUUID; | |
| 1292 | + sourceTree = "<group>"; | |
| 1293 | + }; | |
| 1282 | 1294 | 080AB4BE217AD457008BA78F /* ShareTool */ = { |
| 1283 | 1295 | isa = PBXGroup; |
| 1284 | 1296 | children = ( |
| ... | ... | @@ -2014,6 +2026,7 @@ |
| 2014 | 2026 | 08C08FCF214FA01B00E23D16 /* Tools */ = { |
| 2015 | 2027 | isa = PBXGroup; |
| 2016 | 2028 | children = ( |
| 2029 | + 0802446A262425DB00BD68E8 /* DeviceUUID */, | |
| 2017 | 2030 | 08C721A924CAC9B700970100 /* SDCycleScrollView */, |
| 2018 | 2031 | 080AB4BE217AD457008BA78F /* ShareTool */, |
| 2019 | 2032 | 08585DD7215B70DA00FC2CA2 /* JSONKit */, |
| ... | ... | @@ -3067,6 +3080,7 @@ |
| 3067 | 3080 | 08940D752154EB2C00F85DB6 /* UILabel+TextAlign.m in Sources */, |
| 3068 | 3081 | 08585D83215B4C7200FC2CA2 /* PGDatePicker+DateAndTime.m in Sources */, |
| 3069 | 3082 | 08585CF9215B3AA900FC2CA2 /* ArticleTableViewCell.m in Sources */, |
| 3083 | + 0802446D2624267800BD68E8 /* SdkMgr.m in Sources */, | |
| 3070 | 3084 | C3A6D061215278CE00FB7759 /* CNLiveForgotPasswordViewController.m in Sources */, |
| 3071 | 3085 | 084ACE272154C6980089E035 /* CNLiveNewsNoPicTableViewCell.m in Sources */, |
| 3072 | 3086 | 08585CF0215B3AA900FC2CA2 /* SearchHistoryTableViewCell.m in Sources */, | ... | ... |
CNLiveScioLive/Pages/Login/Controller/CNLiveLoginViewController.m
| ... | ... | @@ -15,6 +15,8 @@ |
| 15 | 15 | #import "ZXWUserModel.h" |
| 16 | 16 | #import <AuthenticationServices/AuthenticationServices.h> |
| 17 | 17 | #import <CNLiveRequestBastKit/CNLiveNetworking.h> |
| 18 | +#import "NSString+Validation.h" | |
| 19 | +#import "SdkMgr.h" | |
| 18 | 20 | |
| 19 | 21 | @interface CNLiveLoginViewController ()<ASAuthorizationControllerDelegate, ASAuthorizationControllerPresentationContextProviding> |
| 20 | 22 | @property (nonatomic, strong) CNLiveLoginInputView *account; |
| ... | ... | @@ -471,7 +473,7 @@ |
| 471 | 473 | [mDict setValue:@"i" forKey:@"plat"]; |
| 472 | 474 | [mDict setValue:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"] forKey:@"ver"]; |
| 473 | 475 | [mDict setObject:CNLiveAppId forKey:@"appId"]; |
| 474 | - [mDict setValue:[[[[UIDevice currentDevice] identifierForVendor] UUIDString] stringByReplacingOccurrencesOfString:@"-" withString:@""] forKey:@"uuid"]; | |
| 476 | + [mDict setValue:[SdkMgr getDeviceUUID] forKey:@"uuid"]; | |
| 475 | 477 | |
| 476 | 478 | [CNLiveNetworking setupDefaultParam:mDict]; |
| 477 | 479 | [CNLiveNetworking setupShowResult:NO]; |
| ... | ... | @@ -480,7 +482,6 @@ |
| 480 | 482 | [CNLiveNetworking setResponseSerializerType:CNLiveResponseSerializerJSON]; |
| 481 | 483 | |
| 482 | 484 | } |
| 483 | - | |
| 484 | 485 | - (UIStatusBarStyle)preferredStatusBarStyle { |
| 485 | 486 | return UIStatusBarStyleLightContent; |
| 486 | 487 | } | ... | ... |
CNLiveScioLive/Pages/Tools/DeviceUUID/SdkMgr.h
0 → 100644
| 1 | +// | |
| 2 | +// SdkMgr.h | |
| 3 | +// CNLiveScioLive | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/4/12. | |
| 6 | +// Copyright © 2021 CNLive. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import <Foundation/Foundation.h> | |
| 10 | + | |
| 11 | +NS_ASSUME_NONNULL_BEGIN | |
| 12 | + | |
| 13 | +@interface SdkMgr : NSObject | |
| 14 | ++(NSString *)getDeviceUUID; | |
| 15 | +@end | |
| 16 | + | |
| 17 | +NS_ASSUME_NONNULL_END | ... | ... |
CNLiveScioLive/Pages/Tools/DeviceUUID/SdkMgr.m
0 → 100644
| 1 | +// | |
| 2 | +// SdkMgr.m | |
| 3 | +// CNLiveScioLive | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/4/12. | |
| 6 | +// Copyright © 2021 CNLive. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import "SdkMgr.h" | |
| 10 | + | |
| 11 | +@implementation SdkMgr | |
| 12 | +NSString * const KEY_UDID_INSTEAD = @"com.app.uuid.test"; | |
| 13 | + | |
| 14 | ++(NSString *)getDeviceUUID{ | |
| 15 | + NSString *getUDIDInKeychain = (NSString *)[SdkMgr load:KEY_UDID_INSTEAD]; | |
| 16 | + if (!getUDIDInKeychain ||[getUDIDInKeychain isEqualToString:@""]||[getUDIDInKeychain isKindOfClass:[NSNull class]]) { | |
| 17 | + CFUUIDRef puuid = CFUUIDCreate( nil ); | |
| 18 | + CFStringRef uuidString = CFUUIDCreateString( nil, puuid ); | |
| 19 | + NSString * result = (NSString *)CFBridgingRelease(CFStringCreateCopy( NULL, uuidString)); | |
| 20 | + CFRelease(puuid); | |
| 21 | + CFRelease(uuidString); | |
| 22 | + | |
| 23 | + //去掉横线,保留32位长度 | |
| 24 | + NSString *rst = [result stringByReplacingOccurrencesOfString:@"-" withString:@""]; | |
| 25 | + [SdkMgr save:KEY_UDID_INSTEAD data:rst]; | |
| 26 | + getUDIDInKeychain = (NSString *)[SdkMgr load:KEY_UDID_INSTEAD]; | |
| 27 | + } | |
| 28 | + return getUDIDInKeychain; | |
| 29 | +} | |
| 30 | + | |
| 31 | +#pragma mark - private | |
| 32 | + | |
| 33 | ++ (NSMutableDictionary *)getKeychainQuery:(NSString *)service { | |
| 34 | + return [NSMutableDictionary dictionaryWithObjectsAndKeys: | |
| 35 | + (id)kSecClassGenericPassword,(id)kSecClass, | |
| 36 | + service, (id)kSecAttrService, | |
| 37 | + service, (id)kSecAttrAccount, | |
| 38 | + (id)kSecAttrAccessibleAfterFirstUnlock,(id)kSecAttrAccessible, | |
| 39 | + nil]; | |
| 40 | +} | |
| 41 | + | |
| 42 | ++ (void)save:(NSString *)service data:(id)data { | |
| 43 | + //Get search dictionary | |
| 44 | + NSMutableDictionary *keychainQuery = [self getKeychainQuery:service]; | |
| 45 | + //Delete old item before add new item | |
| 46 | + SecItemDelete((CFDictionaryRef)keychainQuery); | |
| 47 | + //Add new object to search dictionary(Attention:the data format) | |
| 48 | + [keychainQuery setObject:[NSKeyedArchiver archivedDataWithRootObject:data] forKey:(id)kSecValueData]; | |
| 49 | + //Add item to keychain with the search dictionary | |
| 50 | + SecItemAdd((CFDictionaryRef)keychainQuery, NULL); | |
| 51 | +} | |
| 52 | + | |
| 53 | ++ (id)load:(NSString *)service { | |
| 54 | + id ret = nil; | |
| 55 | + NSMutableDictionary *keychainQuery = [self getKeychainQuery:service]; | |
| 56 | + //Configure the search setting | |
| 57 | + //Since in our simple case we are expecting only a single attribute to be returned (the password) we can set the attribute kSecReturnData to kCFBooleanTrue | |
| 58 | + [keychainQuery setObject:(id)kCFBooleanTrue forKey:(id)kSecReturnData]; | |
| 59 | + [keychainQuery setObject:(id)kSecMatchLimitOne forKey:(id)kSecMatchLimit]; | |
| 60 | + CFDataRef keyData = NULL; | |
| 61 | + if (SecItemCopyMatching((CFDictionaryRef)keychainQuery, (CFTypeRef *)&keyData) == noErr) { | |
| 62 | + @try { | |
| 63 | + ret = [NSKeyedUnarchiver unarchiveObjectWithData:(__bridge NSData *)(keyData)]; | |
| 64 | + } @catch (NSException *e) { | |
| 65 | + NSLog(@"Unarchive of %@ failed: %@", service, e); | |
| 66 | + } @finally { | |
| 67 | + } | |
| 68 | + } | |
| 69 | + if (keyData) | |
| 70 | + CFRelease(keyData); | |
| 71 | + return ret; | |
| 72 | +} | |
| 73 | + | |
| 74 | ++ (void)delete:(NSString *)service { | |
| 75 | + NSMutableDictionary *keychainQuery = [self getKeychainQuery:service]; | |
| 76 | + SecItemDelete((CFDictionaryRef)keychainQuery); | |
| 77 | +} | |
| 78 | +@end | ... | ... |
CNLiveScioLive/Pages/Tools/ValidationTool/NSString+Validation.h
Podfile
| ... | ... | @@ -16,7 +16,7 @@ target 'CNLiveScioLive' do |
| 16 | 16 | pod 'SDWebImage/GIF' |
| 17 | 17 | pod 'SDWebImage', '~> 4.0.0' |
| 18 | 18 | pod 'AFNetworking'#, '~> 3.1.0' |
| 19 | - pod 'YYKit', '~> 1.0.9' | |
| 19 | +# pod 'YYKit', '~> 1.0.9' | |
| 20 | 20 | pod 'MJRefresh', '~> 3.1.12' |
| 21 | 21 | pod 'Masonry', '~> 1.0.2' |
| 22 | 22 | pod 'WebViewJavascriptBridge', '~> 6.0.3' | ... | ... |