1# @ohos.app.appstartup.StartupConfigEntry (AppStartup Configuration) 2<!--Kit: Ability Kit--> 3<!--Subsystem: Ability--> 4<!--Owner: @yzkp--> 5<!--Designer: @yzkp--> 6<!--Tester: @lixueqing513--> 7<!--Adviser: @huipeizi--> 8 9 10The module provides APIs for configuring AppStartup. 11 12> **NOTE** 13> 14> The initial APIs of this module are supported since API version 12. Newly added APIs will be marked with a superscript to indicate their earliest API version. 15> 16> The APIs of this module can be used only in the stage model. 17 18## Modules to Import 19 20```ts 21import { StartupConfigEntry } from '@kit.AbilityKit'; 22``` 23 24## StartupConfigEntry.onConfig 25 26onConfig?(): StartupConfig 27 28Called during application startup to configure AppStartup. 29 30**System capability**: SystemCapability.Ability.AppStartup 31 32**Return value** 33 34| Type| Description| 35| -------- | -------- | 36| StartupConfig | AppStartup configuration.| 37 38**Example** 39 40```ts 41import { StartupConfig, StartupConfigEntry, StartupListener } from '@kit.AbilityKit'; 42import { BusinessError } from '@kit.BasicServicesKit'; 43import { hilog } from '@kit.PerformanceAnalysisKit'; 44 45export default class MyStartupConfigEntry extends StartupConfigEntry { 46 onConfig() { 47 hilog.info(0x0000, 'testTag', `onConfig`); 48 let onCompletedCallback = (error: BusinessError<void>) => { 49 hilog.info(0x0000, 'testTag', `onCompletedCallback`); 50 if (error) { 51 hilog.info(0x0000, 'testTag', 'onCompletedCallback: %{public}d, message: %{public}s', error.code, error.message); 52 } else { 53 hilog.info(0x0000, 'testTag', `onCompletedCallback: success.`); 54 } 55 } 56 let startupListener: StartupListener = { 57 'onCompleted': onCompletedCallback 58 } 59 let config: StartupConfig = { 60 'timeoutMs': 10000, 61 'startupListener': startupListener 62 } 63 return config; 64 } 65} 66``` 67 68## StartupConfigEntry.onRequestCustomMatchRule<sup>20+</sup> 69 70onRequestCustomMatchRule(want: Want): string 71 72Called to obtain a custom matching rule during application launch. Depending on the parameters in the Want passed in, you can return various custom rules to match against the **customization** field in **matchRules** configured for the startup task. If a match is successful, the task is executed automatically. This API can be used to further refine the matching rules when a startup scenario cannot match a startup task through the URI, action, or intent name. For details, see [Adding Task Matching Rules](../../application-models/app-startup.md#adding-task-matching-rules). 73 74**System capability**: SystemCapability.Ability.AppStartup 75 76**Parameters** 77 78| Name| Type| Mandatory| Description| 79| -------- | -------- | -------- | -------- | 80| want | [Want](js-apis-app-ability-want.md) | Yes| Want information about the target UIAbility.| 81 82**Return value** 83 84| Type| Description| 85| -------- | -------- | 86| string | Custom matching rule, which is used to determine whether to automatically execute the task.| 87 88**Example** 89 90```ts 91import { StartupConfig, StartupConfigEntry, StartupListener, Want } from '@kit.AbilityKit'; 92import { BusinessError } from '@kit.BasicServicesKit'; 93import { hilog } from '@kit.PerformanceAnalysisKit'; 94 95export default class MyStartupConfigEntry extends StartupConfigEntry { 96 97 // ... 98 99 onRequestCustomMatchRule(want: Want): string { 100 if (want?.parameters?.customParam == 'param1') { 101 return 'customRule1'; 102 } 103 return ''; 104 } 105} 106``` 107