Hi! iOS/MacOS developers,
I am trying to integrate a SDK to my iOS app, and I need to call a function provided by the SDK when the app starts running, to display a dialog.
My iOS app is developed with SwiftUI. For now, I attempt to add the code to the didFinishLaunchingWithOptions delegate of the AppDelegate.swift file, like the following:
import MoPubSDK
// ...
// Check whether you must show the consent dialog
MoPub.sharedInstance().shouldShowConsentDialog;
MoPub.sharedInstance().loadConsentDialog(){
a in MoPub.sharedInstance().showConsentDialog(
from: myUIViewController, completion: nil)}
However, I don't know how I can get the myUIViewController variable.
My questions are:
- how can I get a UIViewController instance when the app starts, such that I can pass it into the SDK function for dialog display?
- If it is not possible to do it in AppDelegate.swift, can it be done some where else?
Thank you!