Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/specs/app-handoff/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion docs/specs/app-handoff/requirements.md
Original file line number Diff line number Diff line change
Expand Up @@ -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=<SKU>&app=<app key>`:
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
Expand Down
20 changes: 20 additions & 0 deletions ios/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!-- The keys Xcode can't generate for the iPad and iPhone app; the rest come from the build settings. The
`scrollkeeper` link lets another toolkit app see that Scrollkeeper is installed and bring it forward
(app-handoff 2.9). -->
<plist version="1.0">
<dict>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>io.github.scooper4711.Scrollkeeper.handoff</string>
<key>CFBundleURLSchemes</key>
<array>
<string>scrollkeeper</string>
</array>
</dict>
</array>
</dict>
</plist>
2 changes: 2 additions & 0 deletions ios/Scrollkeeper.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
27 changes: 27 additions & 0 deletions ios/UITests/RequestLinkUITests.swift
Original file line number Diff line number Diff line change
@@ -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")
}
}
Loading