Revision control
Copy as Markdown
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
import Foundation
import SafariServices
typealias EnabledCallback = (Bool) -> Void
class BlockerEnabledDetector {
func detectEnabled(_ parentView: UIView, callback: @escaping EnabledCallback) {
SFContentBlockerManager.getStateOfContentBlocker(withIdentifier: AppInfo.contentBlockerBundleIdentifier) { state, error in
DispatchQueue.main.async {
guard let state = state else {
print("Detection error: \(error!.localizedDescription)")
callback(false)
return
}
callback(state.isEnabled)
}
}
}
}