diff --git a/docs/specs/app-handoff/design.md b/docs/specs/app-handoff/design.md index f1f0987..812c883 100644 --- a/docs/specs/app-handoff/design.md +++ b/docs/specs/app-handoff/design.md @@ -105,6 +105,9 @@ the state of the download the request waits for. While `handoffFiles` waits, - `scripts/build-app.sh` declares the `scrollkeeper` URL scheme in `CFBundleURLTypes`. +- The iPad app declares the same scheme in `ios/Info.plist`, which Xcode + merges into the Info.plist it generates (2.9). Nothing there reads the link: + the system brings the app forward and SwiftUI opens no window for it. - The Mac `AppDelegate` owns the `LibraryStore`, starts it at launch and takes the links in `application(_:open:)`, so a request is answered whether or not a library window is open, including the one that launched the app. The diff --git a/docs/specs/app-handoff/requirements.md b/docs/specs/app-handoff/requirements.md index 1623447..f9b006d 100644 --- a/docs/specs/app-handoff/requirements.md +++ b/docs/specs/app-handoff/requirements.md @@ -58,7 +58,10 @@ does the same for any title with a PDF. to download, the download failed, the requesting app is not installed, or the download holds no file the requesting app can open. 2.8 One request handles one title (5.3b). -2.9 The iPad app does not handle open requests. +2.9 The iPad app does not handle open requests. It does register the + `scrollkeeper` link, so another toolkit app can see that it is installed + and bring it forward for the user to download a title there; whatever the + link asks for, it only brings the app forward, in the window it has. 2.10 The Mac app also handles `scrollkeeper://download?sku=&app=`: the same as an open request, except that nothing is opened and the library window's selection is left alone. The requesting app learns that diff --git a/ios/Info.plist b/ios/Info.plist new file mode 100644 index 0000000..12834a4 --- /dev/null +++ b/ios/Info.plist @@ -0,0 +1,20 @@ + + + + + + CFBundleURLTypes + + + CFBundleURLName + io.github.scooper4711.Scrollkeeper.handoff + CFBundleURLSchemes + + scrollkeeper + + + + + diff --git a/ios/Scrollkeeper.xcodeproj/project.pbxproj b/ios/Scrollkeeper.xcodeproj/project.pbxproj index cb0e616..518b545 100644 --- a/ios/Scrollkeeper.xcodeproj/project.pbxproj +++ b/ios/Scrollkeeper.xcodeproj/project.pbxproj @@ -254,6 +254,7 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = Info.plist; INFOPLIST_KEY_CFBundleDisplayName = Scrollkeeper; INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities"; INFOPLIST_KEY_ITSAppUsesNonExemptEncryption = NO; @@ -285,6 +286,7 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = Info.plist; INFOPLIST_KEY_CFBundleDisplayName = Scrollkeeper; INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities"; INFOPLIST_KEY_ITSAppUsesNonExemptEncryption = NO; diff --git a/ios/UITests/RequestLinkUITests.swift b/ios/UITests/RequestLinkUITests.swift new file mode 100644 index 0000000..12ab806 --- /dev/null +++ b/ios/UITests/RequestLinkUITests.swift @@ -0,0 +1,27 @@ +import XCTest + +/// The `scrollkeeper` link another toolkit app opens to bring Scrollkeeper forward (app-handoff 2.9). +final class RequestLinkUITests: XCTestCase { + override func setUp() { + continueAfterFailure = false + } + + func testTheLinkBringsTheAppForwardInTheWindowItHas() throws { + let app = XCUIApplication() + app.launchArguments = ["-ScrollkeeperDemo"] + app.launch() + let scope = app.staticTexts["Downloaded"].firstMatch + XCTAssertTrue(scope.waitForExistence(timeout: 30), "the sidebar didn't appear") + scope.tap() + let library = app.navigationBars["Downloaded"] + XCTAssertTrue(library.waitForExistence(timeout: 5), app.debugDescription) + XCUIDevice.shared.press(.home) + XCTAssertTrue(app.wait(for: .runningBackground, timeout: 10), "the app didn't leave the foreground") + + XCUIDevice.shared.system.open(try XCTUnwrap(URL(string: "scrollkeeper://"))) + + XCTAssertTrue(app.wait(for: .runningForeground, timeout: 10), "the link didn't bring the app forward") + // A window opened for the link would show All Titles, as a new one does. + XCTAssertTrue(library.waitForExistence(timeout: 10), "the link opened a window of its own") + } +}