An open API service indexing awesome lists of open source software.

https://github.com/kc-2001ms/advertisementsui

Framework for displaying ads using SwiftUI
https://github.com/kc-2001ms/advertisementsui

Last synced: about 1 month ago
JSON representation

Framework for displaying ads using SwiftUI

Awesome Lists containing this project

README

          

# AdvertisementsUI

Framework for displaying ads using SwiftUI

## Description

With this library, you can display ads with simple SwiftUI code.
It will support AppLovin as well as Admob.

## Requirement

The following environment is required to use this library.






Twitter: @IroIro1234work

## Demo
To verify the operation of this library, I created a sample application in the library. Please refer to it.

## Usage
Basically, the following methods are used to display the information.
### 1. Preparation
``` swift
import SwiftUI
import AdMobUI

@main
struct SampleApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
.admobContainer()
}
}
```
### 2. Display
#### Banner
``` swift
import SwiftUI
import AdMobUI

struct ContentView: View {
var body: some View {
NavigationStack {
AdBannerCard()
}
}
}
```
#### Native
``` swift
import SwiftUI
import AdMobUI

struct ContentView: View {
var body: some View {
NavigationStack {
List {
Section {
NativeAdCard()
} header: {
Text("Google Admob")
}
}
.navigationTitle("Sample")
}
}
}
```
#### Interstitial
``` swift
import SwiftUI
import AdMobUI

struct ContentView: View {
@State private var isOpeningInterstitialAd = false

var body: some View {
NavigationStack {
List {
Section {
Button {
isOpeningInterstitialAd.toggle()
} label: {
Text("Show Interstitial Ad")
}
} header: {
Text("Google Admob")
}
}
.navigationTitle("Sample")
}
.interstitialAdSheet(isPresented: $isOpeningInterstitialAd)
}
}
```
#### Reworded
``` swift
import SwiftUI
import AdMobUI

struct ContentView: View {
@State private var isOpeningRewordedAd = false

@State private var rewordedCount = 0

var body: some View {
NavigationStack {
List {
Section {
GroupBox {
Button {
isOpeningRewordedAd.toggle()
} label: {
Text("Show Reworded Ad")
}
} label: {
LabeledContent("Reworded Count", value: rewordedCount, format: .number)
}
.listRowInsets(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 0))
.padding(5)
.backgroundStyle(.clear)
} header: {
Text("Google Admob")
}
}
.navigationTitle("Sample")
}
.rewardedAdSheet(isPresented: $isOpeningRewordedAd) {
rewordedCount += 1
}
}
}
```
#### Reworded Interstitial
``` swift
import SwiftUI
import AdMobUI

struct ContentView: View {
@State private var isOpeningRewordedInterstitialAd = false

@State private var rewordedInterstitialCount = 0

var body: some View {
NavigationStack {
List {
Section {
GroupBox {
Button {
isOpeningRewordedInterstitialAd.toggle()
} label: {
Text("Show Reworded Interstitial Ad")
}
} label: {
LabeledContent("Reworded Interstitial Count", value: rewordedInterstitialCount, format: .number)
}
.listRowInsets(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 0))
.padding(5)
.backgroundStyle(.clear)
} header: {
Text("Google Admob")
}
}
.navigationTitle("Sample")
}
.rewardedInterstitialAdSheet(isPresented: $isOpeningRewordedInterstitialAd) {
rewordedInterstitialCount += 1
}
}
}
```

## Install

AdvertisementsUI comes with two different frameworks.
Each framework has a different configuration method.

