-
Notifications
You must be signed in to change notification settings - Fork 0
/
AppMonetManager.swift
58 lines (45 loc) · 1.52 KB
/
AppMonetManager.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//
// AppMonetManager.swift
// Flame
//
// Created by Jose Portocarrero on 9/9/20.
// Copyright © 2020 Monet. All rights reserved.
//
import Foundation
import AppMonet_Bidder
import GoogleMobileAds
struct Constants {
static let kCpmKey = "__bid_cpm__";
static let kIdKey = "__bid_id__";
}
class AppMonetManager: NSObject {
@objc let adView = AMAppMonetAdView(adUnitId: "test_banner", size: MONET_MEDIUM_RECT_SIZE);
@objc let interstitial: AMInterstitialAdController = AMInterstitialAdController(forAdUnitId: "test_interstitial");
static let _singletonInstance = AppMonetManager()
private override init() {
}
@objc class func sharedInstance() -> AppMonetManager {
AppMonetManager._singletonInstance
}
@objc func cleanInterstitial() {
interstitial.delegate = nil
}
@objc func cleanBanner() {
adView?.delegate = nil
}
func createDFPRequest(bid: AMMonetBid) -> DFPRequest {
let dfpRequest = DFPRequest()
dfpRequest.customTargeting = ["mm_cpm": bid.cpm.stringValue, "mm_10": (round(bid.cpm.doubleValue * 10)) / 10.00]
let extras = GADCustomEventExtras()
extras.setExtras([Constants.kIdKey: bid.id!, Constants.kCpmKey: bid.cpm.stringValue], forLabel: "appmonet")
dfpRequest.register(extras)
NSLog("bid id: %@", bid.id)
return dfpRequest
}
@objc class func bidCpmKey() -> String {
Constants.kCpmKey
}
@objc class func bidIdKey() -> String {
Constants.kIdKey
}
}