2017-02-28 17:07:51 Three_Zhang 阅读数 1750

在iOS10更新后,系统设置跳转被禁用,只能跳转App设置? NO, NO, NO, 看这里,又可以换个姿势愉快的跳转啦。

其实方法很简单,例如原有跳转Wi-Fi设置是”prefs:root=WIFI”,新的写法是”App-Prefs:root=WIFI”。怎么样,是不是很简单!!!

Objective-c

#define iOS10 ([[UIDevice currentDevice].systemVersion doubleValue] >= 10.0)
NSString * urlString = @"App-Prefs:root=WIFI";
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:urlString]]) {
    if (iOS10) {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString] options:@{} completionHandler:nil];
    } else {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];
    }
}

Swift

if let url = URL(string:"App-Prefs:root=WIFI") {
      if #available(iOS 10.0, *) {
            UIApplication.shared.open(url, options: [:], completionHandler: nil)
      } else {
            UIApplication.shared.openURL(url)
      }
}

当前iOS10支持的所有跳转,亲测可用(测试系统:10.2.1)

跳转 写法
无线局域网 App-Prefs:root=WIFI
蓝牙 App-Prefs:root=Bluetooth
蜂窝移动网络 App-Prefs:root=MOBILE_DATA_SETTINGS_ID
个人热点 App-Prefs:root=INTERNET_TETHERING
运营商 App-Prefs:root=Carrier
通知 App-Prefs:root=NOTIFICATIONS_ID
通用 App-Prefs:root=General
通用-关于本机 App-Prefs:root=General&path=About
通用-键盘 App-Prefs:root=General&path=Keyboard
通用-辅助功能 App-Prefs:root=General&path=ACCESSIBILITYFI
通用-语言与地区 App-Prefs:root=General&path=INTERNATIONAL
通用-还原 App-Prefs:root=Reset
墙纸 App-Prefs:root=Wallpaper
Siri App-Prefs:root=SIRI
隐私 App-Prefs:root=Privacy
Safari App-Prefs:root=SAFARI
音乐 App-Prefs:root=MUSIC
音乐-均衡器 App-Prefs:root=MUSIC&path=com.apple.Music:EQ
照片与相机 App-Prefs:root=Photos
FaceTime App-Prefs:root=FACETIME
2016-06-07 16:03:49 TianYou_Code 阅读数 1076

跳转到设置位置、通知、照片、麦克风等如下:

NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];  
if ([[UIApplication sharedApplication] canOpenURL:url]) {  
   [[UIApplication sharedApplication] openURL:url];  
} 

跳转wifir如下:

NSURL*url=[NSURL URLWithString:@"prefs:root=WIFI"];  
[[UIApplication sharedApplication] openURL:url];  

其他:

About — prefs:root=General&path=About  
Accessibility — prefs:root=General&path=ACCESSIBILITY  
Airplane Mode On — prefs:root=AIRPLANE_MODE  
Auto-Lock — prefs:root=General&path=AUTOLOCK  
Brightness — prefs:root=Brightness  
Bluetooth — prefs:root=General&path=Bluetooth  
Date & Time — prefs:root=General&path=DATE_AND_TIME  
FaceTime — prefs:root=FACETIME  
General — prefs:root=General  
Keyboard — prefs:root=General&path=Keyboard  
iCloud — prefs:root=CASTLE  
iCloud Storage & Backup — prefs:root=CASTLE&path=STORAGE_AND_BACKUP  
International — prefs:root=General&path=INTERNATIONAL  
Location Services — prefs:root=LOCATION_SERVICES  
Music — 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  
VPN — prefs:root=General&path=Network/VPN  
Wallpaper — prefs:root=Wallpaper  
Wi-Fi — prefs:root=WIFI  
Setting —prefs:root=INTERNET_TETHERING  

附加判断是否开启定位:

//请开启定位服务
    CLAuthorizationStatus status = [CLLocationManager authorizationStatus];
    if (kCLAuthorizationStatusDenied == status || kCLAuthorizationStatusRestricted == status)
    {
       NSLog(@"请开启定位");
     }



2015-07-27 12:08:33 Biharry 阅读数 487

iOS 跳转到系统的设置界面

在项目中,我们经常会碰到使用位置的需求。当用户设置app不允许使用位置的时候,最好的用户体验就是直接调转到系统的位置设置界面,进行设置。


本人已经测试,在5c iOS8.3系统 和 5s iOS7.1系统中可以正常跳转


跳转到自己的项目中

在需要调转的按钮动作中添加如下的代码,就会跳转到设置中自己的app的设置界面,这里会有通知和位置权限的设置

NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];  
if ([[UIApplication sharedApplication] canOpenURL:url]) {  
   [[UIApplication sharedApplication] openURL:url];  
}  

