From 1adb488746f1103ce130cf9ed77f292e6ce388cd Mon Sep 17 00:00:00 2001 From: leesam Date: Thu, 16 Jul 2026 11:03:09 +0900 Subject: [PATCH] feat: add async tracking permission API --- GADManager/GADManager.swift | 13 ++++++++++++- README.md | 9 +++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/GADManager/GADManager.swift b/GADManager/GADManager.swift index 4debaaa..f9f41e8 100644 --- a/GADManager/GADManager.swift +++ b/GADManager/GADManager.swift @@ -137,7 +137,7 @@ public class GADManager : NSObject, GoogleMobileAds.FullSc print("[\(#function)] Restricted") //show alert //showAlert(title: String, msg: String, actions : [UIAlertAction], style: UIAlertControllerStyle, sourceView: UIView? = nil, sourceRect: CGRect? = nil, popoverDelegate: UIPopoverPresentationControllerDelegate? = nil, completion: (() -> Void)? = nil) - return; + break; @unknown default: print("[\(#function)] Unknown") break; @@ -146,6 +146,17 @@ public class GADManager : NSObject, GoogleMobileAds.FullSc completion?(status); } } + + /// Requests App Tracking Transparency permission asynchronously and returns the resulting authorization status. + /// - Returns: The authorization status reported by `ATTrackingManager`. + @available(iOS 14, *) + public func requestPermissionAsync(viewControllerForAlert viewController: UIViewController? = nil, title: String? = nil, msg: String? = nil, cancel: String? = nil, settings: String? = nil) async -> ATTrackingManager.AuthorizationStatus { + await withCheckedContinuation { continuation in + requestPermission(viewControllerForAlert: viewController, title: title, msg: msg, cancel: cancel, settings: settings) { status in + continuation.resume(returning: status) + } + } + } #endif public func reset(unit: E){ diff --git a/README.md b/README.md index 5e41e16..b71efc8 100644 --- a/README.md +++ b/README.md @@ -126,6 +126,15 @@ if #available(iOS 14, *) { } ``` +With Swift concurrency: + +```swift +if #available(iOS 14, *) { + let status = await adManager.requestPermissionAsync() + adManager.prepare(interstitialUnit: .interstitial) +} +``` + ## Delegate The delegate is responsible for persisting the last-shown time per unit so throttling works correctly across app launches.