【问题标题】:Open notification permission in settings app direct在设置应用程序中直接打开通知权限
【发布时间】:2016-06-05 09:32:49
【问题描述】:

我正在使用此代码在 Apple 设置应用中打开我的应用特定设置:

@IBAction func openSettings(sender: Any) {
    UIApplication.shared.openURL(URL(string: UIApplicationOpenSettingsURLString)!)
}

这指向Settings>[my_app_name],但有可能指向Settings>[my_app_name]>Notifications

或者这不可能?

到那时, 大卫。

【问题讨论】:

    标签: ios swift settings appsettings


    【解决方案1】:

    您只能打开您自己的应用偏好设置的根目录。你不能直接打开一个小节

    【讨论】:

    • 这会导致应用被拒绝吗?代码:UIApplication.sharedApplication().openURL(NSURL(string: UIApplicationOpenSettingsURLString)!)
    • 不,这是允许的
    【解决方案2】:
    1. 在您的 info.plist 中,将这些代码添加到此文件中:

    <key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleTypeRole</key> <string>Editor</string> <key>CFBundleURLSchemes</key> <array> <string>prefs</string> </array> </dict> </array>

    1. 然后您可以像这样在 Apple 设置应用中打开您的应用设置:

    let url = NSURL(string: "prefs:root=yourBundleId") UIApplication.sharedApplication().openURL(url!)

    【讨论】:

    • 感谢您的回答,但这不是问题所在。
    • 没问题。你不是这个帖子的第一个。其他人已经自己删除了他们的帖子。
    • 好吧,我认为prefs:root=yourBundleId&amp;path=NOTIFICATION 可能会起作用,但我已经尝试过了,但失败了..... key path 的值是否可能是其他词?
    • 我不知道。也许不可能!?
    猜你喜欢
    • 2021-02-22
    • 1970-01-01
    • 1970-01-01
    • 2017-08-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-29
    • 1970-01-01
    相关资源
    最近更新 更多