Commit 1d6ef251ddb817f3347d47fda18d649ee50b846d

Authored by “张旭”
1 parent a05ff01c

接入火山APM监控SDK , 登录按钮关闭刷新状态

@@ -6,6 +6,8 @@ source 'https://cdn.cocoapods.org' @@ -6,6 +6,8 @@ source 'https://cdn.cocoapods.org'
6 6
7 source 'http://bj.gitlab.cnlive.com/ios-team/CNLiveRepos.git' 7 source 'http://bj.gitlab.cnlive.com/ios-team/CNLiveRepos.git'
8 source 'http://bj.gitlab.cnlive.com/DSIOSTeam/DSSpecRepos.git' 8 source 'http://bj.gitlab.cnlive.com/DSIOSTeam/DSSpecRepos.git'
  9 +source 'https://github.com/volcengine/volcengine-specs.git'
  10 +
9 use_frameworks! 11 use_frameworks!
10 12
11 target 'metaCode' do 13 target 'metaCode' do
@@ -74,6 +76,31 @@ target 'metaCode' do @@ -74,6 +76,31 @@ target 'metaCode' do
74 #数据库 76 #数据库
75 pod 'FMDB' 77 pod 'FMDB'
76 78
  79 + #火山APM监控
  80 + pod 'RangersAPM', '3.9.2', :subspecs => [
  81 + 'Crash',
  82 + 'WatchDog',
  83 + 'OOM',
  84 + 'LAG',
  85 + 'UserException',
  86 + 'Monitors',
  87 + 'UITrackers',
  88 + 'Hybrid',
  89 + 'MemoryGraph',
  90 + 'NetworkPro',
  91 + 'EventMonitor',
  92 + 'SessionTracker',
  93 + 'APMLog',
  94 + 'CrashProtector',
  95 + 'CPUException',
  96 + 'MetricKit',
  97 + 'Disk',
  98 + 'GWPASan',
  99 + 'Coredump',
  100 + 'CloudCommand',
  101 + 'CN' #必须引入
  102 + ]
  103 +
77 #依赖三方私有库,如果里面有.a的时候加上这个 104 #依赖三方私有库,如果里面有.a的时候加上这个
78 pre_install do |installer| Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {} 105 pre_install do |installer| Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
79 end 106 end
metaCode.xcodeproj/project.pbxproj
@@ -1506,6 +1506,7 @@ @@ -1506,6 +1506,7 @@
1506 818163B62A25CFCC00579C86 /* Resources */, 1506 818163B62A25CFCC00579C86 /* Resources */,
1507 E0FAE2296315BED785FA507E /* [CP] Embed Pods Frameworks */, 1507 E0FAE2296315BED785FA507E /* [CP] Embed Pods Frameworks */,
1508 43270B0E3FD1AFD4E05616D0 /* [CP] Copy Pods Resources */, 1508 43270B0E3FD1AFD4E05616D0 /* [CP] Copy Pods Resources */,
  1509 + 19AB90652BB669AF00B6A79B /* ShellScript */,
1509 ); 1510 );
1510 buildRules = ( 1511 buildRules = (
1511 ); 1512 );
@@ -1628,6 +1629,23 @@ @@ -1628,6 +1629,23 @@
1628 /* End PBXResourcesBuildPhase section */ 1629 /* End PBXResourcesBuildPhase section */
1629 1630
1630 /* Begin PBXShellScriptBuildPhase section */ 1631 /* Begin PBXShellScriptBuildPhase section */
  1632 + 19AB90652BB669AF00B6A79B /* ShellScript */ = {
  1633 + isa = PBXShellScriptBuildPhase;
  1634 + buildActionMask = 2147483647;
  1635 + files = (
  1636 + );
  1637 + inputFileListPaths = (
  1638 + );
  1639 + inputPaths = (
  1640 + );
  1641 + outputFileListPaths = (
  1642 + );
  1643 + outputPaths = (
  1644 + );
  1645 + runOnlyForDeploymentPostprocessing = 0;
  1646 + shellPath = /bin/sh;
  1647 + shellScript = "/bin/sh ${PODS_ROOT}/RangersAPM/RangersAPM/Core/APMPlus_DSYMUploader.sh \"591048\"\n";
  1648 + };
