75 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			Swift
		
	
	
			
		
		
	
	
			75 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			Swift
		
	
	
| // GuruBannerAd.swift
 | |
| // Base class for banner ad implementations
 | |
| // Corresponds to GuruBannerAd.kt in Android implementation
 | |
| 
 | |
| import Foundation
 | |
| import UIKit
 | |
| 
 | |
| public struct BannerShowRequest: Equatable {
 | |
|     public let placement: String?
 | |
|     public let position: BannerPosition?
 | |
|     public let offset: Float?
 | |
|     
 | |
|     public init(placement: String? = nil, position: BannerPosition? = nil, offset: Float? = nil) {
 | |
|         self.placement = placement
 | |
|         self.position = position
 | |
|         self.offset = offset
 | |
|     }
 | |
| }
 | |
| 
 | |
| open class GuruBannerAd: RelayAd {
 | |
|     public let adUnitId: String
 | |
|     public let adPlatform: AdPlatform
 | |
|     
 | |
|     private let name: String
 | |
|     
 | |
|     public let adType = AdType.Banner
 | |
|     
 | |
|     public init(engineId: Int, adUnitId: String, adPlatform: AdPlatform) {
 | |
|         self.adUnitId = adUnitId
 | |
|         self.adPlatform = adPlatform
 | |
|         self.name = "[BANNER-\(adPlatform)]"
 | |
|         super.init(engineId: engineId)
 | |
|     }
 | |
|     
 | |
|     // MARK: - Logging Methods
 | |
|     
 | |
|     public func logWarn(_ message: String) {
 | |
|         Logger.w(tag: "BANNER-\(adPlatform.name)[\(adUnitId)]", message: message)
 | |
|     }
 | |
|     
 | |
|     public func logDebug(_ message: String) {
 | |
|         Logger.d(tag: "BANNER-\(adPlatform.name)[\(adUnitId)]", message: message)
 | |
|     }
 | |
|     
 | |
|     public func logInfo(_ message: String) {
 | |
|         Logger.i(tag: "BANNER-\(adPlatform.name)[\(adUnitId)]", message: message)
 | |
|     }
 | |
|     
 | |
|     public func logError(_ message: String) {
 | |
|         Logger.e(tag: "BANNER-\(adPlatform.name)[\(adUnitId)]", message: message)
 | |
|     }
 | |
|     
 | |
|     // MARK: - Methods to override
 | |
|     
 | |
|     open func load() -> Bool {
 | |
|         fatalError("Subclass must implement")
 | |
|     }
 | |
|     
 | |
|     open func show(_ request: BannerShowRequest? = nil) -> Bool {
 | |
|         fatalError("Subclass must implement")
 | |
|     }
 | |
|     
 | |
|     open func hide() -> Bool {
 | |
|         fatalError("Subclass must implement")
 | |
|     }
 | |
|     
 | |
|     open func destroy() -> Bool {
 | |
|         fatalError("Subclass must implement")
 | |
|     }
 | |
|     
 | |
|     open func updateOrientation(orientation: ScreenOrientation) -> Bool {
 | |
|         fatalError("Subclass must implement")
 | |
|     }
 | |
| }
 |