Giter VIP home page Giter VIP logo

swiftuimobileads's Introduction

SwiftUIMobileAds

swiftuimobileads's People

Contributors

muradium avatar patrickhaertel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

swiftuimobileads's Issues

Reward Fullscreen View not showing when on iOS 15 and above.

Hi there,

Just added the functionality to my App, the only thing is that it appears like the Reward Ad won't show up when using:

func makeUIViewController(context: Context) -> UIViewController
{

    let view = UIViewController()
    
    DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(1)) {
        self.showAd(from: view)
    }
    
    return view
}

Change this code to:

func makeUIViewController(context: Context) -> UIViewController
{

    let view = UIViewController()
    
    DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(1)) {
        self.showAd(from: (UIApplication.shared.windows.first?.rootViewController)!)
    }
    
    return view
}

Thanks for taking the time on doing this project about Google Ads on SwiftUI!

cant build

dyld: Library not loaded: @rpath/FBLPromises.framework/FBLPromises

windows' was deprecated in iOS 15.0: Use UIWindowScene.windows on a relevant window scene instead

First, thanks for this code. It's great and has been a great help.

In new releases there's a new warning in the build:

func setFrame() {

This line has this warning: 'windows' was deprecated in iOS 15.0: Use UIWindowScene.windows on a relevant window scene instead:
let safeAreaInsets = UIApplication.shared.windows.first(where: { $0.isKeyWindow })?.safeAreaInsets ?? .zero
let frame = UIScreen.main.bounds.inset(by: safeAreaInsets)

    let adSize = GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(frame.width)
    
    self.width = adSize.size.width
    self.height = adSize.size.height
}

After a lot of research I didn't find a clear answer. I fixed it with:

func getSafeArea()-> UIEdgeInsets {

    let keyWindow = UIApplication
        .shared
        .connectedScenes
        .flatMap { ($0 as? UIWindowScene)?.windows ?? [] }
        .first { $0.isKeyWindow }
    
    return (keyWindow?.safeAreaInsets)!
}

func setFrame() {
    
     let safeAreaInsets = getSafeArea()
    let frame = UIScreen.main.bounds.inset(by: safeAreaInsets)
    
    let adSize = GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(frame.width)
    
    self.width = adSize.size.width
    self.height = adSize.size.height
     
}

This fixes the warning and seems to mostly work, but I get a few crashes in getSafeArea() with an unwrapped nil error. I can see why that would be, but since you actually know what you're doing, I'm just wondering if there's a better fix?

thanks

more ads libs

Hi and thank you for your great work and tutorial!

I wanted to ask if there is any possibility you will also demonstrate how to implement other ads libs such as IronSource or AppLovin with swiftUI?

since there is no documentation nor other tutorials on the web at all on how to integrate those libs with swiftui, only with old swift which is completely different implementation and off course doesn't work :

thanks again for your work!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.