LynxShortcuts
Hears the app's shortcuts: things the app does that the person runs without opening it first. On iOS they run from Siri, Spotlight and the Shortcuts app, and on Android from the app icon's menu. import { LynxShortcuts, type LynxShortcut, type LynxShortcutHandler } from '@blotch/angular-lynx';
Add shortcuts for Siri and the app icon shows it in use.
Set it up in angular.json
List the shortcuts in the build target's shortcuts option:
ng build --platform checks them, says what's wrong, and builds them into the apps: App Intents on iOS, static shortcuts on Android. The shortcuts option below lists every field.
Usage
API
LynxShortcuts
The phone brings the app to the front, starting it if it has to, and then the shortcut arrives here.
- A shortcut with a
routemakes the router navigate to it, and then its handlers are called. That needsprovideRouter()from@blotch/angular-lynx. - A route needs no code:
provideRouter()creates the service as the app starts.
LynxShortcuts.on()
Calls handler each time the person runs the shortcut id, the id it has in angular.json.
- Every handler registered for the ID is called, in the order they were registered.
- A handler that throws is reported to Angular's
ErrorHandler, and the others are still called. - A shortcut nothing handled waits. One that ran before any handler was registered for its ID is kept for the first handler registered for it. That handler is called once the code that registered it has finished. It's how the shortcut that started the app reaches a component created later, such as the screen its
routeleads to. - The handler goes with its injection context. Called from one, such as a constructor, the handler is removed when the component or service is destroyed. Pass
injectorto tie it to another. Outside one, it stays until it's removed. - Returns a function that removes the handler.
LynxShortcut
The shortcuts option
Each entry of the build target's shortcuts in angular.json:
iOS takes up to 10 shortcuts from an app.
