From fe1e0a4f138b04e6b317c7cc97db25c3b47e0174 Mon Sep 17 00:00:00 2001 From: zjx Date: Mon, 23 Jun 2025 19:14:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=8E=B7=E5=8F=96idfa=20=201?= =?UTF-8?q?.0.4=E5=8F=91=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Veloria.xcodeproj/project.pbxproj | 8 ++++-- Veloria/AppDelegate/AppDelegate+Open.swift | 6 ++++- .../Base/Controller/VPTabBarController.swift | 5 +++- Veloria/Base/Networking/API/VPWalletAPI.swift | 10 +++++-- Veloria/Base/Networking/Base/VPApi.swift | 2 +- Veloria/Libs/AppTool/VPAppTool.swift | 27 +++++++++++++++++++ Veloria/Libs/VPIAPManager/VPIAPManager.swift | 1 - Veloria/Source/Info.plist | 2 -- 8 files changed, 51 insertions(+), 10 deletions(-) diff --git a/Veloria.xcodeproj/project.pbxproj b/Veloria.xcodeproj/project.pbxproj index 5bb38e7..2e3bf2c 100644 --- a/Veloria.xcodeproj/project.pbxproj +++ b/Veloria.xcodeproj/project.pbxproj @@ -1798,13 +1798,15 @@ CODE_SIGN_ENTITLEMENTS = Veloria/Veloria.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 3; + CURRENT_PROJECT_VERSION = 4; DEVELOPMENT_TEAM = 394VH538M8; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = Veloria/Source/Info.plist; + INFOPLIST_KEY_ITSAppUsesNonExemptEncryption = NO; INFOPLIST_KEY_NSCameraUsageDescription = "The APP needs to access your album to provide screenshots for feedback."; INFOPLIST_KEY_NSLocationWhenInUseUsageDescription = "The APP needs to access your location to recommend better short dramas for you"; INFOPLIST_KEY_NSPhotoLibraryUsageDescription = "The APP needs to access your album to provide screenshots for feedback."; + INFOPLIST_KEY_NSUserTrackingUsageDescription = "We will use your advertising identifier (IDFA) to provide a personalized advertising experience."; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; INFOPLIST_KEY_UIMainStoryboardFile = ""; @@ -1839,13 +1841,15 @@ CODE_SIGN_ENTITLEMENTS = Veloria/Veloria.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 3; + CURRENT_PROJECT_VERSION = 4; DEVELOPMENT_TEAM = 394VH538M8; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = Veloria/Source/Info.plist; + INFOPLIST_KEY_ITSAppUsesNonExemptEncryption = NO; INFOPLIST_KEY_NSCameraUsageDescription = "The APP needs to access your album to provide screenshots for feedback."; INFOPLIST_KEY_NSLocationWhenInUseUsageDescription = "The APP needs to access your location to recommend better short dramas for you"; INFOPLIST_KEY_NSPhotoLibraryUsageDescription = "The APP needs to access your album to provide screenshots for feedback."; + INFOPLIST_KEY_NSUserTrackingUsageDescription = "We will use your advertising identifier (IDFA) to provide a personalized advertising experience."; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; INFOPLIST_KEY_UIMainStoryboardFile = ""; diff --git a/Veloria/AppDelegate/AppDelegate+Open.swift b/Veloria/AppDelegate/AppDelegate+Open.swift index c4cca65..d02e8ba 100644 --- a/Veloria/AppDelegate/AppDelegate+Open.swift +++ b/Veloria/AppDelegate/AppDelegate+Open.swift @@ -39,7 +39,11 @@ extension SceneDelegate { private static var webpageURL: URL? func vp_handleOpenAppMessage(webpageURL: URL?) { - guard VPNetworkReachabilityManager.manager.isReachable == true, AppDelegate.haveBeenShownAPNS, self.isOpenApp else { + guard VPNetworkReachabilityManager.manager.isReachable == true, //有网 + AppDelegate.haveBeenShownAPNS, //推送弹窗 + self.isOpenApp, //APP被开启 + VPAppTool.idfaAuthorizationFinish //idfa授权完成 + else { if let webpageURL = webpageURL { SceneDelegate.webpageURL = webpageURL } diff --git a/Veloria/Base/Controller/VPTabBarController.swift b/Veloria/Base/Controller/VPTabBarController.swift index f94c8f2..67ec36c 100644 --- a/Veloria/Base/Controller/VPTabBarController.swift +++ b/Veloria/Base/Controller/VPTabBarController.swift @@ -58,7 +58,10 @@ class VPTabBarController: UITabBarController { DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { [weak self] in self?.checkUpdates() } - + ///授权idfa + VPAppTool.requestIDFAAuthorization { idfa in + vpLog(message: idfa) + } } diff --git a/Veloria/Base/Networking/API/VPWalletAPI.swift b/Veloria/Base/Networking/API/VPWalletAPI.swift index 25a58e1..06840a8 100644 --- a/Veloria/Base/Networking/API/VPWalletAPI.swift +++ b/Veloria/Base/Networking/API/VPWalletAPI.swift @@ -94,7 +94,13 @@ class VPWalletAPI { ] VPNetwork.request(parameters: param) { (response: VPNetworkResponse) in - if let message = response.data?.message, message.count > 0 { + guard let data = response.data else { + VPToast.show(text: "veloria_network".localized) + completer?(nil) + return + } + + if let message = data.message, message.count > 0 { if response.data?.code == 30007 { VPToast.show(text: "veloria_vip_error_1".localized) } else { @@ -103,7 +109,7 @@ class VPWalletAPI { completer?(nil) } else { - completer?(response.data) + completer?(data) } } } diff --git a/Veloria/Base/Networking/Base/VPApi.swift b/Veloria/Base/Networking/Base/VPApi.swift index 617f5d2..afe4fc9 100644 --- a/Veloria/Base/Networking/Base/VPApi.swift +++ b/Veloria/Base/Networking/Base/VPApi.swift @@ -87,7 +87,7 @@ extension VPApi: TargetType { "brand" : "apple", //品牌 "app-name" : kVPAPPBundleIdentifier, "system-type" : "ios", - "idfa" : JXUUID.idfa(), + "idfa" : VPAppTool.getIdfa(), "model" : UIDevice.vp_machineModelName(), ] //登录信息 diff --git a/Veloria/Libs/AppTool/VPAppTool.swift b/Veloria/Libs/AppTool/VPAppTool.swift index b736966..37c3e8a 100644 --- a/Veloria/Libs/AppTool/VPAppTool.swift +++ b/Veloria/Libs/AppTool/VPAppTool.swift @@ -6,6 +6,8 @@ // import UIKit +import AppTrackingTransparency +import AdSupport class VPAppTool: NSObject { @@ -54,6 +56,31 @@ class VPAppTool: NSObject { } } +extension VPAppTool { + ///idfa是否授权结束 + static var idfaAuthorizationFinish = false + static var idfa: String? + + static func getIdfa() -> String { + if let idfa = idfa { + return idfa + } else { + return ASIdentifierManager.shared().advertisingIdentifier.uuidString + } + } + + static func requestIDFAAuthorization(completion: @escaping (String?) -> Void) { + DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) { + ATTrackingManager.requestTrackingAuthorization { status in + idfaAuthorizationFinish = true + VPAppTool.idfa = ASIdentifierManager.shared().advertisingIdentifier.uuidString + VPAppTool.sceneDelegate?.vp_retryHandleOpenAppMessage() + completion(idfa) + } + } + } +} + extension VPAppTool { ///打开消息通知设置页面 diff --git a/Veloria/Libs/VPIAPManager/VPIAPManager.swift b/Veloria/Libs/VPIAPManager/VPIAPManager.swift index 734aded..7d97c43 100644 --- a/Veloria/Libs/VPIAPManager/VPIAPManager.swift +++ b/Veloria/Libs/VPIAPManager/VPIAPManager.swift @@ -60,7 +60,6 @@ class VPIAPManager { VPHUD.dismiss() self.waitRestoreModel = nil self.completionHandler?(false) - VPToast.show(text: "veloria_network".localized) return } self.orderCode = orderModel.order_code diff --git a/Veloria/Source/Info.plist b/Veloria/Source/Info.plist index 46a8736..28da618 100644 --- a/Veloria/Source/Info.plist +++ b/Veloria/Source/Info.plist @@ -31,8 +31,6 @@ $(PRODUCT_NAME) FirebaseAppDelegateProxyEnabled - ITSAppUsesNonExemptEncryption - LSApplicationQueriesSchemes fbapi