Explorar o código

1.接入友盟

wenweiwei %!s(int64=4) %!d(string=hai) anos
pai
achega
271377d2a0

+ 15 - 8
MusicVideoPlus/MusicVideoPlus.xcodeproj/project.pbxproj

@@ -7,6 +7,7 @@
 	objects = {
 
 /* Begin PBXBuildFile section */
+		2D1EC138266B4F4900CBACE4 /* MVUMApiUtil.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D1EC137266B4F4900CBACE4 /* MVUMApiUtil.swift */; };
 		4112DD832669BFA600A5AFD9 /* MVBanner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4112DD822669BFA600A5AFD9 /* MVBanner.swift */; };
 		4112DD862669BFFA00A5AFD9 /* MVBannerFlowLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4112DD852669BFFA00A5AFD9 /* MVBannerFlowLayout.swift */; };
 		4112DD8C2669C0F500A5AFD9 /* banner2.jpeg in Resources */ = {isa = PBXBuildFile; fileRef = 4112DD892669C0F500A5AFD9 /* banner2.jpeg */; };
@@ -30,6 +31,7 @@
 /* End PBXBuildFile section */
 
 /* Begin PBXFileReference section */
+		2D1EC137266B4F4900CBACE4 /* MVUMApiUtil.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVUMApiUtil.swift; sourceTree = "<group>"; };
 		3FA19A38D145C54301B3CD85 /* Pods_MusicVideoPlus.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_MusicVideoPlus.framework; sourceTree = BUILT_PRODUCTS_DIR; };
 		4112DCF02668C45B00A5AFD9 /* MusicVideoPlus.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = MusicVideoPlus.entitlements; sourceTree = "<group>"; };
 		4112DD492668D6A600A5AFD9 /* MusicVideoPlus-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "MusicVideoPlus-Bridging-Header.h"; sourceTree = "<group>"; };
@@ -70,6 +72,15 @@
 /* End PBXFrameworksBuildPhase section */
 
 /* Begin PBXGroup section */
