Defer System Gestures Web App API
Introduction
This API is in reference to the “preferredScreenEdgesDeferringSystemGestures” instance properly for apple devices. This refers to the ability to make system gestures require two actions, instead of one, to prevent accidental gestures triggering on iOS, iPadOS, Mac Catalyst, and visionOS.
Use Cases
- Cloud Gaming PWAs to prevent academically app closures.
- Other instances where closing an application on accident would not be ideal for the user.
Proposed Solution
- Created a web standard instance that works with progressive web applications and when Fullscreen API is enabled.
- When the gesture is performed it should be ignored unless it is performed twice.
- If a gesture is performed once, after around five seconds without a second gesture, the gesture count needs to be reset.
Reference
This comes from Apple’s support for this feature in native applications. The developer instance property link can be found here:
https://developer.apple.com/documentation/uikit/uiviewcontroller/preferredscreenedgesdeferringsystemgestures
Here is an example from Xcode that defers system gestures from the top, bottom, right, and left of the device:
import UIKit
class GameViewController: UIViewController { override var preferredScreenEdgesDeferringSystemGestures: UIRectEdge { return [.top, .bottom, .right, .left] } }
I believe I had the wrong instance property linked. This is fixed now. This API would be used to prevent accidental web app closures. The instance property linked is used for games on the app store to make it so it takes two swipes to go home instead of one.
If this proposal were to design the API independently, it might conflict with the CloseWatcherAPI, at least from the perspective of developers. This is because users sometimes quickly navigate back to the previous page or close certain pop-ups by swiping.
Therefore, using the number of back presses to define 'closing the app' might lead to some confusion.
Personally, I think we could combine the number of pointers with the swipe distance to determine whether the app should close. For example, if the user only intends to go back or close a window, a light swipe on the edge would suffice. However, to close the app, we could trigger the display of a close button in the center of the screen after the second swipe starts. If the gesture continues and the user releases their finger over the button, the app will close.
Additionally, from a visual perspective, the closer the swipe is to the close button, the more prominent the button becomes. This would create a better visual balance as well.
I have updated this proposal again to aline with current iOS 26 designs.
This would be different than the CloseWatcher API because it would be able to defer/delay all system gestures in a web app.
Unless you think it is possible to defer system gestures with the CloseWatcher API?
Example systems Gestures that need to be controllable:
- iPadOS 3 Finger swipe left/right to switch apps
- iOS/iPadOS Swipe down to open notification center and control center
- iOS/iPadOS Swipe up to go to the home screen
- iOS/iPadOS Double tap bottom of screen to start typing to Siri/ Apple Intelligence