【发布时间】:2021-01-23 06:45:33
【问题描述】:
当我开始游戏时,我尝试从 admob 加载奖励视频广告。我的问题是,我需要检查用户是否建立了互联网连接,以便采取相应的措施,主要是显示/隐藏游戏对象和文本。我在Start() 方法中使用了这段代码:
if (Application.internetReachability != NetworkReachability.NotReachable)
但这并不总是可靠的,而且很多时候该陈述是错误的,即使我通过 Wi-Fi 连接。几秒钟后,连接建立,我可以继续,但我想找到一种方法来避免这个问题。那么有没有更好的方法来检查连接,甚至是异步的,比如在加载主菜单时检查?
【问题讨论】:
-
Application.internetReachabilityNote: Do not use this property to determine the actual connectivity. E.g. the device can be connected to a hot spot, but not have the actual route to the network.