+		2D1EC136266B4F3300CBACE4 /* Utils */ = {
+			isa = PBXGroup;
+			children = (
+				2D1EC137266B4F4900CBACE4 /* MVUMApiUtil.swift */,
+			);
+			name = Utils;
+			path = Modules/Utils;
+			sourceTree = "<group>";
+		};
 		4112DD812669BF8900A5AFD9 /* Banner */ = {
 			isa = PBXGroup;
 			children = (
@@ -124,9 +135,9 @@
 		41CA6E39266782C900874B19 /* Classes */ = {
 			isa = PBXGroup;
 			children = (
+				2D1EC136266B4F3300CBACE4 /* Utils */,
 				41CA6E3A266782C900874B19 /* Vendors */,
 				41CA6E3B266782C900874B19 /* Enums */,
-				41CA6E3C266782C900874B19 /* Utils */,
 				41CA6E3D266782C900874B19 /* Modules */,
 				41CA6E5C266782C900874B19 /* Categorys */,
 			);
@@ -147,13 +158,6 @@
 			path = Enums;
 			sourceTree = "<group>";
 		};
-		41CA6E3C266782C900874B19 /* Utils */ = {
-			isa = PBXGroup;
-			children = (
-			);
-			path = Utils;
-			sourceTree = "<group>";
-		};
 		41CA6E3D266782C900874B19 /* Modules */ = {
 			isa = PBXGroup;
 			children = (
@@ -580,6 +584,7 @@
 				41CA6E632667853C00874B19 /* MVHomeController.swift in Sources */,
 				4149C8932669FE6F0055CAA2 /* MVTagsCell.swift in Sources */,
 				4112DD832669BFA600A5AFD9 /* MVBanner.swift in Sources */,
+				2D1EC138266B4F4900CBACE4 /* MVUMApiUtil.swift in Sources */,
 				41CA6E69266788C000874B19 /* MVLoginController.swift in Sources */,
 				41CA6E662667887C00874B19 /* MVMineController.swift in Sources */,
 				41CA6F4B26689F4400874B19 /* PQMineViewModel.swift in Sources */,
@@ -719,6 +724,7 @@
 				CODE_SIGN_STYLE = Automatic;
 				CURRENT_PROJECT_VERSION = 1000;
 				DEVELOPMENT_TEAM = UH52C8A7SN;
+				ENABLE_BITCODE = NO;
 				INFOPLIST_FILE = MusicVideoPlus/Info.plist;
 				IPHONEOS_DEPLOYMENT_TARGET = 10.0;
 				LD_RUNPATH_SEARCH_PATHS = (
@@ -745,6 +751,7 @@
 				CODE_SIGN_STYLE = Automatic;
 				CURRENT_PROJECT_VERSION = 1000;
 				DEVELOPMENT_TEAM = UH52C8A7SN;
+				ENABLE_BITCODE = NO;
 				INFOPLIST_FILE = MusicVideoPlus/Info.plist;
 				IPHONEOS_DEPLOYMENT_TARGET = 10.0;
 				LD_RUNPATH_SEARCH_PATHS = (

+ 6 - 15
MusicVideoPlus/MusicVideoPlus/AppDelegate.swift

@@ -5,16 +5,13 @@
 //  Created by ak on 2021/5/28.
 //
 
-import UIKit
 import BFFramework
+import UIKit
 @main
 class AppDelegate: UIResponder, UIApplicationDelegate {
-
-
     var window: UIWindow?
 
-    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
-       
+    func application(_: UIApplication, didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
         window = UIWindow(frame: UIScreen.main.bounds)
 
         let rootViewController = MVHomeController()
@@ -23,22 +20,19 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
         window?.rootViewController = navigationController
 
         window?.makeKeyAndVisible()
-        
-        let wxappInfo = WXApiInfo.init()
+
+        let wxappInfo = WXApiInfo()
         wxappInfo.state = "com.piaoquan.pqspeed"
         wxappInfo.appid = "wx0e8234aac576d1e0"
         wxappInfo.secret = "a6c35e4e8adf60039f94f4c18e2aabdb"
         wxappInfo.universalLink = "https://speed.piaoquantv.com"
         wxappInfo.scope = "snsapi_userinfo"
         PQSingletoWXApiUtil.shared.registerApp(appInfo: wxappInfo)
-        
-        
+        // 注册友盟
+        MVUMApiUtil.register()
         return true
-        
- 
     }
 
- 
     func application(_: UIApplication, continue userActivity: NSUserActivity, restorationHandler _: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
         return PQSingletoWXApiUtil.shared.handleOpenUniversalLink(userActivity: userActivity)
     }
@@ -54,7 +48,4 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
     func application(_: UIApplication, open url: URL, sourceApplication _: String?, annotation _: Any) -> Bool {
         return PQSingletoWXApiUtil.shared.handleOpen(url: url)
     }
-
-
 }
-

+ 68 - 0
MusicVideoPlus/MusicVideoPlus/Classes/Modules/Utils/MVUMApiUtil.swift

@@ -0,0 +1,68 @@
+//
+//  MVUMApiUtil.swift
+//  MusicVideoPlus
+//
+//  Created by SanW on 2021/6/5.
+//
+
+import BFFramework
+import UIKit
+
+// MARK: - 友盟相关工具类
+
+/// 友盟相关工具类
+class MVUMApiUtil: NSObject {
+    class func register() {
+        // 注册友盟
+        UMConfigure.setEncryptEnabled(true)
+        // 初始化友盟所有组件产品
+        UMConfigure.initWithAppkey(PQBFConfig.shared.umAppkey, channel: PQBFConfig.shared.channelID)
+        #if DEBUG
+            UMConfigure.setLogEnabled(true)
+        #endif
+        BFLog(message: "友盟版本号:\(UMConfigure.version())")
+    }
+    /// 页面时长统计
+    /// - Parameters:
+    ///   - pageName: 页面名称
+    ///   - isBegin: 开始/结束
+    /// - Returns: <#description#>
+    class func pageAutoTimeAnalytics(pageName: String?, isBegin: Bool) {
+        if pageName == nil || pageName?.count ?? 0 <= 0 {
+            return
+        }
+        BFLog(message: "页面时长统计:isBegin = \(isBegin),pageName = \(pageName ?? "")")
+        if isBegin {
+            MobClick.beginLogPageView(pageName)
+        } else {
+            MobClick.endLogPageView(pageName)
+        }
+    }
+
+    /// 事件统计
+    /// - Parameters:
+    ///   - eventId: 事件ID
+    ///   - attributes: 事件属性
+    /// - Returns: <#description#>
+    class func eventAnalytics(eventId: String?, attributes: [String: Any]?) {
+        if eventId == nil || eventId?.count ?? 0 <= 0 {
+            return
+        }
+        BFLog(message: "自定义事件统计:eventId = \(eventId ?? ""),attributes = \(attributes ?? [:])")
+        if attributes != nil && attributes?.count ?? 0 > 0 {
+            MobClick.event(eventId!, attributes: attributes!)
+        } else {
+            MobClick.event(eventId!)
+        }
+    }
+
+    /// 账号统计
+    /// - Returns: <#description#>
+    class func accountAnalytics() {
+        if BFLoginUserInfo.shared.accessToken.count > 0 {
+            MobClick.profileSignIn(withPUID: BFLoginUserInfo.shared.accessToken, provider: cPrimarykey)
+        } else {
+            MobClick.profileSignOff()
+        }
+    }
+}

+ 3 - 0
MusicVideoPlus/MusicVideoPlus/MusicVideoPlus-Bridging-Header.h

@@ -9,4 +9,7 @@
 #define MusicVideoPlus_Bridging_Header_h
 
 #import "TYAttributedLabel.h"
+#import <UMCommon/UMCommon.h>
+#import <UMCommon/MobClick.h>
+
 #endif /* MusicVideoPlus_Bridging_Header_h */

+ 4 - 0
MusicVideoPlus/Podfile

@@ -10,4 +10,8 @@ target 'MusicVideoPlus' do
 
   pod 'JWTDecode','2.6.0' # Apple登陆校验库
   pod 'TYAttributedLabel','2.6.9' #  富文本
+  pod 'UMCommon','7.2.9'
+  pod 'UMDevice','1.2.0'
+  pod 'UMCSecurityPlugins','1.0.6'
+  pod 'UMAPM','1.2.1'
 end