跳转到系统设置的其他界面

在点击跳转的按钮动作中添加如下代码

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=WIFI"]];

在项目中的info中添加 URL types
添加 URL Schemes 为 prefs的url
这里写图片描述

这样点击就可以跳转到wifi设置界面

(测试手机 5c 8.3系统 5s 7.1系统)


跳转到其他的界面的字段

About — prefs:root=General&path=About  
Accessibility — prefs:root=General&path=ACCESSIBILITY  
Airplane Mode On — prefs:root=AIRPLANE_MODE  
Auto-Lock — prefs:root=General&path=AUTOLOCK  
Brightness — prefs:root=Brightness  
Bluetooth — prefs:root=General&path=Bluetooth  
Date & Time — prefs:root=General&path=DATE_AND_TIME  
FaceTime — prefs:root=FACETIME  
General — prefs:root=General  
Keyboard — prefs:root=General&path=Keyboard  
iCloud — prefs:root=CASTLE  
iCloud Storage & Backup — prefs:root=CASTLE&path=STORAGE_AND_BACKUP  
International — prefs:root=General&path=INTERNATIONAL  
Location Services — prefs:root=LOCATION_SERVICES  
Music — 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  
VPN — prefs:root=General&path=Network/VPN  
Wallpaper — prefs:root=Wallpaper  
Wi-Fi — prefs:root=WIFI  
Setting —prefs:root=INTERNET_TETHERING
2018-04-23 18:28:02 chenfujun818 阅读数 788

Unity 实现跳转ios 设置界面

一、功能需求 iOS网络设置检查,如果没有网络可能是用户选择关闭了 网络链接,ios可以从游戏内直接跳转到设置网络开关。

二、网络检测 直接上代码


        public static bool HasNetwork() {
            return Application.internetReachability != NetworkReachability.NotReachable;
        }

        public static bool IsWiFi() {
            return Application.internetReachability == NetworkReachability.ReachableViaLocalAreaNetwork;
        }

        public static bool IsCellular() {
            return Application.internetReachability == NetworkReachability.ReachableViaCarrierDataNetwork;
        }

三、实现unity调用 ios原生界面
1)unity 调用ios方法

using System;
using UnityEngine;
using System.Runtime.InteropServices;


public class Platform {
#if UNITY_IPHONE
    [DllImport("__Internal")]
    public static extern void __OpenSystemTimeSetting();
    [DllImport("__Internal")]
    public static extern void __TelPhoneNumber(string str);
    [DllImport("__Internal")]
    public static extern bool _IsHadInstalledWeixin();
    [DllImport("__Internal")]
    public static extern string __GetDeviceVersion(); 
#endif
    public static DeviceGeneration GetiOSDeviceGeneration() {
        string str = GetIphoneVersion();
        switch (str) {
            case "iPhone1,1":
                return DeviceGeneration.iPhone;
            case "iPhone1,2":
                return DeviceGeneration.iPhone3G;
            case "iPhone2,1":
                return DeviceGeneration.iPhone3GS;
            case "iPhone3,1":
            case "iPhone3,2":
            case "iPhone3,3":
                return DeviceGeneration.iPhone4;
            case "iPhone4,1":
                return DeviceGeneration.iPhone4S;
            case "iPhone5,1":
            case "iPhone5,2":
                return DeviceGeneration.iPhone5;
            case "iPhone5,3":
            case "iPhone5,4":
                return DeviceGeneration.iPhone5C;
            case "iPhone6,1":
            case "iPhone6,2":
                return DeviceGeneration.iPhone5S;
            case "iPhone7,2":
                return DeviceGeneration.iPhone6;
            case "iPhone7,1":
                return DeviceGeneration.iPhone6Plus;
            case "iPhone8,1":
                return DeviceGeneration.iPhone6S;
            case "iPhone8,2":
                return DeviceGeneration.iPhone6SPlus;
            case "iPhone8,4":
                return DeviceGeneration.iPhoneSE1Gen;
            case "iPhone9,1":
            case "iPhone9,3":
                return DeviceGeneration.iPhone7;
            case "iPhone9,2":
            case "iPhone9,4":
                return DeviceGeneration.iPhone7Plus;
            case "iPhone10,1":
            case "iPhone10,4":
                return DeviceGeneration.iPhone8;
            case "iPhone10,2":
            case "iPhone10,5":
                return DeviceGeneration.iPhone8Plus;
            case "iPhone10,3":
            case "iPhone10,6":
                return DeviceGeneration.iPhoneX;
            case "iPad1,1":
                return DeviceGeneration.iPad1Gen;
            case "iPad2,1":
            case "iPad2,2":
            case "iPad2,3":
            case "iPad2,4":
                return DeviceGeneration.iPad2Gen;
            case "iPad3,1":
            case "iPad3,2":
            case "iPad3,3":
                return DeviceGeneration.iPad3Gen;
            case "iPad3,4":
            case "iPad3,5":
            case "iPad3,6":
                return DeviceGeneration.iPad4Gen;
            case "iPad4,1":
            case "iPad4,2":
            case "iPad4,3":
                return DeviceGeneration.iPadAir1;
            case "iPad5,3":
            case "iPad5,4":
                return DeviceGeneration.iPadAir2;
            case "iPad6,7":
            case "iPad6,8":
                return DeviceGeneration.iPadPro1Gen;
            case "iPad6,3":
            case "iPad6,4":
                return DeviceGeneration.iPadPro10Inch1Gen;
            case "iPad7,1":
            case "iPad7,2":
                return DeviceGeneration.iPadPro2Gen;
            case "iPad7,3":
            case "iPad7,4":
                return DeviceGeneration.iPadPro10Inch2Gen;
            case "iPad2,5":
            case "iPad2,6":
            case "iPad2,7":
                return DeviceGeneration.iPadMini1Gen;
            case "iPad4,4":
            case "iPad4,5":
            case "iPad4,6":
                return DeviceGeneration.iPadMini2Gen;
            case "iPad4,7":
            case "iPad4,8":
            case "iPad4,9":
                return DeviceGeneration.iPadMini3Gen;
            case "iPad5,1":
            case "iPad5,2":
                return DeviceGeneration.iPadMini4Gen;
            case "iPod1,1":
                return DeviceGeneration.iPodTouch1Gen;
            case "iPod2,1":
                return DeviceGeneration.iPodTouch2Gen;
            case "iPod3,1":
                return DeviceGeneration.iPodTouch3Gen;
            case "iPod4,1":
                return DeviceGeneration.iPodTouch4Gen;
            case "iPod5,1":
                return DeviceGeneration.iPodTouch5Gen;
            case "iPod7,1":
                return DeviceGeneration.iPodTouch6Gen;
            default:
                return DeviceGeneration.Unknown;
        }
    }

