How to check if iPhone is in Airplane Mode with Swift

后端 未结 4 1909
刺人心
刺人心 2021-01-22 04:50

I\'d like to check whether flight mode is activated. If so, I need to show a warning message.

How can I check whether flight (airplane) mode is active using Swift?

4条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-22 05:31

    The easiest way is to let iOS done it for you.

    to go Info.plist -> add this **Application uses Wi-Fi (Boolean) YES*

    To test: Kill your app -> turn on airplane mode -> open ur app: you should be able to see alert within the app. Tested on iPhone iOS9

提交回复
热议问题