1631 43270B0E3FD1AFD4E05616D0 /* [CP] Copy Pods Resources */ = { 1649 43270B0E3FD1AFD4E05616D0 /* [CP] Copy Pods Resources */ = {
1632 isa = PBXShellScriptBuildPhase; 1650 isa = PBXShellScriptBuildPhase;
1633 buildActionMask = 2147483647; 1651 buildActionMask = 2147483647;
metaCode/Classes/Main/LoginPage/Controller/CNLiveLoginViewController.swift
@@ -286,11 +286,15 @@ extension CNLiveLoginViewController { @@ -286,11 +286,15 @@ extension CNLiveLoginViewController {
286 } 286 }
287 view.endEditing(true) 287 view.endEditing(true)
288 loginButton.startAnimating() 288 loginButton.startAnimating()
289 - CNLiveLoginViewModel.requestLoginAction(userName: phoneText.text ?? "", countryCode: country, verCode: veriText.text ?? "") { [self] in 289 +
  290 + CNLiveLoginViewModel.requestLoginAction(userName: phoneText.text ?? "", countryCode: country, verCode: veriText.text ?? "") {[self] in
290 loginButton.stopAnimating() 291 loginButton.stopAnimating()
291 let window = UIApplication.shared.delegate?.window 292 let window = UIApplication.shared.delegate?.window
292 window??.rootViewController = CNLiveBaseTabBarViewController.init() 293 window??.rootViewController = CNLiveBaseTabBarViewController.init()
  294 + } endrefreshBlock: {[self] in
  295 + loginButton.stopAnimating()
293 } 296 }
  297 +
294 } 298 }
295 299
296 @objc func pushAgreeActionMothod() { 300 @objc func pushAgreeActionMothod() {
metaCode/Classes/Main/LoginPage/ViewModel/CNLiveLoginViewModel.swift
@@ -8,11 +8,15 @@ @@ -8,11 +8,15 @@
8 import Foundation 8 import Foundation
9 import CNLiveRequestBastKit 9 import CNLiveRequestBastKit
10 import HandyJSON 10 import HandyJSON
  11 +import RangersAPM
11 12
12 //验证码发送成功回调 13 //验证码发送成功回调
13 typealias resultCodeBlock = () -> Void 14 typealias resultCodeBlock = () -> Void
14 //登陆成功回调 15 //登陆成功回调
15 typealias resultLoginBlock = () -> Void 16 typealias resultLoginBlock = () -> Void
  17 +//结束登录按钮刷新回调
  18 +typealias endRefreshBlock = () -> Void
  19 +
16 20
17 class CNLiveLoginViewModel : NSObject { 21 class CNLiveLoginViewModel : NSObject {
18 22
@@ -67,29 +71,36 @@ class CNLiveLoginViewModel : NSObject { @@ -67,29 +71,36 @@ class CNLiveLoginViewModel : NSObject {
67 /// - countryCode: 国家区号 71 /// - countryCode: 国家区号
68 /// - verCode: 验证码 72 /// - verCode: 验证码
69 /// - resultBlock: 结果回调 73 /// - resultBlock: 结果回调
70 - static func requestLoginAction(userName: String, countryCode: String, verCode: String, resultBlock: @escaping resultLoginBlock) { 74 + static func requestLoginAction(userName: String, countryCode: String, verCode: String, resultBlock: @escaping resultLoginBlock ,endrefreshBlock: @escaping endRefreshBlock) {
  75 +
71 if !userName.isNotBlank() { 76 if !userName.isNotBlank() {
72 showMessage(message: "请输入手机号") 77 showMessage(message: "请输入手机号")
  78 + endrefreshBlock()
73 return 79 return
74 } 80 }
75 if userName.lengthOfBytes(using: .utf8) >= 20 { 81 if userName.lengthOfBytes(using: .utf8) >= 20 {
76 showMessage(message: "手机号格式不正确") 82 showMessage(message: "手机号格式不正确")
  83 + endrefreshBlock()
77 return 84 return
78 } 85 }
79 if !userName.isPurnInt() { 86 if !userName.isPurnInt() {
80 showMessage(message: "手机号格式不正确") 87 showMessage(message: "手机号格式不正确")
  88 + endrefreshBlock()
81 return 89 return
82 } 90 }
83 if !verCode.isNotBlank() { 91 if !verCode.isNotBlank() {
84 showMessage(message: "请输入验证码") 92 showMessage(message: "请输入验证码")
  93 + endrefreshBlock()
85 return 94 return
86 } 95 }
87 if verCode.lengthOfBytes(using: .utf8) >= 20 { 96 if verCode.lengthOfBytes(using: .utf8) >= 20 {
88 showMessage(message: "验证码格式不正确") 97 showMessage(message: "验证码格式不正确")
  98 + endrefreshBlock()
89 return 99 return
90 } 100 }
91 if !verCode.isPurnInt() { 101 if !verCode.isPurnInt() {
92 showMessage(message: "验证码格式不正确") 102 showMessage(message: "验证码格式不正确")
  103 + endrefreshBlock()
93 return 104 return
94 } 105 }
95 106
@@ -113,13 +124,16 @@ class CNLiveLoginViewModel : NSObject { @@ -113,13 +124,16 @@ class CNLiveLoginViewModel : NSObject {
113 let userInfoModel = dictionaryToModel(resp as! [String : Any], UserInfoModel.self,"data") 124 let userInfoModel = dictionaryToModel(resp as! [String : Any], UserInfoModel.self,"data")
114 UserInfoManager.cacheUserInfo(userInfo: userInfoModel as! UserInfoModel) 125 UserInfoManager.cacheUserInfo(userInfo: userInfoModel as! UserInfoModel)
115 UserDefaults.standard.set(true,forKey: "is_login") 126 UserDefaults.standard.set(true,forKey: "is_login")
  127 + RangersAPM.setUserID(UserInfoManager.shared.userInfo.uid)
116 resultBlock() 128 resultBlock()
117 } 129 }
118 } else { 130 } else {
119 showMessage(message: resp["errorMessage"] as! String) 131 showMessage(message: resp["errorMessage"] as! String)
  132 + endrefreshBlock()
120 } 133 }
121 } else { 134 } else {
122 showMessage(message: "登陆失败") 135 showMessage(message: "登陆失败")
  136 + endrefreshBlock()
123 } 137 }
124 } 138 }
125 } 139 }
metaCode/Classes/Other/AppDelegate.swift
@@ -9,6 +9,7 @@ import UIKit @@ -9,6 +9,7 @@ import UIKit
9 import CNLiveRequestBastKit 9 import CNLiveRequestBastKit
10 import IQKeyboardManagerSwift 10 import IQKeyboardManagerSwift
11 import CNLiveShareToolKit 11 import CNLiveShareToolKit
  12 +import RangersAPM
