• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.app.form.formHost (FormHost)
2
3FormHost模块提供了卡片使用方相关接口的能力,包括对使用方同一用户下安装的卡片进行删除、释放、请求更新、获取卡片信息、状态等操作。
4
5> **说明:**
6>
7> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
8> 本模块接口均为系统接口。
9
10## 导入模块
11
12```ts
13import formHost from '@ohos.app.form.formHost';
14```
15
16## deleteForm
17
18deleteForm(formId: string, callback: AsyncCallback<void>): void
19
20删除指定的卡片。调用此方法后,应用程序将无法使用该卡片,卡片管理器服务不再保留有关该卡片的信息。使用callback异步回调。
21
22**需要权限**:ohos.permission.REQUIRE_FORM
23
24**系统能力**:SystemCapability.Ability.Form
25
26**参数:**
27
28| 参数名 | 类型    | 必填 | 说明    |
29| ------ | ------ | ---- | ------- |
30| formId | string | 是   | 卡片标识。 |
31| callback | AsyncCallback<void> | 是 | 回调函数。当删除指定的卡片成功,error为undefined,否则为错误对象 |
32
33**错误码:**
34
35| 错误码ID | 错误信息 |
36| -------- | -------- |
37| 201 | Permissions denied. |
38| 202 | The application is not a system application. |
39| 401 | If the input parameter is not valid parameter. |
40| 16500050 | An IPC connection error happened. |
41| 16500060 | A service connection error happened, please try again later. |
42| 16501000 | An internal functional error occurred. |
43| 16501001 | The ID of the form to be operated does not exist. |
44| 16501003 | The form can not be operated by the current application. |
45
46以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
47
48**示例:**
49
50```ts
51try {
52  var formId = '12400633174999288';
53  formHost.deleteForm(formId, (error, data) => {
54  if (error) {
55    console.log('formHost deleteForm, error:' + JSON.stringify(error));
56  } else {
57    console.log('formHost deleteForm success');
58  }
59  });
60} catch (error) {
61  console.log(`catch err->${JSON.stringify(error)}`);
62}
63
64```
65
66## deleteForm
67
68deleteForm(formId: string): Promise<void>
69
70删除指定的卡片。调用此方法后,应用程序将无法使用该卡片,卡片管理器服务不再保留有关该卡片的信息。使用Promise异步回调。
71
72**需要权限**:ohos.permission.REQUIRE_FORM
73
74**系统能力**:SystemCapability.Ability.Form
75
76**参数:**
77
78| 参数名 | 类型    | 必填 | 说明    |
79| ------ | ------ | ---- | ------- |
80| formId | string | 是   | 卡片标识。 |
81
82**返回值:**
83
84| 类型 | 说明 |
85| -------- | -------- |
86| Promise<void> | 无返回结果的Promise对象。 |
87
88
89**错误码:**
90
91| 错误码ID | 错误信息 |
92| -------- | -------- |
93| 201 | Permissions denied. |
94| 202 | The application is not a system application. |
95| 401 | If the input parameter is not valid parameter. |
96| 16500050 | An IPC connection error happened. |
97| 16500060 | A service connection error happened, please try again later. |
98| 16501000 | An internal functional error occurred. |
99| 16501001 | The ID of the form to be operated does not exist. |
100| 16501003 | The form can not be operated by the current application. |
101
102以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
103
104**参数:**
105
106```ts
107try {
108  var formId = '12400633174999288';
109  formHost.deleteForm(formId).then(() => {
110    console.log('formHost deleteForm success');
111  }).catch((error) => {
112    console.log('formHost deleteForm, error:' + JSON.stringify(error));
113  });
114} catch(error) {
115  console.log(`catch err->${JSON.stringify(error)}`);
116}
117```
118
119## releaseForm
120
121releaseForm(formId: string, callback: AsyncCallback<void>): void
122
123释放指定的卡片。调用此方法后,应用程序将无法使用该卡片,但卡片管理器服务仍然保留有关该卡片的缓存信息和存储信息。使用callback异步回调。
124
125**需要权限**:ohos.permission.REQUIRE_FORM
126
127**系统能力**:SystemCapability.Ability.Form
128
129**参数:**
130
131| 参数名 | 类型    | 必填 | 说明    |
132| ------ | ------ | ---- | ------- |
133| formId | string | 是   | 卡片标识。 |
134| callback | AsyncCallback<void> | 是 | 回调函数。当释放指定的卡片成功,error为undefined;否则为错误对象。|
135
136**错误码:**
137
138| 错误码ID | 错误信息 |
139| -------- | -------- |
140| 201 | Permissions denied. |
141| 202 | The application is not a system application. |
142| 401 | If the input parameter is not valid parameter. |
143| 16500050 | An IPC connection error happened. |
144| 16500060 | A service connection error happened, please try again later. |
145| 16501000 | An internal functional error occurred. |
146| 16501001 | The ID of the form to be operated does not exist. |
147| 16501003 | The form can not be operated by the current application. |
148
149以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
150
151**示例:**
152
153```ts
154try {
155  var formId = '12400633174999288';
156  formHost.releaseForm(formId, (error, data) => {
157    if (error) {
158      console.log('formHost releaseForm, error:' + JSON.stringify(error));
159    }
160  });
161} catch(error) {
162    console.log(`catch err->${JSON.stringify(error)}`);
163}
164```
165
166## releaseForm
167
168releaseForm(formId: string, isReleaseCache: boolean, callback: AsyncCallback<void>): void
169
170释放指定的卡片。调用此方法后,应用程序将无法使用该卡片,卡片管理器服务保留有关该卡片的存储信息,可以选择是否保留缓存信息。使用callback异步回调。
171
172**需要权限**:ohos.permission.REQUIRE_FORM
173
174**系统能力**:SystemCapability.Ability.Form
175
176**参数:**
177
178| 参数名         | 类型     | 必填 | 说明        |
179| -------------- | ------  | ---- | ----------- |
180| formId         | string  | 是   | 卡片标识。     |
181| isReleaseCache | boolean | 是   | 是否释放缓存。 |
182| callback | AsyncCallback<void> | 是 | 回调函数。当释放指定的卡片成功,error为undefined;否则为错误对象。 |
183
184**错误码:**
185
186| 错误码ID | 错误信息 |
187| -------- | -------- |
188| 201 | Permissions denied. |
189| 202 | The application is not a system application. |
190| 401 | If the input parameter is not valid parameter. |
191| 16500050 | An IPC connection error happened. |
192| 16500060 | A service connection error happened, please try again later. |
193| 16501000 | An internal functional error occurred. |
194| 16501001 | The ID of the form to be operated does not exist. |
195| 16501003 | The form can not be operated by the current application. |
196
197以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
198
199**示例:**
200
201```ts
202try {
203  var formId = '12400633174999288';
204  formHost.releaseForm(formId, true, (error, data) => {
205    if (error) {
206      console.log('formHost releaseForm, error:' + JSON.stringify(error));
207    }
208  });
209} catch(error) {
210    console.log(`catch err->${JSON.stringify(error)}`);
211}
212```
213
214## releaseForm
215
216releaseForm(formId: string, isReleaseCache?: boolean): Promise<void>
217
218释放指定的卡片。调用此方法后,应用程序将无法使用该卡片,卡片管理器服务保留有关该卡片的存储信息,可以选择是否保留缓存信息。使用Promise异步回调。
219
220**需要权限**:ohos.permission.REQUIRE_FORM
221
222**系统能力**:SystemCapability.Ability.Form
223
224**参数:**
225
226| 参数名         | 类型     | 必填 | 说明        |
227| -------------- | ------  | ---- | ----------- |
228| formId         | string  | 是   | 卡片标识。     |
229| isReleaseCache | boolean | 否   | 是否释放缓存。 |
230
231**返回值:**
232
233| 类型 | 说明 |
234| -------- | -------- |
235| Promise<void> | 无返回结果的Promise对象。 |
236
237**错误码:**
238
239| 错误码ID | 错误信息 |
240| -------- | -------- |
241| 201 | Permissions denied. |
242| 202 | The application is not a system application. |
243| 401 | If the input parameter is not valid parameter. |
244| 16500050 | An IPC connection error happened. |
245| 16500060 | A service connection error happened, please try again later. |
246| 16501000 | An internal functional error occurred. |
247| 16501001 | The ID of the form to be operated does not exist. |
248| 16501003 | The form can not be operated by the current application. |
249
250以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
251
252**示例:**
253
254```ts
255try {
256  var formId = '12400633174999288';
257  formHost.releaseForm(formId, true).then(() => {
258    console.log('formHost releaseForm success');
259  }).catch((error) => {
260    console.log('formHost releaseForm, error:' + JSON.stringify(error));
261  });
262} catch(error) {
263    console.log(`catch err->${JSON.stringify(error)}`);
264}
265```
266
267## requestForm
268
269requestForm(formId: string, callback: AsyncCallback<void>): void
270
271请求卡片更新。使用callback异步回调。
272
273**需要权限**:ohos.permission.REQUIRE_FORM
274
275**系统能力**:SystemCapability.Ability.Form
276
277**参数:**
278
279| 参数名 | 类型    | 必填 | 说明    |
280| ------ | ------ | ---- | ------- |
281| formId | string | 是   | 卡片标识。 |
282| callback | AsyncCallback<void> | 是 | 回调函数。当请求卡片更新成功,error为undefined;否则为错误对象。 |
283
284**错误码:**
285
286| 错误码ID | 错误信息 |
287| -------- | -------- |
288| 201 | Permissions denied. |
289| 202 | The application is not a system application. |
290| 401 | If the input parameter is not valid parameter. |
291| 16500050 | An IPC connection error happened. |
292| 16500060 | A service connection error happened, please try again later. |
293| 16501000 | An internal functional error occurred. |
294| 16501001 | The ID of the form to be operated does not exist. |
295| 16501003 | The form can not be operated by the current application. |
296
297以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
298
299**示例:**
300
301```ts
302try {
303  var formId = '12400633174999288';
304  formHost.requestForm(formId, (error, data) => {
305    if (error) {
306      console.log('formHost requestForm, error:' + JSON.stringify(error));
307    }
308  });
309} catch(error) {
310    console.log(`catch err->${JSON.stringify(error)}`);
311}
312```
313
314## requestForm
315
316requestForm(formId: string): Promise<void>
317
318请求卡片更新。使用Promise异步回调。
319
320**需要权限**:ohos.permission.REQUIRE_FORM
321
322**系统能力**:SystemCapability.Ability.Form
323
324**参数:**
325
326| 参数名 | 类型    | 必填 | 说明    |
327| ------ | ------ | ---- | ------- |
328| formId | string | 是   | 卡片标识。 |
329
330**返回值:**
331
332| 类型 | 说明 |
333| -------- | -------- |
334| Promise<void> | 无返回结果的Promise对象。 |
335
336**错误码:**
337
338| 错误码ID | 错误信息 |
339| -------- | -------- |
340| 201 | Permissions denied. |
341| 202 | The application is not a system application. |
342| 401 | If the input parameter is not valid parameter. |
343| 16500050 | An IPC connection error happened. |
344| 16500060 | A service connection error happened, please try again later. |
345| 16501000 | An internal functional error occurred. |
346| 16501001 | The ID of the form to be operated does not exist. |
347| 16501003 | The form can not be operated by the current application. |
348
349以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
350
351**示例:**
352
353```ts
354try {
355  var formId = '12400633174999288';
356  formHost.requestForm(formId).then(() => {
357    console.log('formHost requestForm success');
358  }).catch((error) => {
359    console.log('formHost requestForm, error:' + JSON.stringify(error));
360  });
361} catch(error) {
362    console.log(`catch err->${JSON.stringify(error)}`);
363}
364
365```
366
367## castToNormalForm
368
369castToNormalForm(formId: string, callback: AsyncCallback<void>): void
370
371将指定的临时卡片转换为普通卡片。使用callback异步回调。
372
373**需要权限**:ohos.permission.REQUIRE_FORM
374
375**系统能力**:SystemCapability.Ability.Form
376
377**参数:**
378
379| 参数名 | 类型    | 必填 | 说明    |
380| ------ | ------ | ---- | ------- |
381| formId | string | 是   | 卡片标识。 |
382| callback | AsyncCallback<void> | 是 | 回调函数。当将指定的临时卡片转换为普通卡片成功,err为undefined,否则为错误对象。 |
383
384**错误码:**
385
386| 错误码ID | 错误信息 |
387| -------- | -------- |
388| 201 | Permissions denied. |
389| 202 | The application is not a system application. |
390| 401 | If the input parameter is not valid parameter. |
391| 16500050 | An IPC connection error happened. |
392| 16501000 | An internal functional error occurred. |
393| 16501001 | The ID of the form to be operated does not exist. |
394| 16501002 | The number of forms exceeds upper bound. |
395| 16501003 | The form can not be operated by the current application. |
396
397以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
398
399**示例:**
400
401```ts
402try {
403  var formId = '12400633174999288';
404  formHost.castToNormalForm(formId, (error, data) => {
405    if (error) {
406      console.log('formHost castTempForm, error:' + JSON.stringify(error));
407    }
408  });
409} catch(error) {
410    console.log(`catch err->${JSON.stringify(error)}`);
411}
412```
413
414## castToNormalForm
415
416castToNormalForm(formId: string): Promise<void>
417
418将指定的临时卡片转换为普通卡片。使用Promise异步回调。
419
420**需要权限**:ohos.permission.REQUIRE_FORM
421
422**系统能力**:SystemCapability.Ability.Form
423
424**参数:**
425
426| 参数名 | 类型    | 必填 | 说明    |
427| ------ | ------ | ---- | ------- |
428| formId | string | 是   | 卡片标识。 |
429
430**返回值:**
431
432| 类型 | 说明 |
433| -------- | -------- |
434| Promise<void> | 无返回结果的Promise对象。|
435
436**错误码:**
437
438| 错误码ID | 错误信息 |
439| -------- | -------- |
440| 201 | Permissions denied. |
441| 202 | The application is not a system application. |
442| 401 | If the input parameter is not valid parameter. |
443| 16500050 | An IPC connection error happened. |
444| 16501000 | An internal functional error occurred. |
445| 16501001 | The ID of the form to be operated does not exist. |
446| 16501002 | The number of forms exceeds upper bound. |
447| 16501003 | The form can not be operated by the current application. |
448
449以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
450
451**示例:**
452
453```ts
454try {
455  var formId = '12400633174999288';
456  formHost.castToNormalForm(formId).then(() => {
457    console.log('formHost castTempForm success');
458  }).catch((error) => {
459    console.log('formHost castTempForm, error:' + JSON.stringify(error));
460  });
461} catch(error) {
462    console.log(`catch err->${JSON.stringify(error)}`);
463}
464```
465
466## notifyVisibleForms
467
468notifyVisibleForms(formIds: Array<string>, callback: AsyncCallback<void>): void
469
470向卡片框架发送通知以使指定的卡片可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。使用callback异步回调。
471
472**需要权限**:ohos.permission.REQUIRE_FORM
473
474**系统能力**:SystemCapability.Ability.Form
475
476**参数:**
477
478| 参数名 | 类型    | 必填 | 说明    |
479| ------ | ------ | ---- | ------- |
480| formIds  | Array<string>       | 是   | 卡片标识列表。         |
481| callback | AsyncCallback<void> | 是 | 回调函数。当向卡片框架发送通知以使指定的卡片可见成功,err为undefined,否则为错误对象。 |
482
483**错误码:**
484
485| 错误码ID | 错误信息 |
486| -------- | -------- |
487| 201 | Permissions denied. |
488| 202 | The application is not a system application. |
489| 401 | If the input parameter is not valid parameter. |
490| 16500050 | An IPC connection error happened. |
491| 16500060 | A service connection error happened, please try again later. |
492| 16501000 | An internal functional error occurred. |
493
494以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
495
496**示例:**
497
498```ts
499try {
500  var formId = ['12400633174999288'];
501  formHost.notifyVisibleForms(formId, (error, data) => {
502    if (error) {
503      console.log('formHost notifyVisibleForms, error:' + JSON.stringify(error));
504    }
505  });
506} catch(error) {
507    console.log(`catch err->${JSON.stringify(error)}`);
508}
509```
510
511## notifyVisibleForms
512
513notifyVisibleForms(formIds: Array<string>): Promise<void>
514
515向卡片框架发送通知以使指定的卡片可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。使用Promise异步回调。
516
517**需要权限**:ohos.permission.REQUIRE_FORM
518
519**系统能力**:SystemCapability.Ability.Form
520
521**参数:**
522
523| 参数名 | 类型    | 必填 | 说明    |
524| ------ | ------ | ---- | ------- |
525| formIds | Array<string> | 是   | 卡片标识列表。 |
526
527**返回值:**
528
529| 类型 | 说明 |
530| -------- | -------- |
531| Promise<void> | 无返回结果的Promise对象。 |
532
533**错误码:**
534
535| 错误码ID | 错误信息 |
536| -------- | -------- |
537| 201 | Permissions denied. |
538| 202 | The application is not a system application. |
539| 401 | If the input parameter is not valid parameter. |
540| 16500050 | An IPC connection error happened. |
541| 16500060 | A service connection error happened, please try again later. |
542| 16501000 | An internal functional error occurred. |
543
544以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
545
546**示例:**
547
548```ts
549try {
550  var formId = ['12400633174999288'];
551  formHost.notifyVisibleForms(formId).then(() => {
552    console.log('formHost notifyVisibleForms success');
553  }).catch((error) => {
554    console.log('formHost notifyVisibleForms, error:' + JSON.stringify(error));
555  });
556} catch(error) {
557    console.log(`catch err->${JSON.stringify(error)}`);
558}
559```
560
561## notifyInvisibleForms
562
563notifyInvisibleForms(formIds: Array<string>, callback: AsyncCallback<void>): void
564
565向卡片框架发送通知以使指定的卡片不可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。使用callback异步回调。
566
567**需要权限**:ohos.permission.REQUIRE_FORM
568
569**系统能力**:SystemCapability.Ability.Form
570
571**参数:**
572
573| 参数名 | 类型    | 必填 | 说明    |
574| ------ | ------ | ---- | ------- |
575| formIds  | Array<string>       | 是   | 卡片标识列表。|
576| callback | AsyncCallback<void> | 是 | 回调函数。当向卡片框架发送通知以使指定的卡片不可见成功,err为undefined,否则为错误对象。 |
577
578**错误码:**
579
580| 错误码ID | 错误信息 |
581| -------- | -------- |
582| 201 | Permissions denied. |
583| 202 | The application is not a system application. |
584| 401 | If the input parameter is not valid parameter. |
585| 16500050 | An IPC connection error happened. |
586| 16500060 | A service connection error happened, please try again later. |
587| 16501000 | An internal functional error occurred. |
588
589以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
590
591**示例:**
592
593```ts
594try {
595  var formId = ['12400633174999288'];
596  formHost.notifyInvisibleForms(formId, (error, data) => {
597    if (error) {
598      console.log('formHost notifyInvisibleForms, error:' + JSON.stringify(error));
599    }
600  });
601} catch(error) {
602    console.log(`catch err->${JSON.stringify(error)}`);
603}
604```
605
606## notifyInvisibleForms
607
608notifyInvisibleForms(formIds: Array<string>): Promise<void>
609
610向卡片框架发送通知以使指定的卡片不可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。使用Promise异步回调。
611
612**需要权限**:ohos.permission.REQUIRE_FORM
613
614**系统能力**:SystemCapability.Ability.Form
615
616**参数:**
617
618| 参数名 | 类型    | 必填 | 说明    |
619| ------ | ------ | ---- | ------- |
620| formIds | Array<string> | 是   | 卡片标识列表。 |
621
622**返回值:**
623
624| 类型 | 说明 |
625| -------- | -------- |
626| Promise<void> | 无返回结果的Promise对象。|
627
628**错误码:**
629
630| 错误码ID | 错误信息 |
631| -------- | -------- |
632| 201 | Permissions denied. |
633| 202 | The application is not a system application. |
634| 401 | If the input parameter is not valid parameter. |
635| 16500050 | An IPC connection error happened. |
636| 16500060 | A service connection error happened, please try again later. |
637| 16501000 | An internal functional error occurred. |
638
639以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
640
641**示例:**
642
643```ts
644try {
645  var formId = ['12400633174999288'];
646  formHost.notifyInvisibleForms(formId).then(() => {
647    console.log('formHost notifyInvisibleForms success');
648  }).catch((error) => {
649    console.log('formHost notifyInvisibleForms, error:' + JSON.stringify(error));
650  });
651} catch(error) {
652    console.log(`catch err->${JSON.stringify(error)}`);
653}
654```
655
656## enableFormsUpdate
657
658enableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void>): void
659
660向卡片框架发送通知以使指定的卡片可以更新。该方法调用成功后,卡片刷新状态设置为使能,卡片可以接收来自卡片提供方的更新。使用callback异步回调。
661
662**需要权限**:ohos.permission.REQUIRE_FORM
663
664**系统能力**:SystemCapability.Ability.Form
665
666**参数:**
667
668| 参数名 | 类型    | 必填 | 说明    |
669| ------ | ------ | ---- | ------- |
670| formIds  | Array<string>       | 是   | 卡片标识列表。         |
671| callback | AsyncCallback<void> | 是 | 回调函数。当向卡片框架发送通知以使指定的卡片可以更新成功,err为undefined,否则为错误对象。 |
672
673**错误码:**
674
675| 错误码ID | 错误信息 |
676| -------- | -------- |
677| 201 | Permissions denied. |
678| 202 | The application is not a system application. |
679| 401 | If the input parameter is not valid parameter. |
680| 16500050 | An IPC connection error happened. |
681| 16500060 | A service connection error happened, please try again later. |
682| 16501000 | An internal functional error occurred. |
683| 16501003 | The form can not be operated by the current application. |
684
685以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
686
687**示例:**
688
689```ts
690try {
691  var formId = ['12400633174999288'];
692  formHost.enableFormsUpdate(formId, (error, data) => {
693    if (error) {
694      console.log('formHost enableFormsUpdate, error:' + JSON.stringify(error));
695    }
696  });
697} catch(error) {
698    console.log(`catch err->${JSON.stringify(error)}`);
699}
700```
701
702## enableFormsUpdate
703
704enableFormsUpdate(formIds: Array<string>): Promise<void>
705
706向卡片框架发送通知以使指定的卡片可以更新。该方法调用成功后,卡片刷新状态设置为使能,卡片可以接收来自卡片提供方的更新。使用Promise异步回调。
707
708**需要权限**:ohos.permission.REQUIRE_FORM
709
710**系统能力**:SystemCapability.Ability.Form
711
712**参数:**
713
714| 参数名 | 类型    | 必填 | 说明    |
715| ------ | ------ | ---- | ------- |
716| formIds | Array<string> | 是   | 卡片标识列表。 |
717
718**返回值:**
719
720| 类型 | 说明 |
721| -------- | -------- |
722| Promise<void> | 无返回结果的Promise对象。 |
723
724**错误码:**
725
726| 错误码ID | 错误信息 |
727| -------- | -------- |
728| 201 | Permissions denied. |
729| 202 | The application is not a system application. |
730| 401 | If the input parameter is not valid parameter. |
731| 16500050 | An IPC connection error happened. |
732| 16500060 | A service connection error happened, please try again later. |
733| 16501000 | An internal functional error occurred. |
734| 16501003 | The form can not be operated by the current application. |
735
736以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
737
738**示例:**
739
740```ts
741try {
742  var formId = ['12400633174999288'];
743  formHost.enableFormsUpdate(formId).then(() => {
744    console.log('formHost enableFormsUpdate success');
745  }).catch((error) => {
746    console.log('formHost enableFormsUpdate, error:' + JSON.stringify(error));
747  });
748} catch(error) {
749    console.log(`catch err->${JSON.stringify(error)}`);
750}
751```
752
753## disableFormsUpdate
754
755disableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void>): void
756
757向卡片框架发送通知以使指定的卡片不可以更新。该方法调用成功后,卡片刷新状态设置为去使能,卡片不可以接收来自卡片提供方的更新。使用callback异步回调。
758
759**需要权限**:ohos.permission.REQUIRE_FORM
760
761**系统能力**:SystemCapability.Ability.Form
762
763**参数:**
764
765| 参数名 | 类型    | 必填 | 说明    |
766| ------ | ------ | ---- | ------- |
767| formIds  | Array<string>       | 是   | 卡片标识列表。         |
768| callback | AsyncCallback<void> | 是 | 回调函数。当向卡片框架发送通知以使指定的卡片不可以更新成功,err为undefined,否则为错误对象。 |
769
770**错误码:**
771
772| 错误码ID | 错误信息 |
773| -------- | -------- |
774| 201 | Permissions denied. |
775| 202 | The application is not a system application. |
776| 401 | If the input parameter is not valid parameter. |
777| 16500050 | An IPC connection error happened. |
778| 16500060 | A service connection error happened, please try again later. |
779| 16501000 | An internal functional error occurred. |
780| 16501001 | The ID of the form to be operated does not exist. |
781| 16501003 | The form can not be operated by the current application. |
782
783以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
784
785**示例:**
786
787```ts
788try {
789  var formId = ['12400633174999288'];
790  formHost.disableFormsUpdate(formId, (error, data) => {
791    if (error) {
792      console.log('formHost disableFormsUpdate, error:' + JSON.stringify(error));
793    }
794  });
795} catch(error) {
796    console.log(`catch err->${JSON.stringify(error)}`);
797}
798```
799
800## disableFormsUpdate
801
802disableFormsUpdate(formIds: Array<string>): Promise<void>
803
804向卡片框架发送通知以使指定的卡片不可以更新。该方法调用成功后,卡片刷新状态设置为去使能,卡片不可以接收来自卡片提供方的更新。使用Promise异步回调。
805
806**需要权限**:ohos.permission.REQUIRE_FORM
807
808**系统能力**:SystemCapability.Ability.Form
809
810**参数:**
811
812| 参数名 | 类型    | 必填 | 说明    |
813| ------ | ------ | ---- | ------- |
814| formIds | Array<string> | 是   | 卡片标识列表。 |
815
816**返回值:**
817
818| 类型 | 说明 |
819| -------- | -------- |
820| Promise<void> | 无返回结果的Promise对象。 |
821
822**错误码:**
823
824| 错误码ID | 错误信息 |
825| -------- | -------- |
826| 201 | Permissions denied. |
827| 202 | The application is not a system application. |
828| 401 | If the input parameter is not valid parameter. |
829| 16500050 | An IPC connection error happened. |
830| 16500060 | A service connection error happened, please try again later. |
831| 16501000 | An internal functional error occurred. |
832| 16501001 | The ID of the form to be operated does not exist. |
833| 16501003 | The form can not be operated by the current application. |
834
835以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
836
837**示例:**
838
839```ts
840try {
841  var formId = ['12400633174999288'];
842  formHost.disableFormsUpdate(formId).then(() => {
843    console.log('formHost disableFormsUpdate success');
844  }).catch((error) => {
845    console.log('formHost disableFormsUpdate, error:' + JSON.stringify(error));
846  });
847} catch(error) {
848    console.log(`catch err->${JSON.stringify(error)}`);
849}
850```
851
852## isSystemReady
853
854isSystemReady(callback: AsyncCallback<void>): void
855
856检查系统是否准备好。使用callback异步回调。
857
858**系统能力**:SystemCapability.Ability.Form
859
860**参数:**
861
862| 参数名 | 类型    | 必填 | 说明    |
863| ------ | ------ | ---- | ------- |
864| callback | AsyncCallback<void> | 是 | 回调函数。当检查系统是否准备好成功,err为undefined,否则为错误对象。 |
865
866**错误码:**
867
868| 错误码ID | 错误信息 |
869| -------- | -------- |
870| 202 | The application is not a system application.   |
871| 401 | If the input parameter is not valid parameter. |
872
873以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
874
875**示例:**
876
877```ts
878try {
879  var formId = '12400633174999288';
880  formHost.isSystemReady((error, data) => {
881    if (error) {
882      console.log('formHost isSystemReady, error:' + JSON.stringify(error));
883    }
884  });
885} catch(error) {
886    console.log(`catch err->${JSON.stringify(error)}`);
887}
888```
889
890## isSystemReady
891
892isSystemReady(): Promise<void>
893
894检查系统是否准备好。使用Promise异步回调。
895
896**系统能力**:SystemCapability.Ability.Form
897
898**返回值:**
899
900| 类型 | 说明 |
901| -------- | -------- |
902| Promise<void> | 无返回结果的Promise对象。 |
903
904**错误码:**
905
906| 错误码ID | 错误信息 |
907| -------- | -------- |
908| 202 | The application is not a system application.   |
909
910以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
911
912**示例:**
913
914```ts
915try {
916  var formId = '12400633174999288';
917  formHost.isSystemReady().then(() => {
918    console.log('formHost isSystemReady success');
919  }).catch((error) => {
920    console.log('formHost isSystemReady, error:' + JSON.stringify(error));
921  });
922} catch(error) {
923    console.log(`catch err->${JSON.stringify(error)}`);
924}
925```
926
927## getAllFormsInfo
928
929getAllFormsInfo(callback: AsyncCallback<Array<formInfo.FormInfo>>): void
930
931获取设备上所有应用提供的卡片信息。使用callback异步回调。
932
933**需要权限**:ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
934
935**系统能力**:SystemCapability.Ability.Form
936
937**错误码:**
938
939| 错误码ID | 错误信息 |
940| -------- | -------- |
941| 201 | Permissions denied. |
942| 202 | The application is not a system application. |
943| 401 | If the input parameter is not valid parameter. |
944| 16500050 | An IPC connection error happened. |
945| 16500060 | A service connection error happened, please try again later. |
946| 16501000 | An internal functional error occurred. |
947
948以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
949
950**参数:**
951
952| 参数名 | 类型    | 必填 | 说明    |
953| ------ | ------ | ---- | ------- |
954| callback | AsyncCallback<Array<[FormInfo](js-apis-app-form-formInfo.md)>> | 是 | 回调函数。当获取设备上所有应用提供的卡片信息成功,err为undefined,data为查询到的卡片信息;否则为错误对象。 |
955
956**示例:**
957
958```ts
959try {
960  formHost.getAllFormsInfo((error, data) => {
961    if (error) {
962      console.log('formHost getAllFormsInfo, error:' + JSON.stringify(error));
963    } else {
964      console.log('formHost getAllFormsInfo, data:' + JSON.stringify(data));
965    }
966  });
967} catch(error) {
968    console.log(`catch err->${JSON.stringify(error)}`);
969}
970```
971
972## getAllFormsInfo
973
974getAllFormsInfo(): Promise<Array<formInfo.FormInfo>>
975
976获取设备上所有应用提供的卡片信息。使用Promise异步回调。
977
978**需要权限**:ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
979
980**系统能力**:SystemCapability.Ability.Form
981
982**错误码:**
983
984| 错误码ID | 错误信息 |
985| -------- | -------- |
986| 201 | Permissions denied. |
987| 202 | The application is not a system application. |
988| 16500050 | An IPC connection error happened. |
989| 16500060 | A service connection error happened, please try again later. |
990| 16501000 | An internal functional error occurred. |
991
992以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
993
994**返回值:**
995
996| 类型          | 说明                                |
997| :------------ | :---------------------------------- |
998| Promise<Array<[FormInfo](js-apis-app-form-formInfo.md)>> | Promise对象,返回查询到的卡片信息。 |
999
1000**示例:**
1001
1002```ts
1003try {
1004  formHost.getAllFormsInfo().then((data) => {
1005      console.log('formHost getAllFormsInfo data:' + JSON.stringify(data));
1006  }).catch((error) => {
1007      console.log('formHost getAllFormsInfo, error:' + JSON.stringify(error));
1008  });
1009} catch(error) {
1010    console.log(`catch err->${JSON.stringify(error)}`);
1011}
1012```
1013
1014## getFormsInfo
1015
1016getFormsInfo(bundleName: string, callback: AsyncCallback<Array<formInfo.FormInfo>>): void
1017
1018获取设备上指定应用程序提供的卡片信息。使用callback异步回调。
1019
1020**需要权限**:ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
1021
1022**系统能力**:SystemCapability.Ability.Form
1023
1024**参数:**
1025
1026| 参数名 | 类型    | 必填 | 说明    |
1027| ------ | ------ | ---- | ------- |
1028| bundleName | string | 是 |  要查询的应用程序包名称。 |
1029| callback | AsyncCallback<Array<[FormInfo](js-apis-app-form-formInfo.md)>> | 是 | 回调函数。当获取设备上指定应用程序提供的卡片信息成功,err为undefined,data为查询到的卡片信息;否则为错误对象。 |
1030
1031**错误码:**
1032
1033| 错误码ID | 错误信息 |
1034| -------- | -------- |
1035| 201 | Permissions denied. |
1036| 202 | The application is not a system application. |
1037| 401 | If the input parameter is not valid parameter. |
1038| 16500050 | An IPC connection error happened. |
1039| 16500060 | A service connection error happened, please try again later. |
1040| 16500100 | Failed to obtain the configuration information. |
1041| 16501000 | An internal functional error occurred. |
1042
1043以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
1044
1045**示例:**
1046
1047```ts
1048try {
1049  formHost.getFormsInfo('com.example.ohos.formjsdemo', (error, data) => {
1050    if (error) {
1051      console.log('formHost getFormsInfo, error:' + JSON.stringify(error));
1052    } else {
1053      console.log('formHost getFormsInfo, data:' + JSON.stringify(data));
1054    }
1055  });
1056} catch(error) {
1057    console.log(`catch err->${JSON.stringify(error)}`);
1058}
1059```
1060
1061## getFormsInfo
1062
1063getFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback<Array<formInfo.FormInfo>>): void
1064
1065获取设备上指定应用程序提供的卡片信息。使用callback异步回调。
1066
1067**需要权限**:ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
1068
1069**系统能力**:SystemCapability.Ability.Form
1070
1071**参数:**
1072
1073| 参数名 | 类型    | 必填 | 说明    |
1074| ------ | ------ | ---- | ------- |
1075| bundleName | string | 是 |  要查询的应用程序包名称。 |
1076| moduleName | string | 是 |  要查询的模块名称。 |
1077| callback | AsyncCallback<Array<[FormInfo](js-apis-app-form-formInfo.md)>> | 是 | 回调函数。当获取设备上指定应用程序提供的卡片信息成功,err为undefined,data为查询到的卡片信息;否则为错误对象。 |
1078
1079**错误码:**
1080
1081| 错误码ID | 错误信息 |
1082| -------- | -------- |
1083| 201 | Permissions denied. |
1084| 202 | The application is not a system application. |
1085| 401 | If the input parameter is not valid parameter. |
1086| 16500050 | An IPC connection error happened. |
1087| 16500060 | A service connection error happened, please try again later. |
1088| 16500100 | Failed to obtain the configuration information. |
1089| 16501000 | An internal functional error occurred. |
1090
1091以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
1092
1093**示例:**
1094
1095```ts
1096try {
1097  formHost.getFormsInfo('com.example.ohos.formjsdemo', 'entry', (error, data) => {
1098    if (error) {
1099        console.log('formHost getFormsInfo, error:' + JSON.stringify(error));
1100    } else {
1101        console.log('formHost getFormsInfo, data:' + JSON.stringify(data));
1102    }
1103  });
1104} catch(error) {
1105    console.log(`catch err->${JSON.stringify(error)}`);
1106}
1107```
1108
1109## getFormsInfo
1110
1111getFormsInfo(bundleName: string, moduleName?: string): Promise<Array<formInfo.FormInfo>>
1112
1113获取设备上指定应用程序提供的卡片信息。使用Promise异步回调。
1114
1115**需要权限**:ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
1116
1117**系统能力**:SystemCapability.Ability.Form
1118
1119**参数:**
1120
1121| 参数名 | 类型    | 必填 | 说明    |
1122| ------ | ------ | ---- | ------- |
1123| bundleName | string | 是 |  要查询的应用程序包名称。 |
1124| moduleName | string | 否 |  要查询的模块名称。 |
1125
1126**返回值:**
1127
1128| 类型          | 说明                                |
1129| :------------ | :---------------------------------- |
1130| Promise<Array<[FormInfo](js-apis-app-form-formInfo.md)>> | Promise对象,返回查询到的卡片信息。 |
1131
1132**错误码:**
1133
1134| 错误码ID | 错误信息 |
1135| -------- | -------- |
1136| 201 | Permissions denied. |
1137| 202 | The application is not a system application. |
1138| 401 | If the input parameter is not valid parameter. |
1139| 16500050 | An IPC connection error happened. |
1140| 16500060 | A service connection error happened, please try again later. |
1141| 16500100 | Failed to obtain the configuration information. |
1142| 16501000 | An internal functional error occurred. |
1143
1144以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
1145
1146**示例:**
1147
1148```ts
1149try {
1150  formHost.getFormsInfo('com.example.ohos.formjsdemo', 'entry').then((data) => {
1151    console.log('formHost getFormsInfo, data:' + JSON.stringify(data));
1152  }).catch((error) => {
1153    console.log('formHost getFormsInfo, error:' + JSON.stringify(error));
1154  });
1155} catch(error) {
1156    console.log(`catch err->${JSON.stringify(error)}`);
1157}
1158```
1159
1160## deleteInvalidForms
1161
1162deleteInvalidForms(formIds: Array<string>, callback: AsyncCallback<number>): void
1163
1164根据列表删除应用程序的无效卡片。使用callback异步回调。
1165
1166**需要权限**:ohos.permission.REQUIRE_FORM
1167
1168**系统能力**:SystemCapability.Ability.Form
1169
1170**参数:**
1171
1172| 参数名 | 类型    | 必填 | 说明    |
1173| ------ | ------ | ---- | ------- |
1174| formIds | Array<string> | 是   | 有效卡片标识列表。 |
1175| callback | AsyncCallback<number> | 是 | 回调函数。当根据列表删除应用程序的无效卡片成功,err为undefined,data为删除的卡片个数;否则为错误对象。 |
1176
1177**错误码:**
1178
1179| 错误码ID | 错误信息 |
1180| -------- | -------- |
1181| 201 | Permissions denied. |
1182| 202 | The application is not a system application. |
1183| 401 | If the input parameter is not valid parameter. |
1184| 16500050 | An IPC connection error happened. |
1185| 16500060 | A service connection error happened, please try again later. |
1186| 16501000 | An internal functional error occurred. |
1187
1188以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
1189
1190**示例:**
1191
1192```ts
1193try {
1194  var formIds = new Array('12400633174999288', '12400633174999289');
1195  formHost.deleteInvalidForms(formIds, (error, data) => {
1196    if (error) {
1197      console.log('formHost deleteInvalidForms, error:' + JSON.stringify(error));
1198    } else {
1199      console.log('formHost deleteInvalidForms, data:' + JSON.stringify(data));
1200    }
1201  });
1202} catch(error) {
1203    console.log(`catch err->${JSON.stringify(error)}`);
1204}
1205```
1206
1207## deleteInvalidForms
1208
1209deleteInvalidForms(formIds: Array<string>): Promise<number>
1210
1211根据列表删除应用程序的无效卡片。使用Promise异步回调。
1212
1213**需要权限**:ohos.permission.REQUIRE_FORM
1214
1215**系统能力**:SystemCapability.Ability.Form
1216
1217**参数:**
1218
1219| 参数名 | 类型    | 必填 | 说明    |
1220| ------ | ------ | ---- | ------- |
1221| formIds | Array<string> | 是   | 有效卡片标识列表。 |
1222
1223**返回值:**
1224
1225| 类型          | 说明                                |
1226| :------------ | :---------------------------------- |
1227| Promise<number> | Promise对象,返回删除的卡片个数。 |
1228
1229**错误码:**
1230
1231| 错误码ID | 错误信息 |
1232| -------- | -------- |
1233| 201 | Permissions denied. |
1234| 202 | The application is not a system application. |
1235| 401 | If the input parameter is not valid parameter. |
1236| 16500050 | An IPC connection error happened. |
1237| 16500060 | A service connection error happened, please try again later. |
1238| 16501000 | An internal functional error occurred. |
1239
1240以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
1241
1242**示例:**
1243
1244```ts
1245try {
1246  var formIds = new Array('12400633174999288', '12400633174999289');
1247  formHost.deleteInvalidForms(formIds).then((data) => {
1248    console.log('formHost deleteInvalidForms, data:' + JSON.stringify(data));
1249  }).catch((error) => {
1250    console.log('formHost deleteInvalidForms, error:' + JSON.stringify(error));
1251  });
1252} catch(error) {
1253    console.log(`catch err->${JSON.stringify(error)}`);
1254}
1255```
1256
1257## acquireFormState
1258
1259acquireFormState(want: Want, callback: AsyncCallback<formInfo.FormStateInfo>): void
1260
1261获取卡片状态。使用callback异步回调。
1262
1263**需要权限**:ohos.permission.REQUIRE_FORMohos.permission.GET_BUNDLE_INFO_PRIVILEGED
1264
1265**系统能力**:SystemCapability.Ability.Form
1266
1267**参数:**
1268
1269| 参数名 | 类型    | 必填 | 说明    |
1270| ------ | ------ | ---- | ------- |
1271| want | [Want](js-apis-application-want.md) | 是   | 查询卡片状态时携带的want信息。 |
1272| callback | AsyncCallback<[FormStateInfo](js-apis-app-form-formInfo.md#formstateinfo)> | 是 | 回调函数。当获取卡片状态成功,err为undefined,data为获取到的卡片状态;否则为错误对象。 |
1273
1274**错误码:**
1275
1276| 错误码ID | 错误信息 |
1277| -------- | -------- |
1278| 201 | Permissions denied. |
1279| 202 | The application is not a system application. |
1280| 401 | If the input parameter is not valid parameter. |
1281| 16500050 | An IPC connection error happened. |
1282| 16500060 | A service connection error happened, please try again later. |
1283| 16500100 | Failed to obtain the configuration information. |
1284| 16501000 | An internal functional error occurred. |
1285
1286以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
1287
1288**示例:**
1289
1290```ts
1291var want = {
1292  'deviceId': '',
1293  'bundleName': 'ohos.samples.FormApplication',
1294  'abilityName': 'FormAbility',
1295  'parameters': {
1296    'ohos.extra.param.key.module_name': 'entry',
1297    'ohos.extra.param.key.form_name': 'widget',
1298    'ohos.extra.param.key.form_dimension': 2
1299  }
1300};
1301try {
1302  formHost.acquireFormState(want, (error, data) => {
1303    if (error) {
1304      console.log('formHost acquireFormState, error:' + JSON.stringify(error));
1305    } else {
1306      console.log('formHost acquireFormState, data:' + JSON.stringify(data));
1307    }
1308  });
1309} catch(error) {
1310    console.log(`catch err->${JSON.stringify(error)}`);
1311}
1312```
1313
1314## acquireFormState
1315
1316acquireFormState(want: Want): Promise<formInfo.FormStateInfo>
1317
1318获取卡片状态。使用Promise异步回调。
1319
1320**需要权限**:ohos.permission.REQUIRE_FORMohos.permission.GET_BUNDLE_INFO_PRIVILEGED
1321
1322**系统能力**:SystemCapability.Ability.Form
1323
1324**参数:**
1325
1326| 参数名 | 类型    | 必填 | 说明    |
1327| ------ | ------ | ---- | ------- |
1328| want   | [Want](js-apis-application-want.md) | 是   | 查询卡片状态时携带的want信息。 |
1329
1330**返回值:**
1331
1332| 类型          | 说明                                |
1333| :------------ | :---------------------------------- |
1334| Promise<[FormStateInfo](js-apis-app-form-formInfo.md#formstateinfo)> | Promise对象,返回卡片状态。 |
1335
1336**错误码:**
1337
1338| 错误码ID | 错误信息 |
1339| -------- | -------- |
1340| 201 | Permissions denied. |
1341| 202 | The application is not a system application. |
1342| 401 | If the input parameter is not valid parameter. |
1343| 16500050 | An IPC connection error happened. |
1344| 16500060 | A service connection error happened, please try again later. |
1345| 16500100 | Failed to obtain the configuration information. |
1346| 16501000 | An internal functional error occurred. |
1347
1348以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
1349
1350**示例:**
1351
1352```ts
1353var want = {
1354  'deviceId': '',
1355  'bundleName': 'ohos.samples.FormApplication',
1356  'abilityName': 'FormAbility',
1357  'parameters': {
1358    'ohos.extra.param.key.module_name': 'entry',
1359    'ohos.extra.param.key.form_name': 'widget',
1360    'ohos.extra.param.key.form_dimension': 2
1361  }
1362};
1363try {
1364  formHost.acquireFormState(want).then((data) => {
1365    console.log('formHost acquireFormState, data:' + JSON.stringify(data));
1366  }).catch((error) => {
1367    console.log('formHost acquireFormState, error:' + JSON.stringify(error));
1368  });
1369} catch(error) {
1370    console.log(`catch err->${JSON.stringify(error)}`);
1371}
1372```
1373
1374## on('formUninstall')
1375
1376on(type: 'formUninstall', callback: Callback<string>): void
1377
1378订阅卡片卸载事件。使用callback异步回调。
1379
1380**系统能力**:SystemCapability.Ability.Form
1381
1382**参数:**
1383
1384| 参数名 | 类型    | 必填 | 说明    |
1385| ------ | ------ | ---- | ------- |
1386| type | string | 是   | 填写'formUninstall',表示卡片卸载事件。 |
1387| callback | Callback<string> | 是 | 回调函数。返回卡片标识。 |
1388
1389**错误码:**
1390
1391| 错误码ID | 错误信息 |
1392| -------- | -------- |
1393| 202 | The application is not a system application. |
1394| 401 | If the input parameter is not valid parameter. |
1395
1396以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
1397
1398**示例:**
1399
1400```ts
1401let callback = function(formId) {
1402  console.log('formHost on formUninstall, formId:' + formId);
1403}
1404formHost.on('formUninstall', callback);
1405```
1406
1407## off('formUninstall')
1408
1409off(type: 'formUninstall', callback?: Callback<string>): void
1410
1411取消订阅卡片卸载事件。使用callback异步回调。
1412
1413**系统能力**:SystemCapability.Ability.Form
1414
1415**参数:**
1416
1417| 参数名 | 类型    | 必填 | 说明    |
1418| ------ | ------ | ---- | ------- |
1419| type | string | 是   | 填写'formUninstall',表示卡片卸载事件。 |
1420| callback | Callback<string> | 否 | 回调函数。返回卡片标识。缺省时,表示注销所有已注册事件回调。 |
1421
1422**错误码:**
1423
1424| 错误码ID | 错误信息 |
1425| -------- | -------- |
1426| 202 | The application is not a system application. |
1427| 401 | If the input parameter is not valid parameter. |
1428
1429以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
1430
1431**示例:**
1432
1433```ts
1434let callback = function(formId) {
1435  console.log('formHost on formUninstall, formId:' + formId);
1436}
1437formHost.off('formUninstall', callback);
1438```
1439
1440## notifyFormsVisible
1441
1442notifyFormsVisible(formIds: Array<string>, isVisible: boolean, callback: AsyncCallback<void>): void
1443
1444通知卡片是否可见。使用callback异步回调。
1445
1446**需要权限**:ohos.permission.REQUIRE_FORM
1447
1448**系统能力**:SystemCapability.Ability.Form
1449
1450**参数:**
1451
1452| 参数名 | 类型    | 必填 | 说明    |
1453| ------ | ------ | ---- | ------- |
1454| formIds | Array<string> | 是   | 卡片标识列表。 |
1455| isVisible | boolean | 是   | 是否可见。 |
1456| callback | AsyncCallback<void> | 是 | 回调函数。当通知卡片是否可见成功,err为undefined,否则为错误对象。 |
1457
1458**错误码:**
1459
1460| 错误码ID | 错误信息 |
1461| -------- | -------- |
1462| 201 | Permissions denied. |
1463| 202 | The application is not a system application. |
1464| 401 | If the input parameter is not valid parameter. |
1465| 16500050 | An IPC connection error happened. |
1466| 16500060 | A service connection error happened, please try again later. |
1467| 16501000 | An internal functional error occurred. |
1468| 16501003 | The form can not be operated by the current application. |
1469
1470以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
1471
1472**示例:**
1473
1474```ts
1475var formIds = new Array('12400633174999288', '12400633174999289');
1476try {
1477  formHost.notifyFormsVisible(formIds, true, (error, data) => {
1478    if (error) {
1479      console.log('formHost notifyFormsVisible, error:' + JSON.stringify(error));
1480    }
1481  });
1482} catch(error) {
1483    console.log(`catch err->${JSON.stringify(error)}`);
1484}
1485```
1486
1487## notifyFormsVisible
1488
1489notifyFormsVisible(formIds: Array<string>, isVisible: boolean): Promise<void>
1490
1491通知卡片是否可见。使用Promise异步回调。
1492
1493**需要权限**:ohos.permission.REQUIRE_FORM
1494
1495**系统能力**:SystemCapability.Ability.Form
1496
1497**参数:**
1498
1499| 参数名 | 类型    | 必填 | 说明    |
1500| ------ | ------ | ---- | ------- |
1501| formIds | Array<string> | 是   | 卡片标识列表。 |
1502| isVisible | boolean | 是   | 是否可见。 |
1503
1504**返回值:**
1505
1506| 类型 | 说明 |
1507| -------- | -------- |
1508| Promise<void> | 无返回结果的Promise对象。 |
1509
1510**错误码:**
1511
1512| 错误码ID | 错误信息 |
1513| -------- | -------- |
1514| 201 | Permissions denied. |
1515| 202 | The application is not a system application. |
1516| 401 | If the input parameter is not valid parameter. |
1517| 16500050 | An IPC connection error happened. |
1518| 16500060 | A service connection error happened, please try again later. |
1519| 16501000 | An internal functional error occurred. |
1520| 16501003 | The form can not be operated by the current application. |
1521
1522以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
1523
1524**示例:**
1525
1526```ts
1527var formIds = new Array('12400633174999288', '12400633174999289');
1528try {
1529  formHost.notifyFormsVisible(formIds, true).then(() => {
1530    console.log('formHost notifyFormsVisible success');
1531  }).catch((error) => {
1532    console.log('formHost notifyFormsVisible, error:' + JSON.stringify(error));
1533  });
1534} catch(error) {
1535    console.log(`catch err->${JSON.stringify(error)}`);
1536}
1537```
1538
1539## notifyFormsEnableUpdate
1540
1541notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean, callback: AsyncCallback<void>): void
1542
1543通知卡片是否启用更新状态。使用callback异步回调。
1544
1545**需要权限**:ohos.permission.REQUIRE_FORM
1546
1547**系统能力**:SystemCapability.Ability.Form
1548
1549**参数:**
1550
1551| 参数名 | 类型    | 必填 | 说明    |
1552| ------ | ------ | ---- | ------- |
1553| formIds | Array<string> | 是   | 卡片标识列表。 |
1554| isEnableUpdate | boolean | 是   | 是否使能更新。 |
1555| callback | AsyncCallback<void> | 是 | 回调函数。当通知卡片是否启用更新状态成功,err为undefined,否则为错误对象。 |
1556
1557**错误码:**
1558
1559| 错误码ID | 错误信息 |
1560| -------- | -------- |
1561| 201 | Permissions denied. |
1562| 202 | The application is not a system application. |
1563| 401 | If the input parameter is not valid parameter. |
1564| 16500050 | An IPC connection error happened. |
1565| 16500060 | A service connection error happened, please try again later. |
1566| 16501000 | An internal functional error occurred. |
1567| 16501003 | The form can not be operated by the current application. |
1568
1569以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
1570
1571**示例:**
1572
1573```ts
1574var formIds = new Array('12400633174999288', '12400633174999289');
1575try {
1576  formHost.notifyFormsEnableUpdate(formIds, true, (error, data) => {
1577    if (error) {
1578      console.log('formHost notifyFormsEnableUpdate, error:' + JSON.stringify(error));
1579    }
1580  });
1581} catch(error) {
1582    console.log(`catch err->${JSON.stringify(error)}`);
1583}
1584```
1585
1586## notifyFormsEnableUpdate
1587
1588notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean): Promise<void>
1589
1590通知卡片是否启用更新状态。使用Promise异步回调。
1591
1592**需要权限**:ohos.permission.REQUIRE_FORM
1593
1594**系统能力**:SystemCapability.Ability.Form
1595
1596**参数:**
1597
1598| 参数名 | 类型    | 必填 | 说明    |
1599| ------ | ------ | ---- | ------- |
1600| formIds | Array<string> | 是   | 卡片标识列表。 |
1601| isEnableUpdate | boolean | 是   | 是否使能更新。 |
1602
1603**返回值:**
1604
1605| 类型 | 说明 |
1606| -------- | -------- |
1607| Promise<void> | 无返回结果的Promise对象。 |
1608
1609**错误码:**
1610
1611| 错误码ID | 错误信息 |
1612| -------- | -------- |
1613| 201 | Permissions denied. |
1614| 202 | The application is not a system application. |
1615| 401 | If the input parameter is not valid parameter. |
1616| 16500050 | An IPC connection error happened. |
1617| 16500060 | A service connection error happened, please try again later. |
1618| 16501000 | An internal functional error occurred. |
1619| 16501003 | The form can not be operated by the current application. |
1620
1621以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
1622
1623**示例:**
1624
1625```ts
1626var formIds = new Array('12400633174999288', '12400633174999289');
1627try {
1628  formHost.notifyFormsEnableUpdate(formIds, true).then(() => {
1629    console.log('formHost notifyFormsEnableUpdate success');
1630  }).catch((error) => {
1631    console.log('formHost notifyFormsEnableUpdate, error:' + JSON.stringify(error));
1632  });
1633} catch(error) {
1634    console.log(`catch err->${JSON.stringify(error)}`);
1635}
1636```
1637## shareForm
1638
1639shareForm(formId: string, deviceId: string, callback: AsyncCallback<void>): void
1640
1641指定formId和远程设备Id进行卡片分享。使用callback异步回调。
1642
1643**需要权限**:ohos.permission.REQUIRE_FORMohos.permission.DISTRIBUTED_DATASYNC
1644
1645**系统能力**:SystemCapability.Ability.Form
1646
1647**参数:**
1648
1649| 参数名 | 类型    | 必填 | 说明    |
1650| ------ | ------ | ---- | ------- |
1651| formId | string | 是   | 卡片标识。 |
1652| deviceId | string | 是   | 远程设备标识。 |
1653| callback | AsyncCallback<void> | 是 | 回调函数。当指定formId和远程设备Id进行卡片分享成功,err为undefined,否则为错误对象。 |
1654
1655**错误码:**
1656
1657| 错误码ID | 错误信息 |
1658| -------- | -------- |
1659| 201 | Permissions denied. |
1660| 202 | The application is not a system application. |
1661| 401 | If the input parameter is not valid parameter. |
1662| 16500050 | An IPC connection error happened. |
1663| 16501000 | An internal functional error occurred. |
1664| 16501001 | The ID of the form to be operated does not exist. |
1665| 16501003 | The form can not be operated by the current application. |
1666
1667以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
1668
1669**示例:**
1670
1671```ts
1672var formId = '12400633174999288';
1673var deviceId = 'EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2';
1674try {
1675  formHost.shareForm(formId, deviceId, (error, data) => {
1676    if (error) {
1677      console.log('formHost shareForm, error:' + JSON.stringify(error));
1678    }
1679  });
1680} catch(error) {
1681    console.log(`catch err->${JSON.stringify(error)}`);
1682}
1683```
1684
1685## shareForm
1686
1687shareForm(formId: string, deviceId: string): Promise<void>
1688
1689指定formId和远程设备Id进行卡片分享。使用Promise异步回调。
1690
1691**需要权限**:ohos.permission.REQUIRE_FORMohos.permission.DISTRIBUTED_DATASYNC
1692
1693**系统能力**:SystemCapability.Ability.Form
1694
1695**参数:**
1696
1697| 参数名 | 类型    | 必填 | 说明    |
1698| ------ | ------ | ---- | ------- |
1699| formId | string | 是   | 卡片标识。 |
1700| deviceId | string | 是   | 远程设备标识。 |
1701
1702**返回值:**
1703
1704| 类型 | 说明 |
1705| -------- | -------- |
1706| Promise<void> | 无返回结果的Promise对象。 |
1707
1708**错误码:**
1709
1710| 错误码ID | 错误信息 |
1711| -------- | -------- |
1712| 201 | Permissions denied. |
1713| 202 | The application is not a system application. |
1714| 401 | If the input parameter is not valid parameter. |
1715| 16500050 | An IPC connection error happened. |
1716| 16501000 | An internal functional error occurred. |
1717| 16501001 | The ID of the form to be operated does not exist. |
1718| 16501003 | The form can not be operated by the current application. |
1719
1720以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
1721
1722**参数:**
1723
1724```ts
1725var formId = '12400633174999288';
1726var deviceId = 'EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2';
1727try {
1728  formHost.shareForm(formId, deviceId).then(() => {
1729    console.log('formHost shareForm success');
1730  }).catch((error) => {
1731    console.log('formHost shareForm, error:' + JSON.stringify(error));
1732  });
1733} catch(error) {
1734    console.log(`catch err->${JSON.stringify(error)}`);
1735}
1736```
1737
1738## notifyFormsPrivacyProtected
1739
1740notifyFormsPrivacyProtected(formIds: Array\<string>, isProtected: boolean, callback: AsyncCallback\<void>): void
1741
1742**需要权限**:ohos.permission.REQUIRE_FORM
1743
1744**系统能力**:SystemCapability.Ability.Form
1745
1746**参数:**
1747
1748| 参数名 | 类型    | 必填 | 说明    |
1749| ------ | ------ | ---- | ------- |
1750| formIds | Array\<string\> | 是   | 需要修改隐私保护的卡片标识列表。 |
1751| isProtected | boolean | 是   | 是否进行隐私保护。 |
1752| callback | AsyncCallback\<void> | 是 | 回调函数。当指定卡片设置隐私保护属性成功,error为undefined,否则为错误对象。 |
1753
1754**错误码:**
1755
1756| 错误码ID | 错误信息 |
1757| -------- | -------- |
1758| 201 | Permissions denied. |
1759| 202 | The application is not a system application. |
1760| 401 | If the input parameter is not valid parameter. |
1761| 16500050 | An IPC connection error happened. |
1762| 16500060 | A service connection error happened, please try again later. |
1763| 16501000 | An internal functional error occurred. |
1764
1765以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
1766
1767**示例:**
1768
1769```ts
1770import formHost from '@ohos.app.form.formHost';
1771
1772let formIds = new Array('12400633174999288', '12400633174999289');
1773try {
1774  formHost.notifyFormsPrivacyProtected(formIds, true, (error) => {
1775    if (error) {
1776      console.error(`error, code: ${error.code}, message: ${error.message}`);
1777    }
1778  });
1779} catch(error) {
1780  console.error(`catch error, code: ${error.code}, message: ${error.message}`);
1781}
1782```
1783
1784## notifyFormsPrivacyProtected
1785
1786notifyFormsPrivacyProtected(formIds: Array\<string\>, isProtected: boolean): Promise\<void\>;
1787
1788通知指定卡片隐私保护状态改变。使用Promise异步回调。
1789
1790**需要权限**:ohos.permission.REQUIRE_FORM
1791
1792**系统能力**:SystemCapability.Ability.Form
1793
1794**参数:**
1795
1796| 参数名      | 类型            | 必填 | 说明                             |
1797| ----------- | --------------- | ---- | -------------------------------- |
1798| formIds     | Array\<string\> | 是   | 需要修改隐私保护的卡片标识列表。 |
1799| isProtected | boolean         | 是   | 是否进行隐私保护。               |
1800
1801**返回值:**
1802
1803| 类型                | 说明                      |
1804| ------------------- | ------------------------- |
1805| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
1806
1807**错误码:**
1808
1809| 错误码ID | 错误信息 |
1810| -------- | -------- |
1811| 201 | Permissions denied. |
1812| 202 | The application is not a system application. |
1813| 401 | If the input parameter is not valid parameter. |
1814| 16500050 | An IPC connection error happened. |
1815| 16500060 | A service connection error happened, please try again later. |
1816| 16501000 | An internal functional error occurred. |
1817
1818以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
1819
1820```ts
1821import formHost from '@ohos.app.form.formHost';
1822
1823let formIds = new Array('12400633174999288', '12400633174999289');
1824try {
1825  formHost.notifyFormsPrivacyProtected(formIds, true).then(() => {
1826    console.log('formHost shareForm success');
1827  }).catch((error) => {
1828    console.log('formHost shareForm, error:' + JSON.stringify(error));
1829  });
1830} catch(error) {
1831    console.log(`catch err->${JSON.stringify(error)}`);
1832}
1833```
1834