1# Using startAbilityByType to Start a Financial Application
2
3This topic describes how to open the vertical domain panel of financial applications.
4
5## Parameters on the Financial Application Panel
6
7If the **type** field in **startAbilityByType** is set to **finance**, **wantParam** contains the following properties.
8
9| Name           | Type                                                        | Mandatory| Description|
10| -------------------- | ------------------------------------------------------------ | -------- | -------- |
11| sceneType            | number                          | No| The options are as follows: 1: transfer; 2: credit card repayment. The default value is **1**.|
12| bankCardNo      | string                                               | No | Bank card number.|
13
14## Developing a Caller Application
151. Import the **ohos.app.ability.common** module.
16    ```ts
17    import { common } from '@kit.AbilityKit';
18    ```
192. Construct parameters and call the **startAbilityByType** API.
20
21    ```ts
22    let context = getContext(this) as common.UIAbilityContext;
23    let wantParam: Record<string, Object> = {
24      'sceneType': 1,
25      "bankCardNo": '123456789'
26    };
27    let abilityStartCallback: common.AbilityStartCallback = {
28      onError: (code: number, name: string, message: string) => {
29        console.log(`onError code ${code} name: ${name} message: ${message}`);
30      },
31      onResult: (result)=>{
32        console.log(`onResult result: ${JSON.stringify(result)}`);
33      }
34    }
35
36    context.startAbilityByType("finance", wantParam, abilityStartCallback,
37        (err) => {
38            if (err) {
39                console.error(`startAbilityByType fail, err: ${JSON.stringify(err)}`);
40            } else {
41                console.log(`success`);
42            }
43    });
44    ```
45    Effect
46
47    ![Effect example](./figures/start-finance-panel.png)
48
49## Developing a Target Application
50
511. Configure [uris](../quick-start/module-configuration-file.md#skills) in the **module.json5** file.
52   1. Set the **linkFeature** field to declare the features supported by the application so that the system can match the application against all the installed applications on the device. The options are as follows:
53
54        | Value          | Description                        |
55        | -------------- | ---------------------------- |
56        | Transfer     | The application supports transfer.		|
57        | CreditCardRepayment      | The application supports credit card repayment.	|
58   2. Set **scheme**, **host**, **port**, and **path** or **pathStartWith** to match the URIs in Want to distinguish different features.
59
60    ```json
61    {
62      "abilities": [
63          {
64          "skills": [
65              {
66              "uris": [
67                  {
68                  "scheme": "finance", // It is for reference only. Ensure that the declared URI can be started by external systems.
69                  "host": "transfer",
70                  "path": "",
71                  "linkFeature": "Transfer" // Declare that the application supports transfer.
72                  },
73                  {
74                  "scheme": "finance", // It is for reference only. Ensure that the declared URI can be started by external systems.
75                  "host": "credit_card_repayment",
76                  "path": "",
77                  "linkFeature": "CreditCardRepayment" // Declare that the application supports credit card repayment.
78                  }
79              ]
80              }
81          ]
82          }
83      ]
84    }
85    ```
86
872. Parse and process the parameters transferred from the panel.
88
89    ```ts
90    UIAbility::onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void
91    ```
92
93    The **want.uri** parameter carries the URI corresponding to **linkFeature** configured by the target application.
94
95    The **want.parameters** parameter carries the parameters transferred by the caller application, as described in the table below.
96
97    | Name         | Type                                                        | Mandatory| Description|
98    | -------------------- | ------------------------------------------------------------ | -------- | -------- |
99    | bankCardNo  | string | No | Bank card number.|
100
101    The application can develop different style pages based on the features defined in [linkFeature](../quick-start/module-configuration-file.md#skills), such as transfer and credit card repayment, as well as the received URI.
102
103**Sample Code**
104
105```ts
106import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
107import { hilog } from '@kit.PerformanceAnalysisKit';
108import { window } from '@kit.ArkUI';
109
110const TAG = 'EntryAbility'
111
112export default class EntryAbility extends UIAbility {
113    windowStage: window.WindowStage | null = null;
114
115    uri?: string;
116    bankCardNo?: string;
117
118    onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
119        hilog.info(0x0000, TAG, `onCreate, want=${JSON.stringify(want)}`);
120        super.onCreate(want, launchParam);
121        this.parseWant(want);
122    }
123
124    onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam): void {
125        hilog.info(0x0000, TAG, `onNewWant, want=${JSON.stringify(want)}`);
126        super.onNewWant(want, launchParam);
127        this.parseWant(want);
128        if (!this.windowStage) {
129            hilog.error(0x0000, TAG, 'windowStage is null');
130            this.context.terminateSelf();
131            return;
132        }
133        this.loadPage(this.windowStage);
134    }
135
136    private parseWant(want: Want): void {
137        this.uri = want.uri as string | undefined;
138        this.bankCardNo = want.parameters?.bankCardNo as string | undefined;
139    }
140
141    private loadPage(windowStage: window.WindowStage): void {
142        hilog.info(0x0000, TAG, `loadPage, uri=${this.uri}`);
143        if (this.uri === 'finance://transfer') {
144            // Construct parameters for the transfer scenario.
145            const storage: LocalStorage = new LocalStorage({
146                "bankCardNo": this.bankCardNo
147            } as Record<string, Object>);
148            // Open the transfer page.
149            windowStage.loadContent('pages/TransferPage', storage)
150        } else if (this.uri === 'finance://credit_card_repayment') {
151            // Construct parameters for the credit card repayment scenario.
152            const storage: LocalStorage = new LocalStorage({
153                "bankCardNo": this.bankCardNo
154            } as Record<string, Object>);
155            // Open the credit card repayment page.
156            windowStage.loadContent('pages/CreditCardRepaymentPage', storage)
157        } else {
158            // Display the home page by default.
159            windowStage.loadContent('pages/Index', (err) => {
160                if (err.code) {
161                    hilog.error(0x0000, TAG, 'Failed to load the content. Cause: %{public}s',
162                        JSON.stringify(err) ?? '');
163                    return;
164                }
165                hilog.info(0x0000, TAG, 'Succeeded in loading the content.');
166            });
167        }
168    }
169
170    onDestroy(): void {
171        hilog.info(0x0000, TAG, `onDestroy`);
172    }
173
174    onWindowStageCreate(windowStage: window.WindowStage): void {
175        hilog.info(0x0000, TAG, `onWindowStageCreate`);
176        this.windowStage = windowStage;
177        this.loadPage(this.windowStage);
178    }
179
180    onWindowStageDestroy(): void {
181        hilog.info(0x0000, TAG, '%{public}s', 'Ability onWindowStageDestroy');
182    }
183
184    onForeground(): void {
185        hilog.info(0x0000, TAG, '%{public}s', 'Ability onForeground');
186    }
187
188    onBackground(): void {
189        hilog.info(0x0000, TAG, '%{public}s', 'Ability onBackground');
190    }
191}
192```
193