wenweiwei 3 gadi atpakaļ
vecāks
revīzija
96c9b1c5a6

+ 30 - 0
Introduce/Record/INAppConfigUtil.swift

@@ -33,10 +33,16 @@ class INAppConfigUtil: NSObject {
     class func applicationConfig(launchOptions _: [UIApplication.LaunchOptionsKey: Any]?) {
         // 初始化友盟 61c3e145e0f9bb492ba6e4e4
         registerUM(umAppkey: "61c3e145e0f9bb492ba6e4e4")
+        // 初始化Bugly
+        registerBugly(appID: "80af5e913c", deviceId: getMachineCode())
         // 冷热启动上报
         appLaunchReportUpload()
     }
 
+    /// 初始化友盟
+    /// - Parameters:
+    ///   - umAppkey: <#umAppkey description#>
+    ///   - channel: <#channel description#>
     class func registerUM(umAppkey: String, channel: String = "AppStore") {
         #if DEBUG
             UMConfigure.setLogEnabled(true)
@@ -48,6 +54,30 @@ class INAppConfigUtil: NSObject {
         #endif
     }
 
+    /// 初始化Bugly
+    /// - Parameters:
+    ///   - appID: <#appID description#>
+    ///   - channel: <#channel description#>
+    ///   - deviceId: <#deviceId description#>
+    class func registerBugly(appID: String, channel: String = "AppStore", deviceId: String? = nil) {
+        let versionName = "\(Bundle.main.infoDictionary?["CFBundleShortVersionString"] ?? "1.0.0")"
+        // 注册bugly
+        let buglyConfig = BuglyConfig()
+        buglyConfig.reportLogLevel = .warn
+        #if DEBUG
+            buglyConfig.version = versionName + ".6666"
+            buglyConfig.debugMode = true
+        #else
+            buglyConfig.version = versionName + "." + versionCode
+        #endif
+        buglyConfig.channel = channel
+        buglyConfig.deviceIdentifier = deviceId ?? ""
+        buglyConfig.unexpectedTerminatingDetectionEnable = true
+        buglyConfig.blockMonitorEnable = true
+        buglyConfig.blockMonitorTimeout = 2
+        Bugly.start(withAppId: appID, config: buglyConfig)
+    }
+
     // 冷热启动上报
     class func appLaunchReportUpload(isHotLaunch: Bool = false) {
         // 冷启动

+ 1 - 0
Introduce/Record/Introduce-Bridging-Header.h

@@ -4,3 +4,4 @@
 
 #import <UMCommon/UMCommon.h>
 #import <UMCommon/MobClick.h>
+#import <Bugly/Bugly.h>

+ 1 - 1
Podfile

@@ -13,7 +13,7 @@ target 'Introduce' do
   pod 'UMDevice',                 '2.1.0'
   pod 'UMCSecurityPlugins',       '1.0.6'
   pod 'UMAPM',                    '1.5.5'
-
+  pod 'Bugly',                    '2.5.91'
 ## Pods-for-AppStore
 #  pod 'BFCommonKit',           '1.4.9'
 #  pod 'BFNetRequestKit',       '0.2.3'