فهرست منبع

feat:新增firebase

kailen 3 روز پیش
والد
کامیت
3d55285a1e

+ 4 - 0
AIEmoji.xcodeproj/project.pbxproj

@@ -10,6 +10,7 @@
 		605E20552DCC90CE0069F4B6 /* SchemeHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 605E20542DCC90CE0069F4B6 /* SchemeHandler.swift */; };
 		605E20592DCCAF3C0069F4B6 /* SchemeHandler+Ext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 605E20582DCCAF3C0069F4B6 /* SchemeHandler+Ext.swift */; };
 		605E205B2DCCB8D20069F4B6 /* TSCustomAlertController+Ext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 605E205A2DCCB8D20069F4B6 /* TSCustomAlertController+Ext.swift */; };
+		60AE42912E31E046009FBB77 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 60AE42902E31E046009FBB77 /* GoogleService-Info.plist */; };
 		A80327B02D813A0200AF7878 /* TSTTPSelectStyleCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A80327AF2D8139FC00AF7878 /* TSTTPSelectStyleCell.swift */; };
 		A80327B32D813D4900AF7878 /* TSTTPInputVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = A80327B22D813D4800AF7878 /* TSTTPInputVC.swift */; };
 		A80327B62D813D8700AF7878 /* TSTTPInputVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = A80327B52D813D8100AF7878 /* TSTTPInputVM.swift */; };
@@ -345,6 +346,7 @@
 		605E20542DCC90CE0069F4B6 /* SchemeHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SchemeHandler.swift; sourceTree = "<group>"; };
 		605E20582DCCAF3C0069F4B6 /* SchemeHandler+Ext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SchemeHandler+Ext.swift"; sourceTree = "<group>"; };
 		605E205A2DCCB8D20069F4B6 /* TSCustomAlertController+Ext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TSCustomAlertController+Ext.swift"; sourceTree = "<group>"; };
+		60AE42902E31E046009FBB77 /* GoogleService-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
 		6E77A292B548CD79E381757E /* Pods-AIEmoji.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AIEmoji.release.xcconfig"; path = "Target Support Files/Pods-AIEmoji/Pods-AIEmoji.release.xcconfig"; sourceTree = "<group>"; };
 		86FB4D6AEFDDA7A2017F307C /* Pods_AIEmoji.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_AIEmoji.framework; sourceTree = BUILT_PRODUCTS_DIR; };
 		A80327AF2D8139FC00AF7878 /* TSTTPSelectStyleCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TSTTPSelectStyleCell.swift; sourceTree = "<group>"; };
@@ -2048,6 +2050,7 @@
 				A8F3D6492E2E2AC000DE6C9D /* launch2.png */,
 				A8F774822D38E8B700AA6E93 /* Assets.xcassets */,
 				A8F774832D38E8B700AA6E93 /* Info.plist */,
+				60AE42902E31E046009FBB77 /* GoogleService-Info.plist */,
 				A83405012DA35CB700C140E4 /* InfoPlist.strings */,
 				A83404FC2DA35BFE00C140E4 /* Localizable.strings */,
 				A8F774852D38E8B700AA6E93 /* LaunchScreen.storyboard */,
@@ -2557,6 +2560,7 @@
 				A82542F62E279C5A00F54FE5 /* Making Face.mp4 in Resources */,
 				A82542F72E279C5A00F54FE5 /* Robot.mp4 in Resources */,
 				A82542F82E279C5A00F54FE5 /* Pet to Human.mp4 in Resources */,
+				60AE42912E31E046009FBB77 /* GoogleService-Info.plist in Resources */,
 				A82542FA2E279C5A00F54FE5 /* Walking with Beasts.mp4 in Resources */,
 				A82542FB2E279C5A00F54FE5 /* French Kiss.mp4 in Resources */,
 				A80E72482D3F4F0A00C64288 /* templates.json in Resources */,

+ 12 - 6
AIEmoji/AppDelegate.swift

@@ -5,14 +5,15 @@
 //  Created by 100Years on 2025/1/15.
 //
 
+import FirebaseCore
 import UIKit