    public static string GetIphoneVersion() {
#if !UNITY_EDITOR
#if !UNITY_ANDROID
            return __GetDeviceVersion();
#endif
#endif
        return "";
    }

    public static void OpenSystemSetting() {
#if !UNITY_EDITOR
#if UNITY_IPHONE
        __OpenSystemTimeSetting();
#elif UNITY_ANDROID
        callAndroidFunc("OpenSystemTimeSetting");
#endif
#endif
    }

    public static string GetChannel() {
#if !UNITY_EDITOR
#if UNITY_ANDROID
            return callAndroidFunc<string>("GetChannel");
#else
            return "App Store";
#endif
#else
        return "Editor";
#endif
    }

    public static void TelPhoneNumber(string phoneNumber) {
#if !UNITY_EDITOR
#if UNITY_IPHONE
            //__TelPhoneNumber(phoneNumber);
#elif UNITY_ANDROID
            callAndroidFunc("TelPhoneNumber",phoneNumber);
#endif
#endif
    }

    public static bool IsWeixinAvailable() {
        try {
#if !UNITY_EDITOR
#if UNITY_IPHONE
                        return _IsHadInstalledWeixin();
//                      return true;
#elif UNITY_ANDROID
                        return callAndroidFunc<bool>("isWeixinAvilable");
#else

#endif
#endif
            return true;

        } catch (Exception e) {
            LogException(e);
        }
        return false;
    }

    public static string GetDeviceBrand() {
#if !UNITY_EDITOR
#if UNITY_ANDROID
                    return callAndroidFunc<string>("GetDeviceBrand");
#else
                    return "Apple";
#endif
#endif
        return "MacOS";
    }

    public static string GetSoucre() {
        try {
#if UNITY_IPHONE
            return "iOS";
#elif UNITY_ANDROID
            return "android";
#else
                return "iOS";
#endif
        } catch (Exception e) {
            LogException(e);
        }
        return string.Empty;
    }

    public static string GetVersion() {
        return Application.version;
    }

    public static string GetOSVersion() {
        return SystemInfo.operatingSystem;
    }

    public static string GetDeviceModel() {
        return SystemInfo.deviceModel;
    }

    public static bool IsIpx() {
#if UNITY_IPHONE
            if (GetiOSDeviceGeneration() == DeviceGeneration.iPhoneX) {
                return true;
            }
            return false;           
#else
        return false;
#endif
    }

