How to check if iPhone is in Airplane Mode with Swift

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

    As far as I know you can't -- or you can't using public API. My suggestion would be to call required devices and set corresponding notifications. If you really need to know if its flight mode, maybe you can do that with calling 3G, GPS, Wi-Fi etc. and check if every one is off.

    I saw another suggestion with taking an in-app screenshot and checking for orange airplane ( does top contains orange part ).

    Drawbacks are present for both, My suggestion is bad since your devices could be off for other, not related reasons.

    Good luck.

提交回复
热议问题