Skip to content

Commit f61b57c

Browse files
Compatibility with Equativ Display SDK 8.1.0 and Smart Display SDK 7.24.0
1 parent 3eada1b commit f61b57c

12 files changed

+425
-42
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
build/
77
DerivedData/
88

9+
**/**/.DS_STORE
10+
911
## Various settings
1012
*.pbxuser
1113
!default.pbxuser

README.md

Lines changed: 7 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,18 @@
1-
Smart AdServer - Google Mobile Ads SDK Adapter
1+
Equativ - Google Mobile Ads SDK Adapter
22
==============================================
33

44
Introduction
55
------------
6-
The _Smart Display SDK_ can be used through _Google Mobile Ads SDK_ using the adapter provided in this repository for banner, interstitial and rewarded video. Those adapters are compatible with:
7-
* _Smart Display SDK_ v7.21+
8-
* _Google Mobile Ads SDK_ v11.5.0
6+
The _Equativ Display SDK_ can be used through _Google Mobile Ads_ using the adapters provided in this repository.
97

108
Setup
119
-----
1210

13-
1) Install the _Google Mobile Ads SDK_ according to the official documentation https://developers.google.com/admob/ios/download.
14-
15-
2) Install the _Smart Display SDK_ by adding the _pod_ `Smart-Display-SDK` to your app _Podfile_ (more info in [the documentation](https://documentation.smartadserver.com/displaySDK/ios/gettingstarted.html)).
16-
17-
3) Checkout this repository and copy the files you need into your Xcode Project:
18-
19-
- `SASGMAUtils` in any cases.
20-
- `SASGMABannerAdapter` for banner ads.
21-
- `SASGMAInterstitialAdapter` for interstitial ads.
22-
- `SASGMARewardedAdapter` for rewarded video ads.
23-
- `SASGMANativeAdapter` for native ads ads.
24-
25-
4) You can now declare _SDK Mediation Creatives_ in the _Google Mobile Ads_ interface. To setup the _Custom Event_ (under _Ad networks_), you need to fill:
26-
27-
- the _Parameter_ field: set your _Smart AdServer_ IDs using slash separator `[siteID]/[pageID]/[formatID]`
28-
- the _Class Name_ field: set `SASGMABannerAdapter` for banners, `SASGMAInterstitialAdapter` for interstitials or `SASGMARewardedAdapter` for rewarded videos.
29-
30-
5) If you intend to use keyword targeting in your Smart insertions, typically if you want it to match any custom targeting you have set-up on Google Ad Manager interface, you will need to set it on Google ad requests in your application.
31-
32-
For Banner, Interstitial and Native-Ad, this is done by using `GADRequest`'s `keywords` attribut. For instance, for banner case, if your smart insertion uses "myCustomBannerTargeting" string on any Smart programmed banner insertion:
33-
```
34-
let request = GADRequest()
35-
request.keywords = ["myCustomBannerTargeting", "and", "additional", "keywords"]
36-
bannerView.load(request)
37-
```
38-
39-
For Rewarded Video, this is done by registering extra on `GADRequest` instance using our `SASGMAAdNetworkExtra` class. For instance, if your smart insertion uses "myCustomTargeting" string on any Smart programmed rewarded video insertion:
40-
```
41-
let request = GADRequest()
42-
request.register(SASGMAAdNetworkExtra(keywords: ["myCustomTargeting", "and", "additional", "keywords"]))
43-
GADRewardedAd.load(withAdUnitID: "yourAddUnitID", request: request)
44-
```
45-
46-
As you can see, in both solution you can set-up multiples keywords, they will be concatenated before making the ad call via _Smart Display SDK_.
47-
11+
If you are using _Smart Display SDK_ v7.x, please follow the instruction in the `displaysdk7` folder.
12+
If you are using _Equativ Display SDK_ v8.x, please follow the instruction in the `displaysdk8` folder.
4813

4914
More infos
5015
----------
51-
You can find more informations about the _Smart Display SDK_ and the _Google Mobile Ads SDK_ in the official documentation:
52-
https://documentation.smartadserver.com/displaySDK
16+
You can find more informations about the _Equativ Display SDK_ and the _Google Mobile Ads_ in the official documentation:
17+
18+
https://documentation.smartadserver.com/displaySDK

