Skip to content

Commit

Permalink
[Feature] Add documents
Browse files Browse the repository at this point in the history
  • Loading branch information
wayne90040 committed May 19, 2024
1 parent 1a895f8 commit 9ca5bf1
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 HSU WEI LUN

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
68 changes: 68 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# GoogleAds
This is a quick tutorial on using the Google Mobile Ads SDK with SwiftUI.

## Installation
### Swift Package Manager
```swift
dependencies: [
.package(url: "httpshttps://github.com/wayne90040/GoogleAds")
]
```

## Usage
#### Please refer to [Google's quick start guide](https://developers.google.com/admob/ios/quick-start?hl=zh-tw) to complete the preliminary `info.plist` setup.

#### Initialize the Mobile Ads SDK
```swift
@main
struct MainApp: App {
init() {
GoogleAds.register()
}

var body: some Scene {
...
}
}
```

#### Banner
```swift
AdsBanner(id: "ca-app-pub-3940256099942544/2934735716", size: .normal)
```

#### Interstitial
```swift

extension AdsInterstitial {
func loadAds() async {
do {
try await loadAds(id: "")
}
catch {
debugPrint("")
}
}
}

struct CreateView: View {
private let ads = AdsInterstitial()

var body: some View {
...
.onAppear {
Task {
await ads.loadAds(ads: "ca-app-pub-3940256099942544/4411468910")
}
}
}

private var nextPageButton: some View {
Button {
try? ads.showAd()
isNextPageActive.toggle()
} label: {
Text("Next Page")
}
}
```
12 changes: 12 additions & 0 deletions ReleaseNote.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Release Note

## 1.0.0

### Date

- 2024/05/19

### Features

- [Added] Banner Ads
- [Added] Interstitial Ads

0 comments on commit 9ca5bf1

Please sign in to comment.