ios wifi 定位_iOS最新跳转手机设置WIFI定位等界面方法适配iOS11

iOS的“人性化”不言而喻,就是访问位置,打开WiFi,,,,都需要得到用户的允许,而有些请款下,用户暂时不想打开这些,甚至手抖选错了关闭,这个时候,就需要你去提醒用户去打开权限,这个时候,你可以像微信一样提示用户"设置"-"定位"。。。但是为了更好地用户体验,我们还是希望能直接跳转到设置界面,让用户直接进行设置。

//华丽的分割线--------------------------【😆】

最新的跳转方式:【这里以项目中显示Alert的形式】

(BOOL)checkLocationAuthorizationStatus

{

if (![CLLocationManager locationServicesEnabled]) { // disable the location for iPhone

dispatch_async(dispatch_get_main_queue(), ^{

[self showLocationServiceDisableAlert:YES];

});

return NO;

}

else {

if (kCLAuthorizationStatusDenied == [CLLocationManager authorizationStatus]) { // disable the location for this app

dispatch_async(dispatch_get_main_queue(), ^{

[self showLocationServiceDisableAlert:NO];

});

return NO;

}

}

return YES;

}

(void)showLocationServiceDisableAlert:(BOOL)disable

{

UIAlertController *ctrl = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"location_alert_title", @"") message:[NSString stringWithFormat:NSLocalizedString(@"location_alert_prompt",@""),AMDeviceAppName] preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction *action1 = [UIAlertAction actionWithTitle:NSLocalizedString(@"cancel_action", @"") style:UIAlertActionStyleCancel handler:nil];

UIAlertAction *action2 = [UIAlertAction actionWithTitle:NSLocalizedString(@"sure_action", @"") style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

dispatch_async(dispatch_get_main_queue(), ^{

NSURL *url = nil;

if (disable) {

if (IS_IOS_10_OR_LATER) {

url = [NSURL URLWithString: @"App-Prefs:root=General&path=LOCATION_SERVICES"];

}

else{

url = [NSURL URLWithString:@"prefs:root=LOCATION_SERVICES"];

}

}

else {

url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];

}

if ([[UIApplication sharedApplication] canOpenURL:url]) {

[[UIApplication sharedApplication] openURL:url];

}

});

}];

[ctrl addAction:action1];

[ctrl addAction:action2];

[self presentViewController:ctrl animated:YES completion:nil];

}

//华丽的分割线--------------------------【😆】

鉴于这篇文章被很多朋友询问,因为这个是好早之前的方式了 ,一直很忙没有更新,现在特此来更新一下最新的跳转方式 :

方式一:prefs:root=某项服务

方式二:prefs:root=bundleID

方式三: UIApplicationOpenSettingsURLString

本篇针对iOS7、iOS8、iOS9、iOS10,来介绍其中区别。

一、跳转方法

当iOS系统版本 < iOS 10.0 时

NSURL *url= [NSURL URLWithString:@"prefs:root=LOCATION_SERVICES"];

if( [[UIApplication sharedApplication]canOpenURL:url] ) {

[[UIApplication sharedApplication]openURL:url];

}

当iOS系统版本 >=iOS 10.0 时

if( [[UIApplication sharedApplication]canOpenURL:url] ) {

[[UIApplication sharedApplication]openURL:url options:@{}completionHandler:^(BOOL success) {

}];

}

二、跳转到哪里去?(系统的设置,系统中自己应用下面的设置)

方式一:

当 iOS系统版本 <= iOS7时 , 只能跳转到 系统设置页面

NSURL *url= [NSURL URLWithString:@"prefs:root=LOCATION_SERVICES"];

跳转到: 隐私-定位服务。

prefs:root=某项服务

系统设置:prefs:root=INTERNET_TETHERING

WIFI设置:prefs:root=WIFI

蓝牙设置:prefs:root=Bluetooth

系统通知:prefs:root=NOTIFICATIONS_ID

通用设置:prefs:root=General

显示设置:prefs:root=DISPLAY&BRIGHTNESS

壁纸设置:prefs:root=Wallpaper

声音设置:prefs:root=Sounds

隐私设置:prefs:root=privacy

蜂窝网路:prefs:root=MOBILE_DATA_SETTINGS_ID

