How to open battery settings from my app in iOS 18 using Swift?

Hi All, I am facing one problem in my app. That is open battery settings from my app. It is working fine in iOS 16.0.0 and it's not working in iOS 18.6.1 is it possible to make it workable in iOS 18.6.1? If so How to do that? Please help me over this to resolve the problem.

Thanks, Nguyen Quang Minh

Answered by DTS Engineer in 858469022

There’s no supported way to open Settings > Battery. The approach you were previously using relies on implementation details, and thus I’m not surprised it’s now boken. I discuss this situation in detail in Supported URL Schemes.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Well, what are you doing in 16.0.0 that works? Show us the code.

It's very hard to help when you don't give us the information.

//
//  SettingsHelper.swift
//  batteryZz
//
//  Created by Nguyen Quang Minh on 15/9/25.
//

import UIKit

class SettingsHelper {
    static let shared = SettingsHelper()
    
    private init() {}
    
    enum SettingsType {
        case appSettings
        case notificationSettings
        case microfonSettings
        case cameraSettings
        case locationSettings
        case photosSettings
        case siriSettings
        case wifiSettings
        case bluetoothSettings
        case cellularSettings
        case batterySettings
        case privacySettings
        
        var urlString: String {
            switch self {
                case .appSettings: return UIApplication.openSettingsURLString
                case .notificationSettings:
                            if #available(iOS 16.0, *) {
                                return UIApplication.openNotificationSettingsURLString
                            } else {
                                return UIApplication.openSettingsURLString
                            }
                case .microfonSettings: return "App-Prefs:Privacy&path=MICROPHONE"
                case .cameraSettings: return "App-Prefs:Privacy&path=CAMERA"
                case .locationSettings: return "App-Prefs:Privacy&path=LOCATION"
                case .photosSettings: return "App-Prefs:Privacy&path=PHOTOS"
                case .siriSettings: return "App-Prefs:SIRI"
                case .wifiSettings: return "App-Prefs:WIFI"
                case .bluetoothSettings: return "App-Prefs:Bluetooth"
                case .cellularSettings: return "App-Prefs:MOBILE_DATA_SETTINGS_ID"
                case .batterySettings: return "App-Prefs:BATTERY_USAGE"
                case .privacySettings: return "App-Prefs:Privacy"
            }
        }
    }
    
    func openSettings(_ type: SettingsType, completion: @escaping (Bool) -> Void) {
        guard let url = URL(string: type.urlString) else {
            print("Invalid settings URL")
            completion(false)
            return
        }
        
        UIApplication.shared.open(url) { success in
            if success {
                print("Successfully opened settings: \(type)")
            } else {
                print("Failed to open settings: \(type)")
            }
            completion(success)
        }
    }
}

@darkpaw This is the code example I use

Accepted Answer

There’s no supported way to open Settings > Battery. The approach you were previously using relies on implementation details, and thus I’m not surprised it’s now boken. I discuss this situation in detail in Supported URL Schemes.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

How to open battery settings from my app in iOS 18 using Swift?
 
 
Q