### AdMobUI
1. [Adding package dependencies to your app](https://developer.apple.com/documentation/xcode/adding-package-dependencies-to-your-app)
2. Add the following to info.plist
```plist
NSUserTrackingUsageDescription
{some reason}
SKAdNetworkItems


SKAdNetworkIdentifier
cstr6suwn9.skadnetwork


SKAdNetworkIdentifier
4fzdc2evr5.skadnetwork


SKAdNetworkIdentifier
2fnua5tdw4.skadnetwork


SKAdNetworkIdentifier
ydx93a7ass.skadnetwork


SKAdNetworkIdentifier
p78axxw29g.skadnetwork


SKAdNetworkIdentifier
v72qych5uu.skadnetwork


SKAdNetworkIdentifier
ludvb6z3bs.skadnetwork


SKAdNetworkIdentifier
cp8zw746q7.skadnetwork


SKAdNetworkIdentifier
3sh42y64q3.skadnetwork


SKAdNetworkIdentifier
c6k4g5qg8m.skadnetwork


SKAdNetworkIdentifier
s39g8k73mm.skadnetwork


SKAdNetworkIdentifier
3qy4746246.skadnetwork


SKAdNetworkIdentifier
hs6bdukanm.skadnetwork


SKAdNetworkIdentifier
mlmmfzh3r3.skadnetwork


SKAdNetworkIdentifier
v4nxqhlyqp.skadnetwork


SKAdNetworkIdentifier
wzmmz9fp6w.skadnetwork


SKAdNetworkIdentifier
su67r6k2v3.skadnetwork


SKAdNetworkIdentifier
yclnxrl5pm.skadnetwork


SKAdNetworkIdentifier
7ug5zh24hu.skadnetwork


SKAdNetworkIdentifier
gta9lk7p23.skadnetwork


SKAdNetworkIdentifier
vutu7akeur.skadnetwork


SKAdNetworkIdentifier
y5ghdn5j9k.skadnetwork


SKAdNetworkIdentifier
v9wttpbfk9.skadnetwork


SKAdNetworkIdentifier
n38lu8286q.skadnetwork


SKAdNetworkIdentifier
47vhws6wlr.skadnetwork


SKAdNetworkIdentifier
kbd757ywx3.skadnetwork


SKAdNetworkIdentifier
9t245vhmpl.skadnetwork


SKAdNetworkIdentifier
a2p9lx4jpn.skadnetwork


SKAdNetworkIdentifier
22mmun2rn5.skadnetwork


SKAdNetworkIdentifier
4468km3ulz.skadnetwork


SKAdNetworkIdentifier
2u9pt9hc89.skadnetwork


SKAdNetworkIdentifier
8s468mfl3y.skadnetwork


SKAdNetworkIdentifier
ppxm28t8ap.skadnetwork


SKAdNetworkIdentifier
uw77j35x4d.skadnetwork


SKAdNetworkIdentifier
pwa73g5rt2.skadnetwork


SKAdNetworkIdentifier
578prtvx9j.skadnetwork


SKAdNetworkIdentifier
4dzt52r2t5.skadnetwork


SKAdNetworkIdentifier
tl55sbb4fm.skadnetwork


SKAdNetworkIdentifier
e5fvkxwrpn.skadnetwork


SKAdNetworkIdentifier
8c4e2ghe7u.skadnetwork


SKAdNetworkIdentifier
3rd42ekr43.skadnetwork


SKAdNetworkIdentifier
3qcr597p9d.skadnetwork


GADIsAdManagerApp

```
3. Add the following to info.plist
The values of the keys in the AdUnitIDs dictionary are the following keys if not specified in the Swift code.
If specified, custom keys can be used.

```plist
GADApplicationIdentifier
{some identifier}
AdUnitIDs

Banner
{some identifier}
Interstitial
{some identifier}
Native
{some identifier}
Rewarded
{some identifier}
RewardedInterstitial
{some identifier}

```
4. Add code
See demo for details

## Contribution
See [CONTRIBUTING.md](https://github.com/KC-2001MS/AdvertisementsUI/blob/main/CONTRIBUTING.md) if you want to make a contribution.

## Licence
[AdvertisementsUI](https://github.com/KC-2001MS/AdvertisementsUI/blob/main/LICENSE)

## Dependencies
This project depends on the following Apache-2.0 licensed libraries:

- **GogleMobileAds** (Version 12.0.0) - [License](LICENSES/GogleMobileAds_LICENSE)
- **GoogleUserMessagingPlatform** (Version 2.7.0) - [License](LICENSES/GoogleUserMessagingPlatform_LICENSE)
- **SwiftDocCPlugin** (Version 1.4.3) - [License](LICENSES/SwiftDocCPlugin_LICENSE)
- **SymbolKit** (Version 1.0.0) - [License](LICENSES/SymbolKit_LICENSE)

## Supporting

If you would like to make a donation to this project, please click here. The money you give will be used to improve my programming skills and maintain the application.

Buy Me A Coffee

[Pay by PayPal](https://paypal.me/iroiroWork?country.x=JP&locale.x=ja_JP)

## Author

[Keisuke Chinone](https://github.com/KC-2001MS)