Bläddra i källkod

feat:权限申请顺序

zhujieshan 4 veckor sedan
förälder
incheckning
01cbd42ee0

BIN
.DS_Store


+ 2 - 2
QuickSearchLocation.xcodeproj/project.pbxproj

@@ -1387,7 +1387,7 @@
 				CODE_SIGN_ENTITLEMENTS = QuickSearchLocation/QuickSearchLocationDebug.entitlements;
 				CODE_SIGN_IDENTITY = "Apple Development";
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 36;
+				CURRENT_PROJECT_VERSION = 41;
 				DEVELOPMENT_TEAM = Q364C8K9BL;
 				ENABLE_USER_SCRIPT_SANDBOXING = NO;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -1433,7 +1433,7 @@
 				CODE_SIGN_ENTITLEMENTS = QuickSearchLocation/QuickSearchLocationRelease.entitlements;
 				CODE_SIGN_IDENTITY = "Apple Development";
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 36;
+				CURRENT_PROJECT_VERSION = 41;
 				DEVELOPMENT_TEAM = Q364C8K9BL;
 				ENABLE_USER_SCRIPT_SANDBOXING = NO;
 				FRAMEWORK_SEARCH_PATHS = (

+ 0 - 16
QuickSearchLocation/Classes/Common/Tool/QSLTools.swift

@@ -25,22 +25,6 @@ extension QSLTools {
         }
     }
     
-    /// 请求推送权限
-    func requestNotificationPermission() {
-        UNUserNotificationCenter.current().requestAuthorization(
-            options: [.alert, .sound, .badge]
-        ) { granted, error in
-            DispatchQueue.main.async {
-                if granted {
-                    DispatchQueue.main.async {
-                        UIApplication.shared.registerForRemoteNotifications()
-                    }
-                } else if let error = error {
-                    print("Error: \(error.localizedDescription)")
-                }
-            }
-        }
-    }
     
     func dealwithScheme(_ scheme: String) {
         // 将字符串转换为 URL 对象

+ 0 - 2
QuickSearchLocation/Classes/Main/AppDelegate.swift

@@ -30,8 +30,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
 
     func configNoti(){
         UNUserNotificationCenter.current().delegate = self
-        QSLTools.shared.requestNotificationPermission()
-
     }
     
     // MARK: UISceneSession Lifecycle

+ 14 - 0
QuickSearchLocation/Classes/Main/ViewController.swift

@@ -28,6 +28,20 @@ class ViewController: UIViewController {
                 sceneDelegate.window?.makeKeyAndVisible()
             }
         } else {
+            UNUserNotificationCenter.current().requestAuthorization(
+                options: [.alert, .sound, .badge]
+            ) { granted, error in
+                DispatchQueue.main.async {
+                    if granted {
+                        DispatchQueue.main.async {
+                            UIApplication.shared.registerForRemoteNotifications()
+                        }
+                    } else if let error = error {
+                        print("Error: \(error.localizedDescription)")
+                    }
+                }
+            }
+            
             if(!QSLBaseManager.shared.isLoadG){
                 QSLBaseManager.shared.initIDFA()
             }

+ 16 - 1
QuickSearchLocation/Classes/Pages/QSLGuide/QSLGuideController.swift

@@ -59,8 +59,23 @@ class QSLGuideController: QSLBaseController {
         NetworkReachabilityManager.default?.startListening(onUpdatePerforming: { status in
             if(status != .notReachable){
                 print("checkIDFA")
-                self.checkIDFA()
+                
                 NetworkReachabilityManager.default?.stopListening()
+                UNUserNotificationCenter.current().requestAuthorization(
+                    options: [.alert, .sound, .badge]
+                ) { granted, error in
+                    DispatchQueue.main.async {
+                        if granted {
+                            DispatchQueue.main.async {
+                                UIApplication.shared.registerForRemoteNotifications()
+                            }
+                        } else if let error = error {
+                            print("Error: \(error.localizedDescription)")
+                        }
+                        
+                        self.checkIDFA()
+                    }
+                }
             }
         })
         

+ 18 - 1
QuickSearchLocation/Classes/Pages/QSLHome/Controller/QSLHomeController.swift

@@ -13,6 +13,20 @@ import AMapLocationKit
 import YYText
 
 class QSLHomeController: QSLBaseController {
+    // 存储上次时间戳的属性
+    private var lastActionTimestamp: TimeInterval = 0
+    
+    // 检查时间间隔的方法
+    private func shouldProceedWithAction() -> Bool {
+        let currentTimestamp = Date().timeIntervalSince1970
+        
+        if lastActionTimestamp == 0 || currentTimestamp - lastActionTimestamp >= 1 {
+            lastActionTimestamp = currentTimestamp
+            return true
+        } else {
+            return false
+        }
+    }
     
     lazy var viewModel: QSLHomeViewModel = {
        return QSLHomeViewModel()
@@ -355,7 +369,10 @@ extension QSLHomeController {
             
             QSLBaseManager.shared.saveUserId(id: memberModel.userId)
             
-            QSLTools.shared.requestShortcutItem()
+            if(self.shouldProceedWithAction()){
+                QSLTools.shared.requestShortcutItem()
+            }
+            
 //            NotificationCenter.default.post(name: QSLNotification.QSLRefreshMember, object: nil)
             
         } fail: { code, error in

+ 2 - 2
QuickSearchLocation/Resources/Assets.xcassets/Home/home_find_friend.imageset/Contents.json

@@ -5,12 +5,12 @@
       "scale" : "1x"
     },
     {
-      "filename" : "Group 43677.png",
+      "filename" : "找TA.png",
       "idiom" : "universal",
       "scale" : "2x"
     },
     {
-      "filename" : "Group 43677 (1).png",
+      "filename" : "找TA (1).png",
       "idiom" : "universal",
       "scale" : "3x"
     }

BIN
QuickSearchLocation/Resources/Assets.xcassets/Home/home_find_friend.imageset/Group 43677 (1).png


BIN
QuickSearchLocation/Resources/Assets.xcassets/Home/home_find_friend.imageset/Group 43677.png


BIN
QuickSearchLocation/Resources/Assets.xcassets/Home/home_find_friend.imageset/找TA (1).png


BIN
QuickSearchLocation/Resources/Assets.xcassets/Home/home_find_friend.imageset/找TA.png