Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion GADManager/GADManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public class GADManager<E : RawRepresentable> : 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;
Expand All @@ -146,6 +146,17 @@ public class GADManager<E : RawRepresentable> : 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){
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading