admin管理员组文章数量:1333638
So basically I was wondering if I could call a certain function from my Shield Action Extension, which is a built in feature of screen time api from Apple, in my Main App when for example a button is pressed.
class ShieldActionExtension: ShieldActionDelegate {
var applicationProfile: ApplicationProfile!
private var appStates: [ApplicationToken: Bool] = [:]
override func handle(action: ShieldAction, for application: ApplicationToken, completionHandler: @escaping (ShieldActionResponse) -> Void) {
let appIsUnlocked = appStates[application] ?? false
switch action {
case .primaryButtonPressed:
createApplicationProfile(for: application)
unlockAppAndStartTimer()
completionHandler(.none)
case .secondaryButtonPressed:
sendShieldNotification(for: application)
completionHandler(.defer)
@unknown default:
fatalError()
}
}
func unlockAppAndStartTimer() {
unlockApp()
// Schedule timer to reshield after 15 minutes
DispatchQueue.main.asyncAfter(deadline: .now() + 10) {
self.reapplyShield()
}
}
}
For example if I would like to call the function unlockAppAndStartTimer() when a button is pressed in a view in the Main Part of the app? I also already set up App Groups, however im not sure if this is relevant. My Main Problem is that the reshielding of apps only works in the background if I use the functions within the extension so I thought this idea of calling from somewhere else might be a fix?
版权声明:本文标题:xcode - Is there a way to call a function from the Shield Action Extension in the Main App? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742343917a2457138.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论