app-intent-launcher
v2.2.0
Published
allows opening other apps with app intent on tv os (android focus)
Maintainers
Readme
app-intent-launcher
allows opening other apps with app intent on tv os (android focus)
Install
npm install app-intent-launcher
npx cap syncAPI
echo(...)launchApp(...)getInstalledPackages()searchPackages(...)launchSelf()launchAppWithUri(...)launchVideoApp(...)displayToast(...)- Interfaces
- Type Aliases
echo(...)
echo(options: { value: string; }) => Promise<{ value: string; }>| Param | Type |
| ------------- | ------------------------------- |
| options | { value: string; } |
Returns: Promise<{ value: string; }>
launchApp(...)
launchApp(options: LaunchAppOptions) => Promise<LaunchAppResult>Launches an app by package name (Android).
- packageName: required package id (eg. "com.netflix.ninja")
- component: optional component (package/class) to launch
- extras: optional intent extras sent as key/value strings
- flags: optional integer bitflags for the intent
Returns { success: true } on a fired intent, or { success: false, message } on error.
| Param | Type |
| ------------- | ------------------------------------------------------------- |
| options | LaunchAppOptions |
Returns: Promise<LaunchAppResult>
getInstalledPackages()
getInstalledPackages() => Promise<GetPackagesResult>Returns: Promise<GetPackagesResult>
searchPackages(...)
searchPackages(options: SearchPackagesOptions) => Promise<GetPackagesResult>| Param | Type |
| ------------- | ----------------------------------------------------------------------- |
| options | SearchPackagesOptions |
Returns: Promise<GetPackagesResult>
launchSelf()
launchSelf() => Promise<LaunchAppResult>Returns: Promise<LaunchAppResult>
launchAppWithUri(...)
launchAppWithUri(options: LaunchAppWithUriOptions) => Promise<LaunchAppResult>Launches an app via ACTION_VIEW with a data URI instead of the default LAUNCHER activity. Use for apps like YouTube TV where the standard launcher triggers an OS account picker. Falls back through: explicit component → package-scoped URI → standard launch.
| Param | Type |
| ------------- | --------------------------------------------------------------------------- |
| options | LaunchAppWithUriOptions |
Returns: Promise<LaunchAppResult>
launchVideoApp(...)
launchVideoApp(options: LaunchVideoAppOptions) => Promise<LaunchAppResult>Launches a video app (YouTube TV, YouTube on ATV) into a guaranteed-clean Android task.
Resolves the intent via getLeanbackLaunchIntentForPackage first, then getLaunchIntentForPackage as fallback. Applies FLAG_ACTIVITY_CLEAR_TASK so any leftover poisoned task (e.g. a crashed GMS account picker) is torn down before the app starts — the device always lands on the app's own QR / cast-code sign-in.
Does NOT use ACTION_VIEW with a data URI. That path routes through GMS account resolution and unconditionally triggers the picker on managed devices.
Rejects with "App not installed: <packageName>" if neither resolver finds a launcher activity.
Use the exported PKG_YOUTUBE_TV / PKG_YOUTUBE_ATV constants for the package names.
| Param | Type |
| ------------- | ----------------------------------------------------------------------- |
| options | LaunchVideoAppOptions |
Returns: Promise<LaunchAppResult>
displayToast(...)
displayToast(options: DisplayToastOptions) => Promise<void>Displays an Android Toast message.
| Param | Type |
| ------------- | ------------------------------------------------------------------- |
| options | DisplayToastOptions |
Interfaces
LaunchAppResult
| Prop | Type |
| -------------- | -------------------- |
| success | boolean |
| returned | boolean |
LaunchAppOptions
| Prop | Type |
| ----------------- | ------------------------------------------------------------------------------------ |
| packageName | string |
| appName | string |
| action | string |
| data | string |
| extras | Record<string, string | number | boolean> |
GetPackagesResult
| Prop | Type |
| -------------- | --------------------- |
| packages | string[] |
SearchPackagesOptions
| Prop | Type |
| ----------- | ------------------- |
| query | string |
LaunchAppWithUriOptions
| Prop | Type | Description |
| ------------------- | ------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| packageName | string | |
| dataUri | string | |
| activityClass | string | Optional fully-qualified activity class name. If provided, targets that activity directly (strongest account-picker bypass). |
LaunchVideoAppOptions
| Prop | Type | Description |
| ----------------- | ------------------- | ------------------------------------------------------------------------------------------------------ |
| packageName | string | Package name of the video app to launch. Use the PKG_YOUTUBE_TV or PKG_YOUTUBE_ATV exported constants. |
DisplayToastOptions
| Prop | Type |
| -------------- | ------------------------------ |
| msg | string |
| duration | 'short' | 'long' |
Type Aliases
Record
Construct a type with a set of properties K of type T
{ [P in K]: T; }