音乐:prefs:root=MUSIC

APP Store:prefs:root=STORE

Notes:prefs:root=NOTES

Safari:prefs:root=Safari

Music:prefs:root=MUSIC

photo":prefs:root=Photos

这种跳转方式,都是跳转到系统的设置界面。

方式二 :

当 iOS系统版本 >= iOS8 ,支持跳转到第三方应用的设置界面中

使用prefs:root=bundleID ,bundleID是你第三方应用工程的唯一ID

局限性:只支持iOS8,iOS9系统,在iOS10系统上,不会跳转。

在iOS7系统上,仅仅只是跳转到设置应用,不推荐使用。

如果需要继续向项目内层进行跳转,可以通过添加path路径的方式,如下:

关于本机:prefs:root=General&path=About

软件升级:prefs:root=General&path=SOFTWARE_UPDATE_LINK

日期时间:prefs:root=General&path=DATE_AND_TIME

Accessibility:prefs:root=General&path=ACCESSIBILITY

键盘设置:prefs:root=General&path=Keyboard

VPN:prefs:root=General&path=VPN

壁纸设置:@"prefs:root=Wallpaper

声音设置:prefs:root=Sounds

隐私设置:prefs:root=privacy

APP Store:prefs:root=STORE

还原设置:prefs:root=General&path=Reset

应用通知:prefs:root=NOTIFICATIONS_ID&path=应用的boundleId

定位:prefs:root=LOCATION_SERVICES

蜂窝网络:prefs:root=MOBILE_DATA_SETTINGS_ID

VPN — prefs:root=General&path=Network/VPN

Wi-Fi:prefs:root=WIFI

定位服务:prefs:root=LOCATION_SERVICES

个人热点:prefs:root=INTERNET_TETHERING

辅助功能:prefs:root=General&path=ACCESSIBILITY

飞行模式:prefs:root=AIRPLANE_MODE

锁定:prefs:root=General&path=AUTOLOCK

亮度:prefs:root=Brightness

蓝牙:prefs:root=General&path=Bluetooth

时间设置:prefs:root=General&path=DATE_AND_TIME

FaceTime:prefs:root=FACETIME

设置:prefs:root=General

键盘设置:prefs:root=General&path=Keyboard

iCloud:prefs:root=CASTLE

iCloud备份:prefs:root=CASTLE&path=STORAGE_AND_BACKUP

语言:prefs:root=General&path=INTERNATIONAL

音乐:prefs:root=MUSIC

Music Equalizer — prefs:root=MUSIC&path=EQ

Music Volume Limit — prefs:root=MUSIC&path=VolumeLimit

Network — prefs:root=General&path=Network

Nike + iPod — prefs:root=NIKE_PLUS_IPOD

Notes — prefs:root=NOTES

Notification — prefs:root=NOTIFICATIONS_ID

Phone — prefs:root=Phone

Photos — prefs:root=Photos

Profile — prefs:root=General&path=ManagedConfigurationList

Reset — prefs:root=General&path=Reset

Safari — prefs:root=Safari

Siri — prefs:root=General&path=Assistant

Sounds — prefs:root=Sounds

Software Update — prefs:root=General&path=SOFTWARE_UPDATE_LINK

Store — prefs:root=STORE

Twitter — prefs:root=TWITTER

Usage — prefs:root=General&path=USAGE

Wallpaper — prefs:root=Wallpaper

方式三

当 iOS系统版本 >= iOS8,支持跳转到自己应用设置,不支持跳转到系统设置

NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];

UIApplicationOpenSettingsURLString字段,是在iOS8上才提供的,支持iOS8,iOS9,iOS10系统,推荐使用。

当iOS系统版本>= iOS10,支持跳转到自己应用设置,不支持跳转到系统设置

只认:

NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];

跳转。

而 prefs:root=bundleID和 prefs:root=服务 都将不起作用。

总结一下:

方式一:prefs:root=某项服务 适用于 小于 iOS10的系统;

方式二:prefs:root=bundleID 适用于 大于等于iOS8系统,小于iOS10的系统

方式三:UIApplicationOpenSettingsURLString 适用于 大于等于iOS8的系统

Prefs设置方式:[注意大小写]

3DDD36E3-E8F4-4B3C-BAC2-2D47139C4B73.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值