Commit 1d6ef251ddb817f3347d47fda18d649ee50b846d

Authored by “张旭”
1 parent a05ff01c

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

... ... @@ -6,6 +6,8 @@ source 'https://cdn.cocoapods.org'
6 6  
7 7 source 'http://bj.gitlab.cnlive.com/ios-team/CNLiveRepos.git'
8 8 source 'http://bj.gitlab.cnlive.com/DSIOSTeam/DSSpecRepos.git'
  9 +source 'https://github.com/volcengine/volcengine-specs.git'
  10 +
9 11 use_frameworks!
10 12  
11 13 target 'metaCode' do
... ... @@ -74,6 +76,31 @@ target 'metaCode' do
74 76 #数据库
75 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 104 #依赖三方私有库,如果里面有.a的时候加上这个
78 105 pre_install do |installer| Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
79 106 end
... ...
metaCode.xcodeproj/project.pbxproj
... ... @@ -1506,6 +1506,7 @@
1506 1506 818163B62A25CFCC00579C86 /* Resources */,
1507 1507 E0FAE2296315BED785FA507E /* [CP] Embed Pods Frameworks */,
1508 1508 43270B0E3FD1AFD4E05616D0 /* [CP] Copy Pods Resources */,
  1509 + 19AB90652BB669AF00B6A79B /* ShellScript */,
1509 1510 );
1510 1511 buildRules = (
1511 1512 );
... ... @@ -1628,6 +1629,23 @@
1628 1629 /* End PBXResourcesBuildPhase section */
1629 1630  
1630 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 1649 43270B0E3FD1AFD4E05616D0 /* [CP] Copy Pods Resources */ = {
1632 1650 isa = PBXShellScriptBuildPhase;
1633 1651 buildActionMask = 2147483647;
... ...
metaCode/Classes/Main/LoginPage/Controller/CNLiveLoginViewController.swift
... ... @@ -286,11 +286,15 @@ extension CNLiveLoginViewController {
286 286 }
287 287 view.endEditing(true)
288 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 291 loginButton.stopAnimating()
291 292 let window = UIApplication.shared.delegate?.window
292 293 window??.rootViewController = CNLiveBaseTabBarViewController.init()
  294 + } endrefreshBlock: {[self] in
  295 + loginButton.stopAnimating()
293 296 }
  297 +
294 298 }
295 299  
296 300 @objc func pushAgreeActionMothod() {
... ...
metaCode/Classes/Main/LoginPage/ViewModel/CNLiveLoginViewModel.swift
... ... @@ -8,11 +8,15 @@
8 8 import Foundation
9 9 import CNLiveRequestBastKit
10 10 import HandyJSON
  11 +import RangersAPM
11 12  
12 13 //验证码发送成功回调
13 14 typealias resultCodeBlock = () -> Void
14 15 //登陆成功回调
15 16 typealias resultLoginBlock = () -> Void
  17 +//结束登录按钮刷新回调
  18 +typealias endRefreshBlock = () -> Void
  19 +
16 20  
17 21 class CNLiveLoginViewModel : NSObject {
18 22  
... ... @@ -67,29 +71,36 @@ class CNLiveLoginViewModel : NSObject {
67 71 /// - countryCode: 国家区号
68 72 /// - verCode: 验证码
69 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 76 if !userName.isNotBlank() {
72 77 showMessage(message: "请输入手机号")
  78 + endrefreshBlock()
73 79 return
74 80 }
75 81 if userName.lengthOfBytes(using: .utf8) >= 20 {
76 82 showMessage(message: "手机号格式不正确")
  83 + endrefreshBlock()
77 84 return
78 85 }
79 86 if !userName.isPurnInt() {
80 87 showMessage(message: "手机号格式不正确")
  88 + endrefreshBlock()
81 89 return
82 90 }
83 91 if !verCode.isNotBlank() {
84 92 showMessage(message: "请输入验证码")
  93 + endrefreshBlock()
85 94 return
86 95 }
87 96 if verCode.lengthOfBytes(using: .utf8) >= 20 {
88 97 showMessage(message: "验证码格式不正确")
  98 + endrefreshBlock()
89 99 return
90 100 }
91 101 if !verCode.isPurnInt() {
92 102 showMessage(message: "验证码格式不正确")
  103 + endrefreshBlock()
93 104 return
94 105 }
95 106  
... ... @@ -113,13 +124,16 @@ class CNLiveLoginViewModel : NSObject {
113 124 let userInfoModel = dictionaryToModel(resp as! [String : Any], UserInfoModel.self,"data")
114 125 UserInfoManager.cacheUserInfo(userInfo: userInfoModel as! UserInfoModel)
115 126 UserDefaults.standard.set(true,forKey: "is_login")
  127 + RangersAPM.setUserID(UserInfoManager.shared.userInfo.uid)
116 128 resultBlock()
117 129 }
118 130 } else {
119 131 showMessage(message: resp["errorMessage"] as! String)
  132 + endrefreshBlock()
120 133 }
121 134 } else {
122 135 showMessage(message: "登陆失败")
  136 + endrefreshBlock()
123 137 }
124 138 }
125 139 }
... ...
metaCode/Classes/Other/AppDelegate.swift
... ... @@ -9,6 +9,7 @@ import UIKit
9 9 import CNLiveRequestBastKit
10 10 import IQKeyboardManagerSwift
11 11 import CNLiveShareToolKit
  12 +import RangersAPM
12 13  
13 14 @main
14 15 class AppDelegate: UIResponder, UIApplicationDelegate {
... ... @@ -46,6 +47,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
46 47 window?.rootViewController = is_login ? CNLiveBaseTabBarViewController.init() : CNLiveLoginViewController.init()
47 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 58 AppDelegate_configRequestManager()
50 59 AppDelegate_configIQKeyboardManager()
51 60  
... ...