    public static bool IsIPad() {
#if UNITY_IPHONE
            if (GetiOSDeviceGeneration () == DeviceGeneration.iPad1Gen
               || GetiOSDeviceGeneration () == DeviceGeneration.iPad2Gen
               || GetiOSDeviceGeneration () == DeviceGeneration.iPad3Gen
               || GetiOSDeviceGeneration () == DeviceGeneration.iPad4Gen
               || GetiOSDeviceGeneration () == DeviceGeneration.iPadAir1
               || GetiOSDeviceGeneration () == DeviceGeneration.iPadAir2
               || GetiOSDeviceGeneration () == DeviceGeneration.iPadPro1Gen
               || GetiOSDeviceGeneration () == DeviceGeneration.iPadPro10Inch1Gen
               || GetiOSDeviceGeneration () == DeviceGeneration.iPadPro2Gen
               || GetiOSDeviceGeneration () == DeviceGeneration.iPadPro10Inch2Gen
               || GetiOSDeviceGeneration () == DeviceGeneration.iPadMini1Gen
               || GetiOSDeviceGeneration () == DeviceGeneration.iPadMini2Gen
               || GetiOSDeviceGeneration () == DeviceGeneration.iPadMini3Gen
               || GetiOSDeviceGeneration () == DeviceGeneration.iPadMini4Gen) {
                return true;
            }
            return false;
#else
        return false;
#endif
    }

    private static T callAndroidFunc<T>(string funName, params object[] args) {
        try {
           using (AndroidJavaClass jcla = new AndroidJavaClass("com.Platform")) {
               using (AndroidJavaObject instance = jcla.CallStatic<AndroidJavaObject>("getInstance")) {
                   return instance.Call<T>(funName, args);
               }
           }
        } catch (Exception e) {
           LogException(e);
        }
        return default(T);
    }

    private static void callAndroidFunc(string funName, params object[] args) {
        try {
           using (AndroidJavaClass jcla = new AndroidJavaClass("com.Platform")) {
               using (AndroidJavaObject instance = jcla.CallStatic<AndroidJavaObject>("getInstance")) {
                   instance.Call(funName, args);
               }
           }
        } catch (Exception e) {
           LogException(e);
        }
    }
}

2)ios 方法实现


#import "OpenSetting.h"

@implementation OpenSetting

@end

extern "C" {
    void __OpenSystemTimeSetting()
    {
        NSURL * url = [NSURL URLWithString: UIApplicationOpenSettingsURLString];
        if ( [[UIApplication sharedApplication] canOpenURL: url] ) {
            NSURL*url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
            [[UIApplication sharedApplication] openURL:url];
        }
    }

    void __TelPhoneNumber(char* cPhoneNum){
        if (cPhoneNum == nullptr) {
            return;
        }
        NSString *phoneNum = [NSString stringWithUTF8String:cPhoneNum];
        if (phoneNum == nil) {
            return;
        }
        NSString *callPhone = [NSString stringWithFormat:@"telprompt://%@", phoneNum];
        if ([[UIDevice currentDevice].systemVersion floatValue] >= 10.0) {
            /// 10及其以上系统
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:callPhone] options:@{} completionHandler:nil];
        } else {
            /// 10以下系统
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:callPhone]];
        }
    }

    bool _IsHadInstalledWeixin(){
        NSURL * url1 = [NSURL URLWithString:@"weixin://"];
        NSURL * url2 = [NSURL URLWithString:@"Whatapp://"];
        if ([[UIApplication sharedApplication] canOpenURL:url1] ||
            [[UIApplication sharedApplication] canOpenURL:url2]) {
            return true;
        }
        return false;
    }
}

至此xcode 打包即可

2015-12-22 11:32:07 forwardto9 阅读数 1219

1.跳转到系统设置

// 英文模式下,到setting页,然后使用navigation path

//  setting->General&path->Reset

//  setting->WIFI


形式:跳转到“一般”中得“时间与日期”

"prefs:root=General&path=DATE_AND_TIME"

通过观察,我们发现,访问“一般”中得某项,就需要使用“General&path=xxx”

同理,

如果跳转到设置中的大类,比如WIFI

"prefs:root=WIFI"

注意:

OS版本不同,路径可能会发生变化


2.跳转到设置页面中自己的应用下

[[UIApplication sharedApplication] openURL:[NSUR URLWithString:UIApplicationOpenSettingsURLString]];

一般情况下,这个主要是申请了访问系统资源的权限APP才会使用,比如,麦克风、推送、Location Service等!

注意:

这个UIApplicationOpenSettingsURLString常量是iOS8之后才可用的

iOS跳转系统设置页面

博文 来自: lxmy2012

ios跳转wifi设置页面

阅读数 2093

iOS 跳转系统设置

阅读数 199

没有更多推荐了,返回首页