How to get Reachability Notifications in iOS in Background when dropping Wi-Fi network?

后端 未结 2 1506
南笙
南笙 2020-12-23 17:28

I\'m using Reachability successfully to determine the status of the network, and to be notified of changes (e.g. Reachability Guide for iOS 4).

My question isn\'t h

相关标签:
2条回答
  • 2020-12-23 17:52

    By default in the background state app stays for a short time only, most apps move to the suspended state shortly afterward. That mean the app is in the background but is not executing code. So your custom implemented notification do not work. Must requery NetworkReachability at Wakeup Time in app delegate methodes:

    applicationWillEnterForeground:
    applicationDidBecomeActive 
    
    0 讨论(0)
  • 2020-12-23 18:18

    I was working on a VoIP app, which is launched in the background when the iPhone boots up, at which point there might be no network reachability (e.g. if the phone has both a passcode and/or a SIM card with a PIN code). But since the app is launched directly in the background, the delegate method applicationDidEnterBackground: is not called. Instead what I did was use @Hurden's idea directly in application:didFinishLaunchingWithOptions, checking the applicationState to see if the app was actually starting in the background. This enabled my app to get the kReachabilityChangedNotification notification after the phone was unlocked (enabling the WiFi to connect using the stored password).

    0 讨论(0)
提交回复
热议问题