From 3bbf7f63bde484b187a2c12350d2b5b073d535df Mon Sep 17 00:00:00 2001 From: zaehorang Date: Sat, 23 Nov 2024 18:40:43 +0900 Subject: [PATCH] feat: #71 Add App Tracking Transparency permission request --- FiveGuyes/FiveGuyes.xcodeproj/project.pbxproj | 2 ++ FiveGuyes/FiveGuyes/FiveGuyesApp.swift | 30 +++++++++++++++++-- FiveGuyes/FiveGuyes/Info.plist | 11 ++++--- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/FiveGuyes/FiveGuyes.xcodeproj/project.pbxproj b/FiveGuyes/FiveGuyes.xcodeproj/project.pbxproj index 4dd53b5..b6dbc35 100644 --- a/FiveGuyes/FiveGuyes.xcodeproj/project.pbxproj +++ b/FiveGuyes/FiveGuyes.xcodeproj/project.pbxproj @@ -670,6 +670,7 @@ INFOPLIST_FILE = FiveGuyes/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = "한입독서"; INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.books"; + INFOPLIST_KEY_NSUserTrackingUsageDescription = "사용자에게 맞춤 서비스를 제공하기 위해 사용되며, 서비스 이외에 목적으로는 절대 사용되지 않습니다."; INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchScreen_Generation = YES; @@ -709,6 +710,7 @@ INFOPLIST_FILE = FiveGuyes/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = "한입독서"; INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.books"; + INFOPLIST_KEY_NSUserTrackingUsageDescription = "사용자에게 맞춤 서비스를 제공하기 위해 사용되며, 서비스 이외에 목적으로는 절대 사용되지 않습니다."; INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchScreen_Generation = YES; diff --git a/FiveGuyes/FiveGuyes/FiveGuyesApp.swift b/FiveGuyes/FiveGuyes/FiveGuyesApp.swift index 5e56aa7..66c7939 100644 --- a/FiveGuyes/FiveGuyes/FiveGuyesApp.swift +++ b/FiveGuyes/FiveGuyes/FiveGuyesApp.swift @@ -5,6 +5,8 @@ // Created by zaehorang on 10/3/24. // +import AdSupport +import AppTrackingTransparency import SwiftData import SwiftUI @@ -23,9 +25,31 @@ struct FiveGuyesApp: App { } } +// MARK: - AppDelegate class class AppDelegate: NSObject, UIApplicationDelegate { - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { - FirebaseApp.configure() - return true + func application(_ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { + // Firebase 초기화 + FirebaseApp.configure() + + // 앱 추적 권한 요청을 비동기적으로 처리 + Task { + await requestTrackingAuthorization() + } + return true + } + + /// 비동기 추적 권한 요청 함수 + private func requestTrackingAuthorization() async { + // 0.5초 지연 후 추적 권한 요청 + do { + try await Task.sleep(nanoseconds: 500_000_000) // 0.5초 = 500,000,000 나노초 + } catch { + print(error) + } + + if ATTrackingManager.trackingAuthorizationStatus == .notDetermined { + let _ = await ATTrackingManager.requestTrackingAuthorization() + } } } diff --git a/FiveGuyes/FiveGuyes/Info.plist b/FiveGuyes/FiveGuyes/Info.plist index 9161cd4..ec8a59e 100644 --- a/FiveGuyes/FiveGuyes/Info.plist +++ b/FiveGuyes/FiveGuyes/Info.plist @@ -6,10 +6,13 @@ $(API_KEY) FirebaseAutomaticScreenReportingEnabled - GOOGLE_ANALYTICS_REGISTRATION_WITH_AD_NETWORK_ENABLED - - ITSAppUsesNonExemptEncryption - + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + NSAllowsArbitraryLoadsInWebContent + + UIAppFonts Pretendard-Regular.otf