+
 var kAppNewVerison = ""
 @main
 class AppDelegate: UIResponder, UIApplicationDelegate {
-    
-    static var shared:AppDelegate?
-    static var tabbar:TSTabBarController?
-    
+    static var shared: AppDelegate?
+    static var tabbar: TSTabBarController?
+
     var window: UIWindow?
     var backgroundTaskIdentifier: UIBackgroundTaskIdentifier = .invalid
 
@@ -22,10 +23,15 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
         window?.backgroundColor = UIColor.black
         window?.makeKeyAndVisible()
         initPlatform()
+        initFireBase()
         goToLoadVC()
         return true
     }
 
+    func initFireBase() {
+        FirebaseApp.configure()
+    }
+
     func goToLoadVC() {
         let launchVC = TSLaunchVC()
         launchVC.dismissHandler = { [weak self] in
@@ -51,7 +57,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
 //            let navi = TSBaseNavigationC(rootViewController: bootPageVC)
 //            window?.rootViewController = navi
 //        } else {
-            goToTab()
+        goToTab()
 //        }
     }
 
@@ -63,7 +69,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
         checkAppConfig()
 
         kHandleDBHistoryOperation()
-        
+
         kPurchaseCountDownTime.autoStart()
     }
 }

+ 48 - 59
AIEmoji/Business/TSTabBarController/TSTabBarController.swift

@@ -5,11 +5,9 @@
 //  Created by 100Years on 2024/12/20.
 //
 
-
-import UIKit
 import Kingfisher
