How to check if iPhone is in Airplane Mode with Swift

后端 未结 4 1895
刺人心
刺人心 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:13

    If you are using Location Services, they should return with an error code of 1009 by presenting the following in log:

    Geocode error: Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline."
    

    If you check for a return code of -1009, you can recognize the user as offline and follow through accordingly.

提交回复
热议问题