Explorar o código

feat:新增广告追踪权限

kailen hai 3 meses
pai
achega
4ff9dab790

+ 2 - 0
TSLiveWallpaper.xcodeproj/project.pbxproj

@@ -956,6 +956,7 @@
 				INFOPLIST_FILE = TSLiveWallpaper/Info.plist;
 				INFOPLIST_KEY_CFBundleDisplayName = LiveLive;
 				INFOPLIST_KEY_NSPhotoLibraryUsageDescription = "Allow us to access Photos in order to save wallpapers to your device.";
+				INFOPLIST_KEY_NSUserTrackingUsageDescription = "It will only be used to measure advertising efficiency without leaking any of your personal information.";
 				INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
 				INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
 				INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait;
@@ -995,6 +996,7 @@
 				INFOPLIST_FILE = TSLiveWallpaper/Info.plist;
 				INFOPLIST_KEY_CFBundleDisplayName = LiveLive;
 				INFOPLIST_KEY_NSPhotoLibraryUsageDescription = "Allow us to access Photos in order to save wallpapers to your device.";
+				INFOPLIST_KEY_NSUserTrackingUsageDescription = "It will only be used to measure advertising efficiency without leaking any of your personal information.";
 				INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
 				INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
 				INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait;

+ 24 - 2
TSLiveWallpaper/AppDelegate.swift

@@ -5,6 +5,7 @@
 //  Created by 100Years on 2024/12/19.i
 //
 
+import AppTrackingTransparency
 import GoogleMobileAds
 import UIKit
 
@@ -36,12 +37,33 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
         _ = TSImageDataCenter.shared
         window?.rootViewController = TSLaunchVC()
     }
-    
-    func addNetListener(){
+
+    func addNetListener() {
         TSNetworkShard.monitorNetworkPermission { success in
             if success {
                 PurchaseManager.default.requestProducts()
             }
+            AppDelegate.requestAdTrack()
+        }
+    }
+
+    static func requestAdTrack() {
+        DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
+            ATTrackingManager.requestTrackingAuthorization(completionHandler: { status in
+                // 这里可以处理用户的选择
+                switch status {
+                case .authorized:
+                    print("授权成功,可以开始跟踪")
+                case .denied:
+                    print("用户拒绝了授权")
+                case .restricted:
+                    print("该设备的用户无法授权")
+                case .notDetermined:
+                    print("用户尚未做出选择")
+                @unknown default:
+                    print("未知状态")
+                }
+            })
         }
     }
 }