Monotouch: WebRequest connection fails after switching off Airplane Mode on iPhone

前端 未结 1 1652
你的背包
你的背包 2020-12-30 17:31

My monotouch app is doing periodic background synchronization with a web-service. It runs perfectly and detects Airplane mode correctly. When I switch off WiFi, it automatic

相关标签:
1条回答
  • 2020-12-30 17:51

    MonoTouch high level objects (ftp, smtp, http) that process network transactions utilize BSD sockets. Apple has a mechanism where even if the 3G/EDGE connection is "alive" its actually put to sleep. The only way to wake this up is to use CFStream or NSStream resources, there is no publically exposed API to wake up a GPRS connection for a BSD socket. Thankfully you can work around this issue. MonoTouch has provided an API:

    MonoTouch.ObjCRuntime.Runtime.StartWWAN (Uri uri);
    

    This api only accepts HTTP/HTTPs uri's and will make a quick connection to the specified API to re-awaken the WWAN for all connections, at which point the WWAN will stay alive until airplaned or timed out again.

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