Vernissage/Vernissage/SceneDelegate.swift

28 lines
848 B
Swift
Raw Normal View History

2022-12-31 16:31:05 +01:00
//
// https://mczachurski.dev
// Copyright © 2022 Marcin Czachurski and the repository contributors.
2023-03-28 10:35:38 +02:00
// Licensed under the Apache License 2.0.
2022-12-31 16:31:05 +01:00
//
import SwiftUI
2023-02-19 10:32:38 +01:00
import PixelfedKit
2022-12-31 16:31:05 +01:00
import OAuthSwift
2023-04-07 16:59:18 +02:00
import EnvironmentKit
2022-12-31 16:31:05 +01:00
2023-01-12 18:34:48 +01:00
class SceneDelegate: NSObject, UISceneDelegate {
2022-12-31 16:31:05 +01:00
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
2023-01-29 19:11:44 +01:00
guard let url = URLContexts.first?.url else {
return
}
2023-01-29 19:11:44 +01:00
if url.host == AppConstants.oauthCallbackPart {
OAuthSwift.handle(url: url)
2023-03-11 18:30:33 +01:00
} else if url.host == AppConstants.statusCallbackPart {
let statusId = url.string.replacingOccurrences(of: "\(AppConstants.statusUri)/", with: "")
if statusId.isEmpty == false {
ApplicationState.shared.showStatusId = statusId
}
2023-01-29 19:11:44 +01:00
}
2022-12-31 16:31:05 +01:00
}
}