iOS10之后 以前的openUrl已经被遗弃了,所以要用新的方法来进行跳转
直接看代码:
//打开设置页面
- (void)openAppSetting{
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
if ([[UIApplication sharedApplication] canOpenURL:url])
{
if (iOS_Version < 10.0) {
[self openUrl:url];
}else{
[self openUrl:url completion:^(BOOL success) {
NSLog(@"跳转设置%@",success?@"成功":@"失败");
}];
}
}
}
//iOS10之前跳转
- (void)openUrl:(NSURL *)url{
[[UIApplication sharedApplication] openURL:url];
}
//iOS10之后跳转
- (void)openUrl:(NSURL *)url completion:(void(^)(BOOL success))block{
[[UIApplication sharedApplication] openURL:url options:@{UIApplicationOpenURLOptionUniversalLinksOnly:@NO} completionHandler:^(BOOL success) {
if(block)
block(success);
}];
}
提示:10之后就不能跳转到私有的设置了,只能通过UIApplicationOpenSettingsURLString跳转到App对应的权限设置
有些人用了10以后新的方法也不能进行跳转是因为 UIApplicationOpenURLOptionUniversalLinksOnly对应的值不能为YES
网友评论