forked from shadowfacts/Tusker
Set target content identifiers on scenes/activities
This commit is contained in:
parent
a848f6e425
commit
eec2adbfd9
|
@ -63,6 +63,7 @@ class NotificationService: UNNotificationServiceExtension {
|
||||||
mutableContent.body = notification.body
|
mutableContent.body = notification.body
|
||||||
mutableContent.userInfo["notificationID"] = notification.notificationID
|
mutableContent.userInfo["notificationID"] = notification.notificationID
|
||||||
mutableContent.userInfo["accountID"] = accountID
|
mutableContent.userInfo["accountID"] = accountID
|
||||||
|
mutableContent.targetContentIdentifier = accountID
|
||||||
|
|
||||||
let task = Task {
|
let task = Task {
|
||||||
await updateNotificationContent(mutableContent, account: account, push: notification)
|
await updateNotificationContent(mutableContent, account: account, push: notification)
|
||||||
|
|
|
@ -295,7 +295,12 @@ extension AppDelegate: UNUserNotificationCenterDelegate {
|
||||||
rootViewController.getNavigationController().pushViewController(vc, animated: false)
|
rootViewController.getNavigationController().pushViewController(vc, animated: false)
|
||||||
} else {
|
} else {
|
||||||
let activity = UserActivityManager.showNotificationActivity(id: notificationID, accountID: accountID)
|
let activity = UserActivityManager.showNotificationActivity(id: notificationID, accountID: accountID)
|
||||||
UIApplication.shared.requestSceneSessionActivation(nil, userActivity: activity, options: nil)
|
if #available(iOS 17.0, *) {
|
||||||
|
let request = UISceneSessionActivationRequest(userActivity: activity)
|
||||||
|
UIApplication.shared.activateSceneSession(for: request)
|
||||||
|
} else {
|
||||||
|
UIApplication.shared.requestSceneSessionActivation(nil, userActivity: activity, options: nil)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
completionHandler()
|
completionHandler()
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,8 +32,9 @@ class AuxiliarySceneDelegate: UIResponder, UIWindowSceneDelegate, TuskerSceneDel
|
||||||
}
|
}
|
||||||
launchActivity = activity
|
launchActivity = activity
|
||||||
|
|
||||||
let account: UserAccountInfo
|
scene.activationConditions.canActivateForTargetContentIdentifierPredicate = NSPredicate(value: false)
|
||||||
|
|
||||||
|
let account: UserAccountInfo
|
||||||
if let activityAccount = UserActivityManager.getAccount(from: activity) {
|
if let activityAccount = UserActivityManager.getAccount(from: activity) {
|
||||||
account = activityAccount
|
account = activityAccount
|
||||||
} else if let mostRecent = UserAccountsManager.shared.getMostRecentAccount() {
|
} else if let mostRecent = UserAccountsManager.shared.getMostRecentAccount() {
|
||||||
|
|
|
@ -29,6 +29,8 @@ class ComposeSceneDelegate: UIResponder, UIWindowSceneDelegate, TuskerSceneDeleg
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scene.activationConditions.canActivateForTargetContentIdentifierPredicate = NSPredicate(value: false)
|
||||||
|
|
||||||
let account: UserAccountInfo
|
let account: UserAccountInfo
|
||||||
let controller: MastodonController
|
let controller: MastodonController
|
||||||
let draft: Draft?
|
let draft: Draft?
|
||||||
|
|
|
@ -225,6 +225,8 @@ class MainSceneDelegate: UIResponder, UIWindowSceneDelegate, TuskerSceneDelegate
|
||||||
window!.windowScene!.title = account.instanceURL.host!
|
window!.windowScene!.title = account.instanceURL.host!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window!.windowScene!.activationConditions.prefersToActivateForTargetContentIdentifierPredicate = NSPredicate(format: "self == %@", account.id)
|
||||||
|
|
||||||
if let container = window?.rootViewController as? AccountSwitchingContainerViewController {
|
if let container = window?.rootViewController as? AccountSwitchingContainerViewController {
|
||||||
let direction: AccountSwitchingContainerViewController.AnimationDirection
|
let direction: AccountSwitchingContainerViewController.AnimationDirection
|
||||||
if animated,
|
if animated,
|
||||||
|
|
|
@ -39,6 +39,7 @@ extension NSUserActivity {
|
||||||
self.userInfo = [
|
self.userInfo = [
|
||||||
"accountID": accountID
|
"accountID": accountID
|
||||||
]
|
]
|
||||||
|
self.targetContentIdentifier = accountID
|
||||||
}
|
}
|
||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
|
|
Loading…
Reference in New Issue