gpt4 book ai didi

ios - 应用程序可以请求打开飞行模式然后检测到用户已经这样做了吗?

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:45:00 25 4
gpt4 key购买 nike

我正在构建一个应用程序,它应该只在飞行模式被激活时使用。该应用程序至少可以说是为不懂技术的人准备的。因此,我不能指望他们向上滑动并单击飞机图标。我最接近在我的应用程序中打开飞行模式的表单是什么?

基本上,我正在寻找 UIRequiresPersistentWifi 的对立面。

最佳答案

目前没有公共(public) API 可以直接检查飞行模式是否开启。

最接近的解决方案是使用 SystemConfiguration 框架并监控设备是否可以连接到网络。

使用 Reachability class (来自 tonymillion)你可以做类似的事情

Reachability* reach = [Reachability reachabilityWithHostname:@"www.google.com"];
reach.reachableBlock = ^(Reachability*reach) {
// do something to prevent the app to be used
// NOTE: this block is called on a background thread
// so if you need to change the UI, do
dispatch_async(dispatch_get_main_queue(), ^{
// UI related stuff
});
};
reach.unreachableBlock = ^(Reachability*reach) {
// ok continue using the app
};
[reach startNotifier];

关于ios - 应用程序可以请求打开飞行模式然后检测到用户已经这样做了吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19550159/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com