My iPhone app needs a persistent network connection…how to specify UIRequiredDeviceCapabilities?

前端 未结 4 1741
滥情空心
滥情空心 2020-12-21 09:15

I\'m trying to set the UIRequiredDeviceCapabilities properties in my Info.plist file. My app requires a persistent network connection. If I look at the definition for the \"

相关标签:
4条回答
  • 2020-12-21 09:45

    Without this key, the iPhone will disable wifi after a certain amount of inactivity. With this key, the wifi is kept permanently enabled for your app.

    0 讨论(0)
  • 2020-12-21 09:52

    First of all, UIRequiresPersistentWiFi does not pertain just to WiFi, but is simply a way to state that your program is a network application and will be using any connection persistently. This in particular was mentioned by Apple developer doing WWDC presentation on network programming (last year, I think).

    Second, the wifi key of required device capabilities does seem to pertain to the WiFi in particular. The Unicom iPhone available in China has WiFi turned off (but is capable of connecting to network using cellular connection), and I've heard of reports that wifi key is (or at least was) causing trouble with installations.

    0 讨论(0)
  • 2020-12-21 09:58

    If you believe Apple's own (often vague) documentation, specifying properties in UIRequiredDeviceCapabilities causes filtering at Apple's point of delivery (app store). So if you specified 'wifi', in theory non-wifi devices wouldn't be able to install your app. However, all the iDevices so far support wifi.

    Btw, UIRequiresPersistentWiFi does pertain to wifi directly in some ways. If you set this property to true, from my own tests I've seen that:

    • while the application is running the wifi comms will continue to be available even after 30 mins timeout has passed
    • if the app is running and wifi radio is currently timed out to 'off' (but wifi is enabled), first network access turns on wifi radio
    • if the app is running and wifi is enabled, but user is not currently joined to any access point, network access causes a system prompt to appear to join one of the access points

    Or, to put it another way: without this flag set, communication over wifi in your app can just appear to stop working. Or sometimes you can launch your app on your ipod or ipad and find that network comms is failing, even though wifi is enabled and you are near a good hotspot.

    It's sad that Apple's documentation is so muddled and confusing.

    0 讨论(0)
  • 2020-12-21 10:00

    If you need persistent wifi you should use the key UIRequiresPersistentWiFi.

    The UIRequiredDeviceCapabilities key does just what the name indicates, specifies which capabilities your app needs the device to have. Be it wifi, gps, magnetometer, etc.

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