2018-10-20 14:54:59 +00:00
|
|
|
//
|
|
|
|
// NSUserActivity+Extensions.swift
|
|
|
|
// Tusker
|
|
|
|
//
|
|
|
|
// Created by Shadowfacts on 10/19/18.
|
|
|
|
// Copyright © 2018 Shadowfacts. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
|
|
|
|
extension NSUserActivity {
|
|
|
|
|
2022-05-13 21:10:18 +00:00
|
|
|
var displaysAuxiliaryScene: Bool {
|
|
|
|
get {
|
|
|
|
(userInfo?["displaysAuxiliaryScene"] as? Bool) ?? false
|
|
|
|
}
|
|
|
|
set {
|
|
|
|
if userInfo == nil {
|
|
|
|
userInfo = [:]
|
|
|
|
}
|
|
|
|
userInfo!["displaysAuxiliaryScene"] = newValue
|
|
|
|
}
|
|
|
|
}
|
2022-11-23 16:35:25 +00:00
|
|
|
|
|
|
|
var isStateRestorationActivity: Bool {
|
|
|
|
get {
|
|
|
|
(userInfo?["isStateRestorationActivity"] as? Bool) ?? false
|
|
|
|
}
|
|
|
|
set {
|
|
|
|
if userInfo == nil {
|
|
|
|
userInfo = [:]
|
|
|
|
}
|
|
|
|
userInfo!["isStateRestorationActivity"] = newValue
|
|
|
|
}
|
|
|
|
}
|
2022-05-13 21:10:18 +00:00
|
|
|
|
2023-02-23 02:42:09 +00:00
|
|
|
convenience init(type: UserActivityType, accountID: String) {
|
2018-10-20 14:54:59 +00:00
|
|
|
self.init(activityType: type.rawValue)
|
2023-02-23 02:42:09 +00:00
|
|
|
self.userInfo = [
|
|
|
|
"accountID": accountID
|
|
|
|
]
|
2018-10-20 14:54:59 +00:00
|
|
|
}
|
|
|
|
|
2023-02-25 18:55:46 +00:00
|
|
|
@MainActor
|
2022-05-13 21:10:18 +00:00
|
|
|
func handleResume(manager: UserActivityManager) -> Bool {
|
2018-10-20 14:54:59 +00:00
|
|
|
guard let type = UserActivityType(rawValue: activityType) else { return false }
|
2022-05-13 21:10:18 +00:00
|
|
|
type.handle(manager)(self)
|
2018-10-20 14:54:59 +00:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|