LynxShortcuts
Hears the app's shortcuts: the things angular.json's shortcuts says the app does, which the person runs from Siri, Spotlight and the Shortcuts app on iOS, and from the app icon's menu on Android. import { LynxShortcuts, type LynxShortcut, type LynxShortcutHandler } from '@blotch/angular-lynx';
Add shortcuts for Siri and the app icon shows it in use.
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 route makes the router navigate to it, when the app uses provideRouter() from @blotch/angular-lynx, and then its handlers are called. provideRouter() creates the service as the app starts, so a route needs no code.
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, which is called once the code that registered it has finished. That'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. ng build --platform checks all of this and says what's wrong, and builds the shortcuts into the app: App Intents on iOS, static shortcuts on Android.
