Fixed opening universal links
This commit is contained in:
parent
fffd101f85
commit
593deaf6f6
@ -1785,7 +1785,7 @@
|
|||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
|
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 151;
|
CURRENT_PROJECT_VERSION = 152;
|
||||||
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
||||||
INFOPLIST_FILE = AutoCat/Info.plist;
|
INFOPLIST_FILE = AutoCat/Info.plist;
|
||||||
INFOPLIST_KEY_CFBundleDisplayName = AutoCat;
|
INFOPLIST_KEY_CFBundleDisplayName = AutoCat;
|
||||||
@ -1812,7 +1812,7 @@
|
|||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
|
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 151;
|
CURRENT_PROJECT_VERSION = 152;
|
||||||
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
||||||
INFOPLIST_FILE = AutoCat/Info.plist;
|
INFOPLIST_FILE = AutoCat/Info.plist;
|
||||||
INFOPLIST_KEY_CFBundleDisplayName = AutoCat;
|
INFOPLIST_KEY_CFBundleDisplayName = AutoCat;
|
||||||
|
|||||||
@ -3,19 +3,9 @@ import RealmSwift
|
|||||||
import PKHUD
|
import PKHUD
|
||||||
import AutoCatCore
|
import AutoCatCore
|
||||||
|
|
||||||
enum QuickAction {
|
|
||||||
case none
|
|
||||||
case check
|
|
||||||
case checkNumber(String, VehicleEventDto?)
|
|
||||||
case addVoiceRecord
|
|
||||||
case openReport(String)
|
|
||||||
}
|
|
||||||
|
|
||||||
@main
|
@main
|
||||||
class AppDelegate: UIResponder, UIApplicationDelegate {
|
class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||||
|
|
||||||
var quickAction: QuickAction = .none
|
|
||||||
|
|
||||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||||||
|
|
||||||
let config = Realm.Configuration(
|
let config = Realm.Configuration(
|
||||||
@ -94,18 +84,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
|||||||
// Called when a new scene session is being created.
|
// Called when a new scene session is being created.
|
||||||
// Use this method to select a configuration to create the new scene with.
|
// Use this method to select a configuration to create the new scene with.
|
||||||
|
|
||||||
#if !targetEnvironment(macCatalyst)
|
|
||||||
|
|
||||||
if let shortcutItem = options.shortcutItem {
|
|
||||||
if shortcutItem.type == "CheckNumberAction" {
|
|
||||||
self.quickAction = .check
|
|
||||||
} else if shortcutItem.type == "AddVoiceRecordAction" {
|
|
||||||
self.quickAction = .addVoiceRecord
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
|
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -38,26 +38,6 @@ class RecordsController: UIViewController, UITableViewDelegate {
|
|||||||
self.tableView.delegate = self
|
self.tableView.delegate = self
|
||||||
}
|
}
|
||||||
|
|
||||||
override func viewDidAppear(_ animated: Bool) {
|
|
||||||
super.viewDidAppear(animated)
|
|
||||||
self.handleQuickActions()
|
|
||||||
}
|
|
||||||
|
|
||||||
func handleQuickActions() {
|
|
||||||
guard let ad = UIApplication.shared.delegate as? AppDelegate else { return }
|
|
||||||
|
|
||||||
switch ad.quickAction {
|
|
||||||
case .addVoiceRecord:
|
|
||||||
ad.quickAction = .none
|
|
||||||
if let addButton = self.navigationItem.rightBarButtonItem {
|
|
||||||
self.onAddVoiceRecord(addButton)
|
|
||||||
}
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func donateUserActivity() {
|
func donateUserActivity() {
|
||||||
let activityId = "pro.aliencat.autocat.addVoiceRecord"
|
let activityId = "pro.aliencat.autocat.addVoiceRecord"
|
||||||
let activity = NSUserActivity(activityType: activityId)
|
let activity = NSUserActivity(activityType: activityId)
|
||||||
@ -327,8 +307,7 @@ class RecordsController: UIViewController, UITableViewDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func check(number: String, event: VehicleEventDto?) {
|
func check(number: String, event: VehicleEventDto?) {
|
||||||
guard let ad = UIApplication.shared.delegate as? AppDelegate else { return }
|
// TODO: Implement checking number without quick action
|
||||||
ad.quickAction = .checkNumber(number, event)
|
|
||||||
self.tabBarController?.selectedIndex = 0
|
self.tabBarController?.selectedIndex = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -14,14 +14,15 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
|||||||
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
|
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
|
||||||
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
|
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
|
||||||
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
|
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
|
||||||
guard let ad = UIApplication.shared.delegate as? AppDelegate else { return }
|
|
||||||
|
var number: String?
|
||||||
|
|
||||||
if let activity = connectionOptions.userActivities.first {
|
if let activity = connectionOptions.userActivities.first {
|
||||||
|
|
||||||
if let url = activity.webpageURL {
|
if let url = activity.webpageURL {
|
||||||
if let param = URLComponents(url: url, resolvingAgainstBaseURL: false)?.queryItems?.first, let token = param.value {
|
if let param = URLComponents(url: url, resolvingAgainstBaseURL: false)?.queryItems?.first, let token = param.value {
|
||||||
if let jwt = JWT<NumberPayload>(string: token) {
|
if let jwt = JWT<NumberPayload>(string: token) {
|
||||||
ad.quickAction = .openReport(jwt.payload.plateNumber)
|
number = jwt.payload.plateNumber
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -29,7 +30,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
|||||||
|
|
||||||
Task {
|
Task {
|
||||||
try? await registerServices()
|
try? await registerServices()
|
||||||
setupRootController(scene: scene)
|
setupRootController(scene: scene, openReport: number)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +62,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
|||||||
container.register(VehicleServiceProtocol.self, instance: vehicleService)
|
container.register(VehicleServiceProtocol.self, instance: vehicleService)
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupRootController(scene: UIScene) {
|
func setupRootController(scene: UIScene, openReport number: String?) {
|
||||||
guard let windowScene = (scene as? UIWindowScene) else {
|
guard let windowScene = (scene as? UIWindowScene) else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -75,6 +76,9 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
|||||||
self.window?.rootViewController = storyboard.instantiateViewController(identifier: "AuthController")
|
self.window?.rootViewController = storyboard.instantiateViewController(identifier: "AuthController")
|
||||||
} else {
|
} else {
|
||||||
self.window?.rootViewController = storyboard.instantiateViewController(identifier: "MainSplitController")
|
self.window?.rootViewController = storyboard.instantiateViewController(identifier: "MainSplitController")
|
||||||
|
if let number {
|
||||||
|
Task { await openReport(with: number) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if targetEnvironment(macCatalyst)
|
#if targetEnvironment(macCatalyst)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user