displaysdk7/README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
Smart AdServer - Google Mobile Ads SDK Adapter
2+
==============================================
3+
4+
Introduction
5+
------------
6+
The _Smart Display SDK_ can be used through _Google Mobile Ads SDK_ using the adapter provided in this repository for banner, interstitial and rewarded video. Those adapters are compatible with:
7+
* _Smart Display SDK_ v7.21+
8+
* _Google Mobile Ads SDK_ v11.5.0
9+
10+
Setup
11+
-----
12+
13+
1) Install the _Google Mobile Ads SDK_ according to the official documentation https://developers.google.com/admob/ios/download.
14+
15+
2) Install the _Smart Display SDK_ by adding the _pod_ `Smart-Display-SDK` to your app _Podfile_ (more info in [the documentation](https://documentation.smartadserver.com/displaySDK/ios/gettingstarted.html)).
16+
17+
3) Checkout this repository and copy the files you need into your Xcode Project:
18+
19+
- `SASGMAUtils` in any cases.
20+
- `SASGMABannerAdapter` for banner ads.
21+
- `SASGMAInterstitialAdapter` for interstitial ads.
22+
- `SASGMARewardedAdapter` for rewarded video ads.
23+
- `SASGMANativeAdapter` for native ads ads.
24+
25+
4) You can now declare _SDK Mediation Creatives_ in the _Google Mobile Ads_ interface. To setup the _Custom Event_ (under _Ad networks_), you need to fill:
26+
27+
- the _Parameter_ field: set your _Smart AdServer_ IDs using slash separator `[siteID]/[pageID]/[formatID]`
28+
- the _Class Name_ field: set `SASGMABannerAdapter` for banners, `SASGMAInterstitialAdapter` for interstitials or `SASGMARewardedAdapter` for rewarded videos.
29+
30+
5) If you intend to use keyword targeting in your Smart insertions, typically if you want it to match any custom targeting you have set-up on Google Ad Manager interface, you will need to set it on Google ad requests in your application.
31+
32+
For Banner, Interstitial and Native-Ad, this is done by using `GADRequest`'s `keywords` attribut. For instance, for banner case, if your smart insertion uses "myCustomBannerTargeting" string on any Smart programmed banner insertion:
33+
```
34+
let request = GADRequest()
35+
request.keywords = ["myCustomBannerTargeting", "and", "additional", "keywords"]
36+
bannerView.load(request)
37+
```
38+
39+
For Rewarded Video, this is done by registering extra on `GADRequest` instance using our `SASGMAAdNetworkExtra` class. For instance, if your smart insertion uses "myCustomTargeting" string on any Smart programmed rewarded video insertion:
40+
```
41+
let request = GADRequest()
42+
request.register(SASGMAAdNetworkExtra(keywords: ["myCustomTargeting", "and", "additional", "keywords"]))
43+
GADRewardedAd.load(withAdUnitID: "yourAddUnitID", request: request)
44+
```
45+
46+
As you can see, in both solution you can set-up multiples keywords, they will be concatenated before making the ad call via _Smart Display SDK_.
47+
48+
49+
More infos
50+
----------
51+
You can find more informations about the _Smart Display SDK_ and the _Google Mobile Ads SDK_ in the official documentation:
52+
https://documentation.smartadserver.com/displaySDK
File renamed without changes.
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ class SASGMAAdNetworkExtras: NSObject, GADAdNetworkExtras {
2121

2222
class SASGMAUtils {
2323

24+
static let SASImplementationInfo_PrimarySDKName = "GoogleMobileAds"
25+
static let SASImplementationInfo_MediationAdapterVersion = "1.1.0"
26+
2427
static private let customEventServerSeparatorString = "/"
2528

2629
static let kSASGMAErrorDomain = "kSASGMAErrorDomain"
@@ -81,7 +84,9 @@ class SASGMAUtils {
8184

8285
// Configure the Smart Display SDK
8386
SASConfiguration.shared.configure(siteId: siteId)
84-
SASConfiguration.shared.primarySDK = false
87+
SASConfiguration.shared.secondaryImplementationInfo = SASSecondaryImplementationInfo(primarySDKName: SASImplementationInfo_PrimarySDKName,
88+
primarySDKVersion: GADGetStringFromVersionNumber(GADMobileAds.sharedInstance().versionNumber),
89+
mediationAdapterVersion: SASImplementationInfo_MediationAdapterVersion)
8590

8691
// Ad placement instantiation
8792
return SASAdPlacement(siteId: siteId, pageName: pageId!, formatId: formatId, keywordTargeting: targetingString)

displaysdk8/README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
Equativ - Google Mobile Ads SDK Adapter
2+
==============================================
3+
4+
Introduction
5+
------------
6+
The _Equativ Display SDK_ can be used through _Google Mobile Ads SDK_ using the adapter provided in this repository for banner and interstitial. Those adapters are compatible with:
7+
* _Equativ Display SDK_ v8.0+
8+
* _Google Mobile Ads SDK_ v11.5.0
9+
10+
Setup
11+
-----
12+
13+
1) Install the _Google Mobile Ads SDK_ according to the official documentation https://developers.google.com/admob/ios/download.
14+
15+
2) Install the _Equativ Display SDK_ by adding the _pod_ `Equativ-Display-SDK` to your app _Podfile_ (more info in [the documentation](https://documentation.smartadserver.com/displaySDK/ios/gettingstarted.html)).
16+
17+
3) Checkout this repository and copy the files you need into your Xcode Project:
18+
19+
- `SASGMAUtils` in any cases.
20+
- `SASGMABannerAdapter` for banner ads.
21+
- `SASGMAInterstitialAdapter` for interstitial ads.
22+
23+
4) You can now declare _SDK Mediation Creatives_ in the _Google Mobile Ads_ interface. To setup the _Custom Event_ (under _Ad networks_), you need to fill:
24+
25+
- the _Parameter_ field: set your _Smart AdServer_ IDs using slash separator `[siteID]/[pageID]/[formatID]`
26+
- the _Class Name_ field: set `SASGMABannerAdapter` for banners or `SASGMAInterstitialAdapter` for interstitials.
27+
28+
5) If you intend to use keyword targeting in your Smart insertions, typically if you want it to match any custom targeting you have set-up on Google Ad Manager interface, you will need to set it on Google ad requests in your application.
29+
30+
For Banner and Interstitial, this is done by using `GADRequest`'s `keywords` attribut. For instance, for banner case, if your Equativ insertion uses "myCustomBannerTargeting" string on any Equativ programmed banner insertion:
31+
```
32+
let request = GADRequest()
33+
request.keywords = ["myCustomBannerTargeting", "and", "additional", "keywords"]
34+
bannerView.load(request)
35+
```
36+
37+
As you can see, you can set-up multiples keywords, they will be concatenated before making the ad call via _Equativ Display SDK_.
38+
39+
40+
More infos
41+
----------
42+
You can find more informations about the _Equativ Display SDK_ and the _Google Mobile Ads SDK_ in the official documentation:
43+
https://documentation.smartadserver.com/displaySDK
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
//
2+
// SASGMABannerAdapter.swift
3+
// Adapter for Google Mobile Ad Mediation
4+
//
5+
// Created by Guillaume Laubier on 22/01/2024.
6+
//
7+
8+
import Foundation
9+
import SASDisplayKit
10+
import GoogleMobileAds
11+
12+
@objc(SASGMABannerAdapter)
13+
class SASGMABannerAdapter : NSObject, GADMediationAdapter, GADMediationBannerAd, SASBannerViewDelegate {
14+
var view: UIView
15+
private var loadCompletionHandler: GADMediationBannerLoadCompletionHandler?
16+
private var delegate: GADMediationBannerAdEventDelegate?
17+
18+
required override init() {
19+
view = SASBannerView(frame: CGRect.zero) as UIView
20+
}
21+
22+
static func adapterVersion() -> GADVersionNumber {
23+
return SASGMAUtils.adapterVersion()
24+
}
25+
26+
static func adSDKVersion() -> GADVersionNumber {
27+
return SASGMAUtils.adSDKVersion()
28+
}
29+
30+
static func networkExtrasClass() -> GADAdNetworkExtras.Type? {
31+
return SASGMAAdNetworkExtras.self
32+
}
33+
34+
func loadBanner(for adConfiguration: GADMediationBannerAdConfiguration, completionHandler: @escaping GADMediationBannerLoadCompletionHandler) {
35+
guard let placement = SASGMAUtils.placementWith(adConfiguration: adConfiguration) else {
36+
// Placement is invalid, sending an error
37+
let error = NSError(domain: SASGMAUtils.kSASGMAErrorDomain, code: SASGMAUtils.kSASGMAErrorCodeInvalidServerParameters, userInfo: nil)
38+
_ = completionHandler(nil, error)
39+
return
40+
}
41+
42+
loadCompletionHandler = completionHandler
43+
44+
if let bannerView = view as? SASBannerView {
45+
bannerView.frame = CGRect(x: 0, y: 0, width: adConfiguration.adSize.size.width, height: adConfiguration.adSize.size.height)
46+
bannerView.modalParentViewController = adConfiguration.topViewController
47+
bannerView.delegate = self
48+
49+
// Load the banner ad
50+
bannerView.loadAd(with: placement)
51+
}
52+
}
53+
54+
// Pragma - SASBannerViewDelegate implementation
55+
56+
func bannerView(_ bannerView: SASBannerView, didLoadWith adInfo: SASAdInfo) {
57+
delegate = loadCompletionHandler?(self, nil)
58+
self.delegate?.reportImpression()
59+
}
60+
61+
func bannerView(_ bannerView: SASBannerView, didFailToLoad error: Error) {
62+
_ = loadCompletionHandler?(nil, error)
63+
}
64+
65+
func bannerView(_ bannerView: SASBannerView, didClickWith URL: URL) {
66+
delegate?.reportClick()
67+
}
68+
69+
func bannerViewWillPresentModalView(_ bannerView: SASBannerView) {
70+
delegate?.willPresentFullScreenView()
71+
}
72+
73+
func bannerViewWillDismissModalView(_ bannerView: SASBannerView) {
74+
delegate?.willDismissFullScreenView()
75+
}
76+
77+
func bannerViewDidRequestClose(_ bannerView: SASBannerView) {
78+
// Nothing to do
79+
}
80+
}

0 commit comments

Comments
 (0)