diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..85eeeca --- /dev/null +++ b/LICENSE @@ -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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..29fb6a2 --- /dev/null +++ b/README.md @@ -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") + } + } +``` diff --git a/ReleaseNote.md b/ReleaseNote.md new file mode 100644 index 0000000..d029a6b --- /dev/null +++ b/ReleaseNote.md @@ -0,0 +1,12 @@ +# Release Note + +## 1.0.0 + +### Date + +- 2024/05/19 + +### Features + +- [Added] Banner Ads +- [Added] Interstitial Ads