Post

Replies

Boosts

Views

Activity

Reply to How to get the UIViewController instance for displaying dialog when the app starts up?
Hi OOper, Thank you for your suggestion about using Life Cycle as UIKit App Delegate. I will try it. On another hand, I found a way to get a UIViewController object from ContentView.swift file, like the code below. Is this solution Ok? or there will be issue? Thank you! import SwiftUI import MoPubSDK struct ContentView: View {     var body: some View {         return         Text("Hello, world!")             .padding()             .onAppear(){                 // for MoPub: Check whether you must show the consent dialog                 let shouldShow = MoPub.sharedInstance().shouldShowConsentDialog;                 // for MoPub: Start loading the consent dialog. This call fails if the user has opted out of ad personalization                 let myUIViewController : UIViewController = (UIApplication.shared.windows.first?.rootViewController)!                 MoPub.sharedInstance().loadConsentDialog(){ a in                     MoPub.sharedInstance().showConsentDialog(from: myUIViewController, completion: nil)                 }             }     } }
Topic: UI Frameworks SubTopic: UIKit Tags:
Aug ’21
Reply to Is there a way to pretend IP address in Xcode Device Simulator?
Thank you Claude! I changed the IP address of my Mac manually for testing the app. Even though I didn't get the expected result (seeing the popup message), but I think your answer has got to the bottom of the specific question I asked.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to Xcode: Why I need #available(iOS 14.0, *) even if the project iOS Deployment Target is 14.1?
Hi Claude31, OOPer, Thank you for pointing out what I missed. I check the individual targets and found the "iOS Deployment Target". After updating each of them to iOS 14.1, I can delete the unnecessary code now.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to How to get the UIViewController instance for displaying dialog when the app starts up?
Hi OOper, For the "UIKit App Delegate" option of Life Cycle, I found it is only available if I chose "iOS" App template for the new project. If I chose "Multiplatform" template, then there is no Life Cycle choices for me to select. Thank you!
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to How to get the UIViewController instance for displaying dialog when the app starts up?
Hi OOper, Thank you for your suggestion about using Life Cycle as UIKit App Delegate. I will try it. On another hand, I found a way to get a UIViewController object from ContentView.swift file, like the code below. Is this solution Ok? or there will be issue? Thank you! import SwiftUI import MoPubSDK struct ContentView: View {     var body: some View {         return         Text("Hello, world!")             .padding()             .onAppear(){                 // for MoPub: Check whether you must show the consent dialog                 let shouldShow = MoPub.sharedInstance().shouldShowConsentDialog;                 // for MoPub: Start loading the consent dialog. This call fails if the user has opted out of ad personalization                 let myUIViewController : UIViewController = (UIApplication.shared.windows.first?.rootViewController)!                 MoPub.sharedInstance().loadConsentDialog(){ a in                     MoPub.sharedInstance().showConsentDialog(from: myUIViewController, completion: nil)                 }             }     } }
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Aug ’21