@@ -21,29 +21,29 @@ class SyncWebViewGoogleAdView: NSObject, WebViewHelperDelegate {
2121 var bannerSize : GADAdSize
2222
2323 public init ( webView: WKWebView , selector: String , admobBannerView: GADBannerView , bannerSize: GADAdSize ) {
24- self . webViewHelper = WebViewHelper ( webView: webView, selector: selector)
24+ webViewHelper = WebViewHelper ( webView: webView, selector: selector)
2525 self . admobBannerView = admobBannerView
2626 self . webView = webView
2727 self . bannerSize = bannerSize
2828 super. init ( )
29- self . webViewHelper. delegate = self
29+ webViewHelper. delegate = self
3030 }
3131
3232 deinit {
33- self . webViewHelper. clean ( )
33+ webViewHelper. clean ( )
3434 }
3535
3636 public func injectJS( ) {
3737 //Inject the js in your webview when the webview is ready
38- self . webViewHelper. injectJS ( )
38+ webViewHelper. injectJS ( )
3939 }
4040
4141 // MARK: WebViewHelperDelegate
4242
4343 public func webViewHelperJSIsReady( ) {
44- self . webViewHelper. openSlot ( )
44+ webViewHelper. openSlot ( )
4545 // Landscape ads are 16/9, setting the ratio to 16/10 give more space to display the ads and result in a better looking square ads
46- self . webViewHelper. updateSlot ( adRatio: 16 / 10 )
46+ webViewHelper. updateSlot ( adRatio: 16 / 10 )
4747 }
4848 public func webViewHelperSlotStartToShow( ) {
4949
@@ -63,26 +63,26 @@ class SyncWebViewGoogleAdView: NSObject, WebViewHelperDelegate {
6363
6464 public func webViewHelperUpdatedSlot( left: Int , top: Int , right: Int , bottom: Int ) {
6565 // if the adView is not already loaded load it and add it to the scrollView of your webview
66- if let admobBannerView = self . admobBannerView, let webView = self . webView {
67- if !self . isLoaded {
68- self . isLoaded = true
66+ if let admobBannerView = admobBannerView, let webView = webView {
67+ if !isLoaded {
68+ isLoaded = true
6969 webView. scrollView. addSubview ( admobBannerView)
7070 admobBannerView. translatesAutoresizingMaskIntoConstraints = false
7171 }
7272 //change the constraint according to coordonate that the delegate send us
73- self . customAdViewConstraint ( left: left, top: top, right: right, bottom: bottom)
73+ customAdViewConstraint ( left: left, top: top, right: right, bottom: bottom)
7474 }
7575 }
7676
7777 /// change the constraint of the ad so it follows what the bootstrap ask
7878 func customAdViewConstraint( left: Int , top: Int , right: Int , bottom: Int ) {
79- if let admobBannerView = self . admobBannerView, let webView = self . webView {
80- NSLayoutConstraint . deactivate ( self . adViewConstraints)
81- self . adViewConstraints. removeAll ( )
82- self . adViewConstraints. append ( admobBannerView. leadingAnchor. constraint ( equalTo: webView. scrollView. leadingAnchor, constant: CGFloat ( left) ) )
83- self . adViewConstraints. append ( admobBannerView. topAnchor. constraint ( equalTo: webView. scrollView. topAnchor, constant: CGFloat ( top) ) )
84- self . adViewConstraints. append ( admobBannerView. widthAnchor. constraint ( equalToConstant: CGFloat ( right- left) ) )
85- NSLayoutConstraint . activate ( self . adViewConstraints)
79+ if let admobBannerView = admobBannerView, let webView = webView {
80+ NSLayoutConstraint . deactivate ( adViewConstraints)
81+ adViewConstraints. removeAll ( )
82+ adViewConstraints. append ( admobBannerView. leadingAnchor. constraint ( equalTo: webView. scrollView. leadingAnchor, constant: CGFloat ( left) ) )
83+ adViewConstraints. append ( admobBannerView. topAnchor. constraint ( equalTo: webView. scrollView. topAnchor, constant: CGFloat ( top) ) )
84+ adViewConstraints. append ( admobBannerView. widthAnchor. constraint ( equalToConstant: CGFloat ( right- left) ) )
85+ NSLayoutConstraint . activate ( adViewConstraints)
8686 }
8787 }
8888}
0 commit comments