热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

如何在iOS11设置中打开您的应用

如何解决《如何在iOS11设置中打开您的应用》经验,为你挑选了2个好方法。

似乎Apple已经将很多应用程序配置移动到iOS 11的App路径,如何在设置中以编程方式打开应用程序路径?我试过,"App-Prefs:root=\(Bundle.main.bundleIdentifier!)"但这似乎不起作用.

请注意,我的问题特定于:如何在设置中打开应用程序路径:知道如何打开设置

Damien Banne.. 44

以下是您正在寻找的代码,我想:

if let url = URL(string: UIApplicationOpenSettingsURLString) {
    if UIApplication.shared.canOpenURL(url) {
        UIApplication.shared.open(url, options: [:], completionHandler: nil)
    }
}


Alessandro F.. 14

Swift 4.2,iOS 12

使用以下功能可以打开设置:

extension UIApplication {

    ...

    @discardableResult
    static func openAppSettings() -> Bool {
        guard
            let settingsURL = URL(string: UIApplication.openSettingsURLString),
            UIApplication.shared.canOpenURL(settingsURL)
            else {
                return false
        }

        UIApplication.shared.open(settingsURL)
        return true
    }
}

用法: UIApplication.openAppSettings()

但请注意不要使用" 非公共URL方案 ",例如:prefs:root=或者App-Prefs:root,否则您的应用将被拒绝.这件事最近发生在我身上,因为我试图在设置中与wifi部分建立深层链接.



1> Damien Banne..:

以下是您正在寻找的代码,我想:

if let url = URL(string: UIApplicationOpenSettingsURLString) {
    if UIApplication.shared.canOpenURL(url) {
        UIApplication.shared.open(url, options: [:], completionHandler: nil)
    }
}



2> Alessandro F..:

Swift 4.2,iOS 12

使用以下功能可以打开设置:

extension UIApplication {

    ...

    @discardableResult
    static func openAppSettings() -> Bool {
        guard
            let settingsURL = URL(string: UIApplication.openSettingsURLString),
            UIApplication.shared.canOpenURL(settingsURL)
            else {
                return false
        }

        UIApplication.shared.open(settingsURL)
        return true
    }
}

用法: UIApplication.openAppSettings()

但请注意不要使用" 非公共URL方案 ",例如:prefs:root=或者App-Prefs:root,否则您的应用将被拒绝.这件事最近发生在我身上,因为我试图在设置中与wifi部分建立深层链接.


您应该将`UIApplication.openAppSettings()`命名为(注意`s`)以符合`openSettingsURLString`
推荐阅读
author-avatar
奥咨达医疗器_械丶服务集团
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有