'How to Implement UnityAds in Swift Without Admob

I'm trying to show a rewarded ad in my SwiftUI app. The existing implementations are either old or vague. This is my SwiftUI view:

struct WalletView: View{
    // properties
    
    init() {
        UnityAds.initialize("gameId", testMode: false)
        UnityAds.load("Rewarded_iOS")
    }
    
    func loadAd() {
        UnityAds.show(self, placementId: "Rewarded_iOS", showDelegate: nil)
    }
    
    var body: some View {
        VStack{
          //code
        }
    }
}

This code throws Cannot convert value to expected argument type 'UIViewController': Error

What can I do?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source