12 13
13 @main 14 @main
14 class AppDelegate: UIResponder, UIApplicationDelegate { 15 class AppDelegate: UIResponder, UIApplicationDelegate {
@@ -46,6 +47,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate { @@ -46,6 +47,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
46 window?.rootViewController = is_login ? CNLiveBaseTabBarViewController.init() : CNLiveLoginViewController.init() 47 window?.rootViewController = is_login ? CNLiveBaseTabBarViewController.init() : CNLiveLoginViewController.init()
47 window?.makeKeyAndVisible() 48 window?.makeKeyAndVisible()
48 49
  50 + ///设置APM监控SDK
  51 + let apmConfig = RangersAPMConfig.init(appID: "591048", appToken: "8dcc7f8b0a3a4aee8ef698311ef89a62")
  52 + apmConfig.channel = "App Store"
  53 + apmConfig.deviceIDSource = .fromAPMService
  54 + apmConfig.defaultMonitors = .apmCrashMonitorSwitch
  55 + RangersAPM.start(with: apmConfig)
  56 + RangersAPM.setUserID(is_login ? UserInfoManager.shared.userInfo.uid : "userID")
  57 +
49 AppDelegate_configRequestManager() 58 AppDelegate_configRequestManager()
50 AppDelegate_configIQKeyboardManager() 59 AppDelegate_configIQKeyboardManager()
51 60