diff --git a/AgileWorks/AgileWorks/App/AppDelegate.swift b/AgileWorks/AgileWorks/App/AppDelegate.swift index 448b09fda637360529a604ec9bd9fbc47a322db0..8392a88eb1e49cf51f7c77cbf687be35c26160f3 100644 --- a/AgileWorks/AgileWorks/App/AppDelegate.swift +++ b/AgileWorks/AgileWorks/App/AppDelegate.swift @@ -73,22 +73,31 @@ class AppDelegate: UIResponder, UIApplicationDelegate { } //ios13の場合 - var statusUrl = url.absoluteString - let result: URL - if statusUrl.contains("atled-aw:/") { - statusUrl = statusUrl.replacingOccurrences(of:"atled-aw:/", with:"") - result = getStatusURL(status: statusUrl) - print(result) - return Linker.handleDeeplink(url: result) + if url.scheme == urlSchemeName { + var strUrl = url.absoluteString + //指定した書類状態の取得、アプリ起動のみの場合は飛ばす + if strUrl.contains("/") { + let result: URL + var scheme = urlScheme + // 不要な"/"を取り除く + let delIdx = scheme.index(scheme.endIndex, offsetBy: -1) + scheme.remove(at: delIdx) + //scheme以降の取得 + strUrl = strUrl.replacingOccurrences(of: scheme, with: "") + //遷移URLの取得 + result = getStatusURL(status: strUrl) + return Linker.handleDeeplink(url: result) + } } return Linker.handleDeeplink(url: url) } func getStatusURL(status: String) -> URL { - if status == "nil" { + if status == "nil" { //「仕事」タブを開く return URL(string: Configuration.shared.awURL + "/" + (KeychainDataStore().readContextPath() ?? "") + "/Broker/Mobile#work")! + }else { //指定した書類状態を開く + return URL(string: Configuration.shared.awURL + "/" + (KeychainDataStore().readContextPath() ?? "") + "/Broker/Mobile#docList_" + status)! } - return URL(string: Configuration.shared.awURL + "/" + (KeychainDataStore().readContextPath() ?? "") + "/Broker/Mobile#docList_" + status)! } // Notification受信 diff --git a/AgileWorks/AgileWorks/Main/Wireframe/MainTabBarViewWireframe.swift b/AgileWorks/AgileWorks/Main/Wireframe/MainTabBarViewWireframe.swift index f076f63b24307f48c17f49239379c46aa17534c0..8b6e875888248e58577f8ce35aaf615223a64881 100644 --- a/AgileWorks/AgileWorks/Main/Wireframe/MainTabBarViewWireframe.swift +++ b/AgileWorks/AgileWorks/Main/Wireframe/MainTabBarViewWireframe.swift @@ -34,6 +34,10 @@ extension MainTabBarViewWireframeImpl: MainTabBarViewWireframe { } //ウィジェットからの起動 func showApprovalDetail(url: String) { + //アプリ起動のみ + if url.contains(urlSchemeName) { + return + } //アラートが表示されていたら画面遷移しない if alertCheck() { return diff --git a/AgileWorks/Common/WidgetView.swift b/AgileWorks/Common/WidgetView.swift index 19fadfa7fd17a7d473d31b8964ed0de155b584cf..c848a97cdf6f9523f4a2a32ad7b4de5cb3f5a846 100644 --- a/AgileWorks/Common/WidgetView.swift +++ b/AgileWorks/Common/WidgetView.swift @@ -20,6 +20,9 @@ let share = "SHARE" let shared = "SHARED" let futurePass = "FUTUREPASS" +let urlSchemeName = "atled-aw" +let urlScheme = urlSchemeName + "://" + //ウィジェット選択のプレビュー画面などで表示させる項目 func previewItems() -> [ApprovalItem] { var items = [ApprovalItem]() @@ -54,7 +57,16 @@ struct StatusCheckWidgetView: View { if entry.message == "-" { StatusBoxView(entry: entry) } else { //ログイン・コネクションエラー - FailureWidgetView(entry: entry) + if #available(iOS 14.0, *) { + FailureWidgetView(entry: entry) + }else { + FailureWidgetView(entry: entry) + .onTapGesture { + if entry.viewController != nil { + entry.viewController!.extensionContext?.open(NSURL(fileURLWithPath: urlScheme)as URL, completionHandler: nil) + } + } + } } } } @@ -137,7 +149,7 @@ struct StatusBoxView: View { var body: some View { GeometryReader { geometry in - //ios13・14状態確認ウィジェット + //ios13・14~状態確認ウィジェット if geometry.size.height > kCellDefaultHight { VStack(spacing: 5) { ForEach(0.. String { //スキーム+ステータスで設定 - let urlString = "atled-aw://" - if let status = getStatus() { - return urlString + status - } - return urlString + "nil" + if let status = getStatus() { + return urlScheme + status + } + return urlScheme + "nil" } var body: some View { diff --git a/AgileWorks/TodayExtension/View/TodayViewController.swift b/AgileWorks/TodayExtension/View/TodayViewController.swift index 506cb6f81112dfa63260c48c830b0829f4568f02..7869ee89fd3cb47bdfc6e6d468b0d9f0e9aafa6a 100644 --- a/AgileWorks/TodayExtension/View/TodayViewController.swift +++ b/AgileWorks/TodayExtension/View/TodayViewController.swift @@ -34,10 +34,10 @@ class TodayViewController: UIViewController, NCWidgetProviding { rootView = StatusCheckWidgetView(entry: EntryData(approvalItems: self.approvalItems, message: nil, viewController: self)) completionHandler(.newData) case .nodate(let message): - rootView = StatusCheckWidgetView(entry: EntryData(approvalItems: [ApprovalItem](), message: message, viewController: nil)) + rootView = StatusCheckWidgetView(entry: EntryData(approvalItems: [ApprovalItem](), message: message, viewController: self)) completionHandler(.noData) case .failure(let message): - rootView = StatusCheckWidgetView(entry: EntryData(approvalItems: previewItems(), message: message, viewController: nil)) + rootView = StatusCheckWidgetView(entry: EntryData(approvalItems: previewItems(), message: message, viewController: self)) completionHandler(.failed) } self.callWidgetView(vc: UIHostingController(rootView: rootView))