Cannot call show method in UnityAds Using SwiftUi

141 Views Asked by At

I am trying to show unity ads in my ios project. I am using SwiftUI (Not AppDelegate, not Storyboard). There are not much examples on the web, and the little of them there are old and does not support showing ads with swiftui. Even the unity documentation website does not support it yet. please help me, I get this error from my show ads method and the code won't build: Cannot convert value of type 'UIViewController.Type' to expected argument type 'UIViewController'

import SwiftUI
import UnityAds

//Initialize Unity ads here
UnityAds.initialize("307659", testMode: true)

func loadInterstitial_UnityAds(){
    if UnityAds.isInitialized(){
        UnityAds.load("video")
    }
}
func showAds_Unity(){
    UnityAds.show(UIViewController, placementId:"307659", showDelegate: nil)
}
0

There are 0 best solutions below