Skip to content

Commit

Permalink
feat: #71 Add App Tracking Transparency permission request
Browse files Browse the repository at this point in the history
  • Loading branch information
zaehorang committed Nov 23, 2024
1 parent f9cc9da commit 3bbf7f6
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 7 deletions.
2 changes: 2 additions & 0 deletions FiveGuyes/FiveGuyes.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
30 changes: 27 additions & 3 deletions FiveGuyes/FiveGuyes/FiveGuyesApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// Created by zaehorang on 10/3/24.
//

import AdSupport
import AppTrackingTransparency
import SwiftData
import SwiftUI

Expand All @@ -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()
}
}
}
11 changes: 7 additions & 4 deletions FiveGuyes/FiveGuyes/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
<string>$(API_KEY)</string>
<key>FirebaseAutomaticScreenReportingEnabled</key>
<false/>
<key>GOOGLE_ANALYTICS_REGISTRATION_WITH_AD_NETWORK_ENABLED</key>
<false/>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSAllowsArbitraryLoadsInWebContent</key>
<true/>
</dict>
<key>UIAppFonts</key>
<array>
<string>Pretendard-Regular.otf</string>
Expand Down

0 comments on commit 3bbf7f6

Please sign in to comment.