+import UIKit
 class TSTabBarController: UITabBarController {
-  
 //    lazy var animatedImageView: AnimatedImageView = {
 //        let animatedImageView = AnimatedImageView()
 //        animatedImageView.autoPlayAnimatedImage = false
@@ -18,12 +16,12 @@ class TSTabBarController: UITabBarController {
 //        }
 //        return animatedImageView
 //    }()
-    
+
     private var viewControllerArray: [String] = []
     private var titleArray: [String] = []
     private var selectedImageArray: [String] = []
     private var unselectedImageArray: [String] = []
-    
+
     override func viewDidLoad() {
         super.viewDidLoad()
         createUI()
@@ -33,23 +31,22 @@ class TSTabBarController: UITabBarController {
     }
 
     @objc private func setUpData() {
-
-        viewControllerArray = ["TSDiscoverVC","TSGenerateHistoryVC","TSSetingVC"]
-        titleArray = ["Discover","Creations","Setting"]
+        viewControllerArray = ["TSDiscoverVC", "TSGenerateHistoryVC", "TSSetingVC"]
+        titleArray = ["Discover", "Creations", "Setting"]
         selectedImageArray = [
             "tabbar_select_pic",
             "tabbar_select_history",
-            "tabbar_select_setting"
+            "tabbar_select_setting",
         ]
         unselectedImageArray = [
             "tabbar_unSelect_pic",
             "tabbar_unSelect_history",
-            "tabbar_unSelect_setting"
+            "tabbar_unSelect_setting",
         ]
 
         var tabArray: [UINavigationController] = []
 
-        for i in 0..<viewControllerArray.count {
+        for i in 0 ..< viewControllerArray.count {
             if let rootViewController = viewControllerArray[i].toInstance(of: UIViewController.self) {
                 let title = titleArray[i]
                 let nav = TSBaseNavigationC(rootViewController: rootViewController)
@@ -64,8 +61,7 @@ class TSTabBarController: UITabBarController {
             }
         }
 
-        self.viewControllers = tabArray
-
+        viewControllers = tabArray
     }
 
     private func createUI() {
@@ -73,20 +69,20 @@ class TSTabBarController: UITabBarController {
         tabBar.isTranslucent = false
         tabBar.backgroundColor = "#262626".uiColor
         tabBar.backgroundImage = UIImage.colorFrom(color: tabBar.backgroundColor!, size: CGSize(width: k_ScreenWidth, height: k_TabBar_Height))
-        
+
         // 自定义 TabBarItem 字体颜色和选中颜色
-        UITabBar.appearance().unselectedItemTintColor = .white.withAlphaComponent(0.4)// 未选中颜色
+        UITabBar.appearance().unselectedItemTintColor = .white.withAlphaComponent(0.4) // 未选中颜色
         UITabBar.appearance().tintColor = UIColor.themeColor // 选中颜色
-        
+
         delegate = self
-        
+
         // Workaround to fix the tab bar position in iPad
         if #available(iOS 18.0, *), UIDevice.current.userInterfaceIdiom == .pad {
             tabBar.removeFromSuperview()
             view.addSubview(tabBar)
             traitOverrides.horizontalSizeClass = .compact
         }
-        
+
         setupDoubleTapToScrollTop()
     }
 
@@ -95,36 +91,35 @@ class TSTabBarController: UITabBarController {
         tabBarItem.image = image?.withRenderingMode(.alwaysOriginal)
         tabBarItem.title = title
         tabBarItem.selectedImage = selectedImage?.withRenderingMode(.alwaysOriginal)
-        
+
         tabBarItem.setTitleTextAttributes([
-                .font: UIFont.font(size: 12),
-            ],for: .normal)
-        
+            .font: UIFont.font(size: 12),
+        ], for: .normal)
+
         tabBarItem.setTitleTextAttributes([
-                .font: UIFont.font(size: 12),
-            ], for: .selected)
-        
+            .font: UIFont.font(size: 12),
+        ], for: .selected)
+
         return tabBarItem
     }
-    func monitorEvent(){
-        
-        //后台生成后,跳转到历史页面
+
+    func monitorEvent() {
+        // 后台生成后,跳转到历史页面
         NotificationCenter.default.addObserver(forName: .kAIComeInBackstage, object: nil, queue: .main) { _ in
             if let nav = self.viewControllers?.safeObj(At: self.selectedIndex) as? UINavigationController {
                 nav.popToRootViewController(animated: false)
             }
             TSGenerateHistoryVC.showPosition()
         }
-    
-        //升级弹窗
+
+        // 升级弹窗
         refreshUpdateView()
         NotificationCenter.default.addObserver(self, selector: #selector(refreshUpdateView), name: .kAppUpdateNotification, object: nil)
-        
-        //关闭订阅页面,弹出优惠订阅
+
+        // 关闭订阅页面,弹出优惠订阅
         refreshPurchasePromotional()
         NotificationCenter.default.addObserver(self, selector: #selector(refreshPurchasePromotional), name: .kCloseTSPurchaseVC, object: nil)
     }
-    
 
     deinit {
         debugPrint("TSTabBarController deinit")
@@ -132,51 +127,48 @@ class TSTabBarController: UITabBarController {
     }
 }
 
-
 extension TSTabBarController {
-    func changeSelectedIndex(index:Int){
-        self.selectedIndex = index
+    func changeSelectedIndex(index: Int) {
+        selectedIndex = index
     }
 }
 
-
-//升级弹窗
+// 升级弹窗
 extension TSTabBarController {
     @objc func refreshUpdateView() {
-        if TSAppUpdateManager.isNeedUpdate,TSAppUpdateManager.isDisplayedUpdateAlert == false{
+        if TSAppUpdateManager.isNeedUpdate, TSAppUpdateManager.isDisplayedUpdateAlert == false {
             kMainAfter(1.0) {
                 let updateAlertVC = TSAppUpdateAlertVC()
                 updateAlertVC.modalPresentationStyle = .overFullScreen
                 updateAlertVC.modalTransitionStyle = .crossDissolve
-                self.present(updateAlertVC, animated: true,completion: {
+                self.present(updateAlertVC, animated: true, completion: {
                     TSAppUpdateManager.isDisplayedUpdateAlert = true
                 })
             }
         }
     }
-
 }
 
-//关闭订阅页面,弹出优惠订阅
+// 关闭订阅页面,弹出优惠订阅
 extension TSTabBarController {
     @objc func refreshPurchasePromotional() {
-        if TSPurchasePromotionalVC.showGift,kPurchaseCountDownTime.isNeedCheck == true{
+        if TSPurchasePromotionalVC.showGift, kPurchaseCountDownTime.isNeedCheck == true {
             kMainAfter(0.3) {
                 let updateAlertVC = TSPurchasePromotionalVC(isAnimation: true)
                 updateAlertVC.modalPresentationStyle = .overFullScreen
                 updateAlertVC.modalTransitionStyle = .crossDissolve
-                self.present(updateAlertVC, animated: true,completion: {
+                self.present(updateAlertVC, animated: true, completion: {
                     kPurchaseCountDownTime.isNeedCheck = false
                 })
             }
         }
     }
-
 }
-//private let animatedIndex = 1
-//extension TSTabBarController {
+
+// private let animatedIndex = 1
+// extension TSTabBarController {
 //    func addAnimatedImageView(){
-//        
+//
 //        let index = 1
 //        if let tabBarItems = tabBar.items,tabBarItems.count > index {
 //            let tabBarButtons = tabBar.subviews.filter({ $0.isKind(of: NSClassFromString("UITabBarButton")!) })
@@ -192,13 +184,13 @@ extension TSTabBarController {
 //                kDelayMainShort {
 //                    self.animatedImageView.startAnimating()
 //                }
-//                
+//
 //            }
 //        }
 //    }
-//}
+// }
 
-extension TSTabBarController:UITabBarControllerDelegate {
+extension TSTabBarController: UITabBarControllerDelegate {
     func tabBarController(_ tabBarController: UITabBarController, didSelect viewController: UIViewController) {
 //        if tabBarController.selectedIndex == animatedIndex {
 //            self.animatedImageView.isHidden = true
@@ -208,8 +200,6 @@ extension TSTabBarController:UITabBarControllerDelegate {
     }
 }
 
-
-
 protocol TSTabBarControllerProtocol {
     func tabBarDoubleTap(_ tabbar: UITabBarController)
 }
@@ -218,7 +208,7 @@ extension TSTabBarController {
     func setupDoubleTapToScrollTop() {
         let doubleTap = UITapGestureRecognizer(target: self, action: #selector(handleDoubleTap(_:)))
         doubleTap.numberOfTapsRequired = 2
-        doubleTap.delaysTouchesBegan = false  // 默认是true,会延迟单击响应
+        doubleTap.delaysTouchesBegan = false // 默认是true,会延迟单击响应
         doubleTap.delaysTouchesEnded = false
         tabBar.addGestureRecognizer(doubleTap)
     }
@@ -226,13 +216,12 @@ extension TSTabBarController {
     @objc private func handleDoubleTap(_ gesture: UITapGestureRecognizer) {
         guard gesture.state == .ended else { return }
         guard let vc = selectedViewController else { return }
-        
-        if let vc = vc as? TSTabBarControllerProtocol{
+
+        if let vc = vc as? TSTabBarControllerProtocol {
             vc.tabBarDoubleTap(self)
-        }else if let nav = vc as? UINavigationController {
+        } else if let nav = vc as? UINavigationController {
             if let topVC = nav.topViewController {
-                
-                if let vc = topVC as? TSTabBarControllerProtocol{
+                if let vc = topVC as? TSTabBarControllerProtocol {
                     vc.tabBarDoubleTap(self)
                 }
             }

+ 30 - 0
AIEmoji/GoogleService-Info.plist

@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>API_KEY</key>
+	<string>AIzaSyD1IequWZZuYUOq2cOkQGmN7EYNiLOkWIU</string>
+	<key>GCM_SENDER_ID</key>
+	<string>782785661615</string>
+	<key>PLIST_VERSION</key>
+	<string>1</string>
+	<key>BUNDLE_ID</key>
+	<string>com.girl.music.wallpaper</string>
+	<key>PROJECT_ID</key>
+	<string>aurart-10d51</string>
+	<key>STORAGE_BUCKET</key>
+	<string>aurart-10d51.firebasestorage.app</string>
+	<key>IS_ADS_ENABLED</key>
+	<false></false>
+	<key>IS_ANALYTICS_ENABLED</key>
+	<false></false>
+	<key>IS_APPINVITE_ENABLED</key>
+	<true></true>
+	<key>IS_GCM_ENABLED</key>
+	<true></true>
+	<key>IS_SIGNIN_ENABLED</key>
+	<true></true>
+	<key>GOOGLE_APP_ID</key>
+	<string>1:782785661615:ios:6a08690f69b628139a625a</string>
+</dict>
+</plist>

+ 3 - 0
Podfile

@@ -26,6 +26,9 @@ target 'AIEmoji' do
   pod 'TYCyclePagerView'
   pod 'Shimmer'
   pod 'APNGKit', '~> 2.0'
+  
+  pod 'FirebaseAnalytics'
+  pod 'FirebaseCrashlytics'
 end