You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Explain Info.plist key must match enum rawValue
- Add SwiftUI window initialization example
- Explain needToWait parameter
- Add import GoogleMobileAds note for rewarded
- Add guidance on when to call prepare/show
- Clarify delegate responsibility for throttling persistence
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: README.md
+34-11Lines changed: 34 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,9 @@ A Swift library for managing Google Mobile Ads with time-based throttling and li
17
17
18
18
## Setup
19
19
20
-
Add your ad unit IDs to `Info.plist` under the key `GADUnitIdentifiers` as a `[String: String]` dictionary:
20
+
### 1. Info.plist
21
+
22
+
Add your ad unit IDs under the key `GADUnitIdentifiers` as a `[String: String]` dictionary. The keys must exactly match your enum's `rawValue`s.
21
23
22
24
```xml
23
25
<key>GADUnitIdentifiers</key>
@@ -31,7 +33,7 @@ Add your ad unit IDs to `Info.plist` under the key `GADUnitIdentifiers` as a `[S
31
33
</dict>
32
34
```
33
35
34
-
Define an enum for your ad units:
36
+
### 2. Define your ad units
35
37
36
38
```swift
37
39
enumAdUnit: String{
@@ -41,38 +43,54 @@ enum AdUnit: String {
41
43
}
42
44
```
43
45
44
-
##Usage
46
+
### 3. Initialize
45
47
46
-
### Initialization
48
+
Create the manager and assign a delegate. Call this early — typically in `AppDelegate.application(_:didFinishLaunchingWithOptions:)` or your app's root scene setup.
47
49
48
50
```swift
51
+
// UIKit
49
52
let adManager = GADManager<AdUnit>(window)
50
53
adManager.delegate=self
54
+
55
+
// SwiftUI
56
+
let adManager = GADManager<AdUnit>(UIApplication.shared.connectedScenes
57
+
.compactMap { ($0as? UIWindowScene)?.keyWindow }
58
+
.first!)
59
+
adManager.delegate=self
51
60
```
52
61
62
+
## Usage
63
+
64
+
Call `prepare` early to preload the ad. Call `show` when you want to display it.
0 commit comments