• 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| 401 | If the input parameter is not valid parameter. |
38以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
39
40**示例:**
41
42```ts
43try {
44  var formId = '12400633174999288';
45  formHost.deleteForm(formId, (error, data) => {
46  if (error) {
47    console.log('formHost deleteForm, error:' + JSON.stringify(error));
48  } else {
49    console.log('formHost deleteForm success');
50  }
51  });
52} catch (error) {
53  console.log(`catch err->${JSON.stringify(error)}`);
54}
55
56```
57
58## deleteForm
59
60deleteForm(formId: string): Promise<void>
61
62删除指定的卡片。调用此方法后,应用程序将无法使用该卡片,卡片管理器服务不再保留有关该卡片的信息。使用Promise异步回调。
63
64**需要权限**:ohos.permission.REQUIRE_FORM
65
66**系统能力**:SystemCapability.Ability.Form
67
68**参数:**
69
70| 参数名 | 类型    | 必填 | 说明    |
71| ------ | ------ | ---- | ------- |
72| formId | string | 是   | 卡片标识。 |
73
74**返回值:**
75
76| 类型 | 说明 |
77| -------- | -------- |
78| Promise<void> | 无返回结果的Promise对象。 |
79
80
81**错误码:**
82
83| 错误码ID | 错误信息 |
84| -------- | -------- |
85| 401 | If the input parameter is not valid parameter. |
86以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
87
88**参数:**
89
90```ts
91try {
92  var formId = '12400633174999288';
93  formHost.deleteForm(formId).then(() => {
94    console.log('formHost deleteForm success');
95  }).catch((error) => {
96    console.log('formHost deleteForm, error:' + JSON.stringify(error));
97  });
98} catch(error) {
99  console.log(`catch err->${JSON.stringify(error)}`);
100}
101```
102
103## releaseForm
104
105releaseForm(formId: string, callback: AsyncCallback<void>): void
106
107释放指定的卡片。调用此方法后,应用程序将无法使用该卡片,但卡片管理器服务仍然保留有关该卡片的缓存信息和存储信息。使用callback异步回调。
108
109**需要权限**:ohos.permission.REQUIRE_FORM
110
111**系统能力**:SystemCapability.Ability.Form
112
113**参数:**
114
115| 参数名 | 类型    | 必填 | 说明    |
116| ------ | ------ | ---- | ------- |
117| formId | string | 是   | 卡片标识。 |
118| callback | AsyncCallback<void> | 是 | 回调函数。当释放指定的卡片成功,error为undefined;否则为错误对象。|
119
120**错误码:**
121
122| 错误码ID | 错误信息 |
123| -------- | -------- |
124| 401 | If the input parameter is not valid parameter. |
125以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
126
127**示例:**
128
129```ts
130try {
131  var formId = '12400633174999288';
132  formHost.releaseForm(formId, (error, data) => {
133    if (error) {
134      console.log('formHost releaseForm, error:' + JSON.stringify(error));
135    }
136  });
137} catch(error) {
138    console.log(`catch err->${JSON.stringify(error)}`);
139}
140```
141
142## releaseForm
143
144releaseForm(formId: string, isReleaseCache: boolean, callback: AsyncCallback<void>): void
145
146释放指定的卡片。调用此方法后,应用程序将无法使用该卡片,卡片管理器服务保留有关该卡片的存储信息,可以选择是否保留缓存信息。使用callback异步回调。
147
148**需要权限**:ohos.permission.REQUIRE_FORM
149
150**系统能力**:SystemCapability.Ability.Form
151
152**参数:**
153
154| 参数名         | 类型     | 必填 | 说明        |
155| -------------- | ------  | ---- | ----------- |
156| formId         | string  | 是   | 卡片标识。     |
157| isReleaseCache | boolean | 是   | 是否释放缓存。 |
158| callback | AsyncCallback<void> | 是 | 回调函数。当释放指定的卡片成功,error为undefined;否则为错误对象。 |
159
160**错误码:**
161
162| 错误码ID | 错误信息 |
163| -------- | -------- |
164| 401 | If the input parameter is not valid parameter. |
165以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
166
167**示例:**
168
169```ts
170try {
171  var formId = '12400633174999288';
172  formHost.releaseForm(formId, true, (error, data) => {
173    if (error) {
174      console.log('formHost releaseForm, error:' + JSON.stringify(error));
175    }
176  });
177} catch(error) {
178    console.log(`catch err->${JSON.stringify(error)}`);
179}
180```
181
182## releaseForm
183
184releaseForm(formId: string, isReleaseCache?: boolean): Promise<void>
185
186释放指定的卡片。调用此方法后,应用程序将无法使用该卡片,卡片管理器服务保留有关该卡片的存储信息,可以选择是否保留缓存信息。使用Promise异步回调。
187
188**需要权限**:ohos.permission.REQUIRE_FORM
189
190**系统能力**:SystemCapability.Ability.Form
191
192**参数:**
193
194| 参数名         | 类型     | 必填 | 说明        |
195| -------------- | ------  | ---- | ----------- |
196| formId         | string  | 是   | 卡片标识。     |
197| isReleaseCache | boolean | 否   | 是否释放缓存。 |
198
199**返回值:**
200
201| 类型 | 说明 |
202| -------- | -------- |
203| Promise<void> | 无返回结果的Promise对象。 |
204
205**错误码:**
206
207| 错误码ID | 错误信息 |
208| -------- | -------- |
209| 401 | If the input parameter is not valid parameter. |
210以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
211
212**示例:**
213
214```ts
215try {
216  var formId = '12400633174999288';
217  formHost.releaseForm(formId, true).then(() => {
218    console.log('formHost releaseForm success');
219  }).catch((error) => {
220    console.log('formHost releaseForm, error:' + JSON.stringify(error));
221  });
222} catch(error) {
223    console.log(`catch err->${JSON.stringify(error)}`);
224}
225```
226
227## requestForm
228
229requestForm(formId: string, callback: AsyncCallback<void>): void
230
231请求卡片更新。使用callback异步回调。
232
233**需要权限**:ohos.permission.REQUIRE_FORM
234
235**系统能力**:SystemCapability.Ability.Form
236
237**参数:**
238
239| 参数名 | 类型    | 必填 | 说明    |
240| ------ | ------ | ---- | ------- |
241| formId | string | 是   | 卡片标识。 |
242| callback | AsyncCallback<void> | 是 | 回调函数。当请求卡片更新成功,error为undefined;否则为错误对象。 |
243
244**错误码:**
245
246| 错误码ID | 错误信息 |
247| -------- | -------- |
248| 401 | If the input parameter is not valid parameter. |
249以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
250
251**示例:**
252
253```ts
254try {
255  var formId = '12400633174999288';
256  formHost.requestForm(formId, (error, data) => {
257    if (error) {
258      console.log('formHost requestForm, error:' + JSON.stringify(error));
259    }
260  });
261} catch(error) {
262    console.log(`catch err->${JSON.stringify(error)}`);
263}
264```
265
266## requestForm
267
268requestForm(formId: string): Promise<void>
269
270请求卡片更新。使用Promise异步回调。
271
272**需要权限**:ohos.permission.REQUIRE_FORM
273
274**系统能力**:SystemCapability.Ability.Form
275
276**参数:**
277
278| 参数名 | 类型    | 必填 | 说明    |
279| ------ | ------ | ---- | ------- |
280| formId | string | 是   | 卡片标识。 |
281
282**返回值:**
283
284| 类型 | 说明 |
285| -------- | -------- |
286| Promise<void> | 无返回结果的Promise对象。 |
287
288**错误码:**
289
290| 错误码ID | 错误信息 |
291| -------- | -------- |
292| 401 | If the input parameter is not valid parameter. |
293以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
294
295**示例:**
296
297```ts
298try {
299  var formId = '12400633174999288';
300  formHost.requestForm(formId).then(() => {
301    console.log('formHost requestForm success');
302  }).catch((error) => {
303    console.log('formHost requestForm, error:' + JSON.stringify(error));
304  });
305} catch(error) {
306    console.log(`catch err->${JSON.stringify(error)}`);
307}
308
309```
310
311## castToNormalForm
312
313castToNormalForm(formId: string, callback: AsyncCallback<void>): void
314
315将指定的临时卡片转换为普通卡片。使用callback异步回调。
316
317**需要权限**:ohos.permission.REQUIRE_FORM
318
319**系统能力**:SystemCapability.Ability.Form
320
321**参数:**
322
323| 参数名 | 类型    | 必填 | 说明    |
324| ------ | ------ | ---- | ------- |
325| formId | string | 是   | 卡片标识。 |
326| callback | AsyncCallback<void> | 是 | 回调函数。当将指定的临时卡片转换为普通卡片成功,err为undefined,否则为错误对象。 |
327
328**错误码:**
329
330| 错误码ID | 错误信息 |
331| -------- | -------- |
332| 401 | If the input parameter is not valid parameter. |
333以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
334
335**示例:**
336
337```ts
338try {
339  var formId = '12400633174999288';
340  formHost.castToNormalForm(formId, (error, data) => {
341    if (error) {
342      console.log('formHost castTempForm, error:' + JSON.stringify(error));
343    }
344  });
345} catch(error) {
346    console.log(`catch err->${JSON.stringify(error)}`);
347}
348```
349
350## castToNormalForm
351
352castToNormalForm(formId: string): Promise<void>
353
354将指定的临时卡片转换为普通卡片。使用Promise异步回调。
355
356**需要权限**:ohos.permission.REQUIRE_FORM
357
358**系统能力**:SystemCapability.Ability.Form
359
360**参数:**
361
362| 参数名 | 类型    | 必填 | 说明    |
363| ------ | ------ | ---- | ------- |
364| formId | string | 是   | 卡片标识。 |
365
366**返回值:**
367
368| 类型 | 说明 |
369| -------- | -------- |
370| Promise<void> | 无返回结果的Promise对象。|
371
372**错误码:**
373
374| 错误码ID | 错误信息 |
375| -------- | -------- |
376| 401 | If the input parameter is not valid parameter. |
377以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
378
379**示例:**
380
381```ts
382try {
383  var formId = '12400633174999288';
384  formHost.castToNormalForm(formId).then(() => {
385    console.log('formHost castTempForm success');
386  }).catch((error) => {
387    console.log('formHost castTempForm, error:' + JSON.stringify(error));
388  });
389} catch(error) {
390    console.log(`catch err->${JSON.stringify(error)}`);
391}
392```
393
394## notifyVisibleForms
395
396notifyVisibleForms(formIds: Array<string>, callback: AsyncCallback<void>): void
397
398向卡片框架发送通知以使指定的卡片可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。使用callback异步回调。
399
400**需要权限**:ohos.permission.REQUIRE_FORM
401
402**系统能力**:SystemCapability.Ability.Form
403
404**参数:**
405
406| 参数名 | 类型    | 必填 | 说明    |
407| ------ | ------ | ---- | ------- |
408| formIds  | Array<string>       | 是   | 卡片标识列表。         |
409| callback | AsyncCallback<void> | 是 | 回调函数。当向卡片框架发送通知以使指定的卡片可见成功,err为undefined,否则为错误对象。 |
410
411**错误码:**
412
413| 错误码ID | 错误信息 |
414| -------- | -------- |
415| 401 | If the input parameter is not valid parameter. |
416以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
417
418**示例:**
419
420```ts
421try {
422  var formId = ['12400633174999288'];
423  formHost.notifyVisibleForms(formId, (error, data) => {
424    if (error) {
425      console.log('formHost notifyVisibleForms, error:' + JSON.stringify(error));
426    }
427  });
428} catch(error) {
429    console.log(`catch err->${JSON.stringify(error)}`);
430}
431```
432
433## notifyVisibleForms
434
435notifyVisibleForms(formIds: Array<string>): Promise<void>
436
437向卡片框架发送通知以使指定的卡片可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。使用Promise异步回调。
438
439**需要权限**:ohos.permission.REQUIRE_FORM
440
441**系统能力**:SystemCapability.Ability.Form
442
443**参数:**
444
445| 参数名 | 类型    | 必填 | 说明    |
446| ------ | ------ | ---- | ------- |
447| formIds | Array<string> | 是   | 卡片标识列表。 |
448
449**返回值:**
450
451| 类型 | 说明 |
452| -------- | -------- |
453| Promise<void> | 无返回结果的Promise对象。 |
454
455**错误码:**
456
457| 错误码ID | 错误信息 |
458| -------- | -------- |
459| 401 | If the input parameter is not valid parameter. |
460以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
461
462**示例:**
463
464```ts
465try {
466  var formId = ['12400633174999288'];
467  formHost.notifyVisibleForms(formId).then(() => {
468    console.log('formHost notifyVisibleForms success');
469  }).catch((error) => {
470    console.log('formHost notifyVisibleForms, error:' + JSON.stringify(error));
471  });
472} catch(error) {
473    console.log(`catch err->${JSON.stringify(error)}`);
474}
475```
476
477## notifyInvisibleForms
478
479notifyInvisibleForms(formIds: Array<string>, callback: AsyncCallback<void>): void
480
481向卡片框架发送通知以使指定的卡片不可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。使用callback异步回调。
482
483**需要权限**:ohos.permission.REQUIRE_FORM
484
485**系统能力**:SystemCapability.Ability.Form
486
487**参数:**
488
489| 参数名 | 类型    | 必填 | 说明    |
490| ------ | ------ | ---- | ------- |
491| formIds  | Array<string>       | 是   | 卡片标识列表。|
492| callback | AsyncCallback<void> | 是 | 回调函数。当向卡片框架发送通知以使指定的卡片不可见成功,err为undefined,否则为错误对象。 |
493
494**错误码:**
495
496| 错误码ID | 错误信息 |
497| -------- | -------- |
498| 401 | If the input parameter is not valid parameter. |
499以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
500
501**示例:**
502
503```ts
504try {
505  var formId = ['12400633174999288'];
506  formHost.notifyInvisibleForms(formId, (error, data) => {
507    if (error) {
508      console.log('formHost notifyInvisibleForms, error:' + JSON.stringify(error));
509    }
510  });
511} catch(error) {
512    console.log(`catch err->${JSON.stringify(error)}`);
513}
514```
515
516## notifyInvisibleForms
517
518notifyInvisibleForms(formIds: Array<string>): Promise<void>
519
520向卡片框架发送通知以使指定的卡片不可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。使用Promise异步回调。
521
522**需要权限**:ohos.permission.REQUIRE_FORM
523
524**系统能力**:SystemCapability.Ability.Form
525
526**参数:**
527
528| 参数名 | 类型    | 必填 | 说明    |
529| ------ | ------ | ---- | ------- |
530| formIds | Array<string> | 是   | 卡片标识列表。 |
531
532**返回值:**
533
534| 类型 | 说明 |
535| -------- | -------- |
536| Promise<void> | 无返回结果的Promise对象。|
537
538**错误码:**
539
540| 错误码ID | 错误信息 |
541| -------- | -------- |
542| 401 | If the input parameter is not valid parameter. |
543以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
544
545**示例:**
546
547```ts
548try {
549  var formId = ['12400633174999288'];
550  formHost.notifyInvisibleForms(formId).then(() => {
551    console.log('formHost notifyInvisibleForms success');
552  }).catch((error) => {
553    console.log('formHost notifyInvisibleForms, error:' + JSON.stringify(error));
554  });
555} catch(error) {
556    console.log(`catch err->${JSON.stringify(error)}`);
557}
558```
559
560## enableFormsUpdate
561
562enableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void>): void
563
564向卡片框架发送通知以使指定的卡片可以更新。该方法调用成功后,卡片刷新状态设置为使能,卡片可以接收来自卡片提供方的更新。使用callback异步回调。
565
566**需要权限**:ohos.permission.REQUIRE_FORM
567
568**系统能力**:SystemCapability.Ability.Form
569
570**参数:**
571
572| 参数名 | 类型    | 必填 | 说明    |
573| ------ | ------ | ---- | ------- |
574| formIds  | Array<string>       | 是   | 卡片标识列表。         |
575| callback | AsyncCallback<void> | 是 | 回调函数。当向卡片框架发送通知以使指定的卡片可以更新成功,err为undefined,否则为错误对象。 |
576
577**错误码:**
578
579| 错误码ID | 错误信息 |
580| -------- | -------- |
581| 401 | If the input parameter is not valid parameter. |
582以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
583
584**示例:**
585
586```ts
587try {
588  var formId = ['12400633174999288'];
589  formHost.enableFormsUpdate(formId, (error, data) => {
590    if (error) {
591      console.log('formHost enableFormsUpdate, error:' + JSON.stringify(error));
592    }
593  });
594} catch(error) {
595    console.log(`catch err->${JSON.stringify(error)}`);
596}
597```
598
599## enableFormsUpdate
600
601enableFormsUpdate(formIds: Array<string>): Promise<void>
602
603向卡片框架发送通知以使指定的卡片可以更新。该方法调用成功后,卡片刷新状态设置为使能,卡片可以接收来自卡片提供方的更新。使用Promise异步回调。
604
605**需要权限**:ohos.permission.REQUIRE_FORM
606
607**系统能力**:SystemCapability.Ability.Form
608
609**参数:**
610
611| 参数名 | 类型    | 必填 | 说明    |
612| ------ | ------ | ---- | ------- |
613| formIds | Array<string> | 是   | 卡片标识列表。 |
614
615**返回值:**
616
617| 类型 | 说明 |
618| -------- | -------- |
619| Promise<void> | 无返回结果的Promise对象。 |
620
621**错误码:**
622
623| 错误码ID | 错误信息 |
624| -------- | -------- |
625| 401 | If the input parameter is not valid parameter. |
626以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
627
628**示例:**
629
630```ts
631try {
632  var formId = ['12400633174999288'];
633  formHost.enableFormsUpdate(formId).then(() => {
634    console.log('formHost enableFormsUpdate success');
635  }).catch((error) => {
636    console.log('formHost enableFormsUpdate, error:' + JSON.stringify(error));
637  });
638} catch(error) {
639    console.log(`catch err->${JSON.stringify(error)}`);
640}
641```
642
643## disableFormsUpdate
644
645disableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void>): void
646
647向卡片框架发送通知以使指定的卡片不可以更新。该方法调用成功后,卡片刷新状态设置为去使能,卡片不可以接收来自卡片提供方的更新。使用callback异步回调。
648
649**需要权限**:ohos.permission.REQUIRE_FORM
650
651**系统能力**:SystemCapability.Ability.Form
652
653**参数:**
654
655| 参数名 | 类型    | 必填 | 说明    |
656| ------ | ------ | ---- | ------- |
657| formIds  | Array<string>       | 是   | 卡片标识列表。         |
658| callback | AsyncCallback<void> | 是 | 回调函数。当向卡片框架发送通知以使指定的卡片不可以更新成功,err为undefined,否则为错误对象。 |
659
660**错误码:**
661
662| 错误码ID | 错误信息 |
663| -------- | -------- |
664| 401 | If the input parameter is not valid parameter. |
665以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
666
667**示例:**
668
669```ts
670try {
671  var formId = ['12400633174999288'];
672  formHost.disableFormsUpdate(formId, (error, data) => {
673    if (error) {
674      console.log('formHost disableFormsUpdate, error:' + JSON.stringify(error));
675    }
676  });
677} catch(error) {
678    console.log(`catch err->${JSON.stringify(error)}`);
679}
680```
681
682## disableFormsUpdate
683
684disableFormsUpdate(formIds: Array<string>): Promise<void>
685
686向卡片框架发送通知以使指定的卡片不可以更新。该方法调用成功后,卡片刷新状态设置为去使能,卡片不可以接收来自卡片提供方的更新。使用Promise异步回调。
687
688**需要权限**:ohos.permission.REQUIRE_FORM
689
690**系统能力**:SystemCapability.Ability.Form
691
692**参数:**
693
694| 参数名 | 类型    | 必填 | 说明    |
695| ------ | ------ | ---- | ------- |
696| formIds | Array<string> | 是   | 卡片标识列表。 |
697
698**返回值:**
699
700| 类型 | 说明 |
701| -------- | -------- |
702| Promise<void> | 无返回结果的Promise对象。 |
703
704**错误码:**
705
706| 错误码ID | 错误信息 |
707| -------- | -------- |
708| 401 | If the input parameter is not valid parameter. |
709以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
710
711**示例:**
712
713```ts
714try {
715  var formId = ['12400633174999288'];
716  formHost.disableFormsUpdate(formId).then(() => {
717    console.log('formHost disableFormsUpdate success');
718  }).catch((error) => {
719    console.log('formHost disableFormsUpdate, error:' + JSON.stringify(error));
720  });
721} catch(error) {
722    console.log(`catch err->${JSON.stringify(error)}`);
723}
724```
725
726## isSystemReady
727
728isSystemReady(callback: AsyncCallback<void>): void
729
730检查系统是否准备好。使用callback异步回调。
731
732**系统能力**:SystemCapability.Ability.Form
733
734**参数:**
735
736| 参数名 | 类型    | 必填 | 说明    |
737| ------ | ------ | ---- | ------- |
738| callback | AsyncCallback<void> | 是 | 回调函数。当检查系统是否准备好成功,err为undefined,否则为错误对象。 |
739
740**示例:**
741
742```ts
743try {
744  var formId = '12400633174999288';
745  formHost.isSystemReady((error, data) => {
746    if (error) {
747      console.log('formHost isSystemReady, error:' + JSON.stringify(error));
748    }
749  });
750} catch(error) {
751    console.log(`catch err->${JSON.stringify(error)}`);
752}
753```
754
755## isSystemReady
756
757isSystemReady(): Promise<void>
758
759检查系统是否准备好。使用Promise异步回调。
760
761**系统能力**:SystemCapability.Ability.Form
762
763**返回值:**
764
765| 类型 | 说明 |
766| -------- | -------- |
767| Promise<void> | 无返回结果的Promise对象。 |
768
769**示例:**
770
771```ts
772try {
773  var formId = '12400633174999288';
774  formHost.isSystemReady().then(() => {
775    console.log('formHost isSystemReady success');
776  }).catch((error) => {
777    console.log('formHost isSystemReady, error:' + JSON.stringify(error));
778  });
779} catch(error) {
780    console.log(`catch err->${JSON.stringify(error)}`);
781}
782```
783
784## getAllFormsInfo
785
786getAllFormsInfo(callback: AsyncCallback<Array<formInfo.FormInfo>>): void
787
788获取设备上所有应用提供的卡片信息。使用callback异步回调。
789
790**需要权限**:ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
791
792**系统能力**:SystemCapability.Ability.Form
793
794**参数:**
795
796| 参数名 | 类型    | 必填 | 说明    |
797| ------ | ------ | ---- | ------- |
798| callback | AsyncCallback<Array<[FormInfo](js-apis-app-form-formInfo.md)>> | 是 | 回调函数。当获取设备上所有应用提供的卡片信息成功,err为undefined,data为查询到的卡片信息;否则为错误对象。 |
799
800**示例:**
801
802```ts
803try {
804  formHost.getAllFormsInfo((error, data) => {
805    if (error) {
806      console.log('formHost getAllFormsInfo, error:' + JSON.stringify(error));
807    } else {
808      console.log('formHost getAllFormsInfo, data:' + JSON.stringify(data));
809    }
810  });
811} catch(error) {
812    console.log(`catch err->${JSON.stringify(error)}`);
813}
814```
815
816## getAllFormsInfo
817
818getAllFormsInfo(): Promise<Array<formInfo.FormInfo>>
819
820获取设备上所有应用提供的卡片信息。使用Promise异步回调。
821
822**需要权限**:ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
823
824**系统能力**:SystemCapability.Ability.Form
825
826**返回值:**
827
828| 类型          | 说明                                |
829| :------------ | :---------------------------------- |
830| Promise<Array<[FormInfo](js-apis-app-form-formInfo.md)>> | Promise对象,返回查询到的卡片信息。 |
831
832**示例:**
833
834```ts
835try {
836  formHost.getAllFormsInfo().then((data) => {
837      console.log('formHost getAllFormsInfo data:' + JSON.stringify(data));
838  }).catch((error) => {
839      console.log('formHost getAllFormsInfo, error:' + JSON.stringify(error));
840  });
841} catch(error) {
842    console.log(`catch err->${JSON.stringify(error)}`);
843}
844```
845
846## getFormsInfo
847
848getFormsInfo(bundleName: string, callback: AsyncCallback<Array<formInfo.FormInfo>>): void
849
850获取设备上指定应用程序提供的卡片信息。使用callback异步回调。
851
852**需要权限**:ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
853
854**系统能力**:SystemCapability.Ability.Form
855
856**参数:**
857
858| 参数名 | 类型    | 必填 | 说明    |
859| ------ | ------ | ---- | ------- |
860| bundleName | string | 是 |  要查询的应用程序包名称。 |
861| callback | AsyncCallback<Array<[FormInfo](js-apis-app-form-formInfo.md)>> | 是 | 回调函数。当获取设备上指定应用程序提供的卡片信息成功,err为undefined,data为查询到的卡片信息;否则为错误对象。 |
862
863**错误码:**
864
865| 错误码ID | 错误信息 |
866| -------- | -------- |
867| 401 | If the input parameter is not valid parameter. |
868以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
869
870**示例:**
871
872```ts
873try {
874  formHost.getFormsInfo('com.example.ohos.formjsdemo', (error, data) => {
875    if (error) {
876      console.log('formHost getFormsInfo, error:' + JSON.stringify(error));
877    } else {
878      console.log('formHost getFormsInfo, data:' + JSON.stringify(data));
879    }
880  });
881} catch(error) {
882    console.log(`catch err->${JSON.stringify(error)}`);
883}
884```
885
886## getFormsInfo
887
888getFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback<Array<formInfo.FormInfo>>): void
889
890获取设备上指定应用程序提供的卡片信息。使用callback异步回调。
891
892**需要权限**:ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
893
894**系统能力**:SystemCapability.Ability.Form
895
896**参数:**
897
898| 参数名 | 类型    | 必填 | 说明    |
899| ------ | ------ | ---- | ------- |
900| bundleName | string | 是 |  要查询的应用程序包名称。 |
901| moduleName | string | 是 |  要查询的模块名称。 |
902| callback | AsyncCallback<Array<[FormInfo](js-apis-app-form-formInfo.md)>> | 是 | 回调函数。当获取设备上指定应用程序提供的卡片信息成功,err为undefined,data为查询到的卡片信息;否则为错误对象。 |
903
904**错误码:**
905
906| 错误码ID | 错误信息 |
907| -------- | -------- |
908| 401 | If the input parameter is not valid parameter. |
909以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
910
911**示例:**
912
913```ts
914try {
915  formHost.getFormsInfo('com.example.ohos.formjsdemo', 'entry', (error, data) => {
916    if (error) {
917        console.log('formHost getFormsInfo, error:' + JSON.stringify(error));
918    } else {
919        console.log('formHost getFormsInfo, data:' + JSON.stringify(data));
920    }
921  });
922} catch(error) {
923    console.log(`catch err->${JSON.stringify(error)}`);
924}
925```
926
927## getFormsInfo
928
929getFormsInfo(bundleName: string, moduleName?: string): Promise<Array<formInfo.FormInfo>>
930
931获取设备上指定应用程序提供的卡片信息。使用Promise异步回调。
932
933**需要权限**:ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
934
935**系统能力**:SystemCapability.Ability.Form
936
937**参数:**
938
939| 参数名 | 类型    | 必填 | 说明    |
940| ------ | ------ | ---- | ------- |
941| bundleName | string | 是 |  要查询的应用程序包名称。 |
942| moduleName | string | 否 |  要查询的模块名称。 |
943
944**返回值:**
945
946| 类型          | 说明                                |
947| :------------ | :---------------------------------- |
948| Promise<Array<[FormInfo](js-apis-app-form-formInfo.md)>> | Promise对象,返回查询到的卡片信息。 |
949
950**错误码:**
951
952| 错误码ID | 错误信息 |
953| -------- | -------- |
954| 401 | If the input parameter is not valid parameter. |
955以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
956
957**示例:**
958
959```ts
960try {
961  formHost.getFormsInfo('com.example.ohos.formjsdemo', 'entry').then((data) => {
962    console.log('formHost getFormsInfo, data:' + JSON.stringify(data));
963  }).catch((error) => {
964    console.log('formHost getFormsInfo, error:' + JSON.stringify(error));
965  });
966} catch(error) {
967    console.log(`catch err->${JSON.stringify(error)}`);
968}
969```
970
971## deleteInvalidForms
972
973deleteInvalidForms(formIds: Array<string>, callback: AsyncCallback<number>): void
974
975根据列表删除应用程序的无效卡片。使用callback异步回调。
976
977**需要权限**:ohos.permission.REQUIRE_FORM
978
979**系统能力**:SystemCapability.Ability.Form
980
981**参数:**
982
983| 参数名 | 类型    | 必填 | 说明    |
984| ------ | ------ | ---- | ------- |
985| formIds | Array<string> | 是   | 有效卡片标识列表。 |
986| callback | AsyncCallback<number> | 是 | 回调函数。当根据列表删除应用程序的无效卡片成功,err为undefined,data为删除的卡片个数;否则为错误对象。 |
987
988**示例:**
989
990```ts
991try {
992  var formIds = new Array('12400633174999288', '12400633174999289');
993  formHost.deleteInvalidForms(formIds, (error, data) => {
994    if (error) {
995      console.log('formHost deleteInvalidForms, error:' + JSON.stringify(error));
996    } else {
997      console.log('formHost deleteInvalidForms, data:' + JSON.stringify(data));
998    }
999  });
1000} catch(error) {
1001    console.log(`catch err->${JSON.stringify(error)}`);
1002}
1003```
1004
1005## deleteInvalidForms
1006
1007deleteInvalidForms(formIds: Array<string>): Promise<number>
1008
1009根据列表删除应用程序的无效卡片。使用Promise异步回调。
1010
1011**需要权限**:ohos.permission.REQUIRE_FORM
1012
1013**系统能力**:SystemCapability.Ability.Form
1014
1015**参数:**
1016
1017| 参数名 | 类型    | 必填 | 说明    |
1018| ------ | ------ | ---- | ------- |
1019| formIds | Array<string> | 是   | 有效卡片标识列表。 |
1020
1021**返回值:**
1022
1023| 类型          | 说明                                |
1024| :------------ | :---------------------------------- |
1025| Promise<number> | Promise对象,返回删除的卡片个数。 |
1026
1027**示例:**
1028
1029```ts
1030try {
1031  var formIds = new Array('12400633174999288', '12400633174999289');
1032  formHost.deleteInvalidForms(formIds).then((data) => {
1033    console.log('formHost deleteInvalidForms, data:' + JSON.stringify(data));
1034  }).catch((error) => {
1035    console.log('formHost deleteInvalidForms, error:' + JSON.stringify(error));
1036  });
1037} catch(error) {
1038    console.log(`catch err->${JSON.stringify(error)}`);
1039}
1040```
1041
1042## acquireFormState
1043
1044acquireFormState(want: Want, callback: AsyncCallback<formInfo.FormStateInfo>): void
1045
1046获取卡片状态。使用callback异步回调。
1047
1048**需要权限**:ohos.permission.REQUIRE_FORMohos.permission.GET_BUNDLE_INFO_PRIVILEGED
1049
1050**系统能力**:SystemCapability.Ability.Form
1051
1052**参数:**
1053
1054| 参数名 | 类型    | 必填 | 说明    |
1055| ------ | ------ | ---- | ------- |
1056| want | [Want](js-apis-application-want.md) | 是   | 查询卡片状态时携带的want信息。 |
1057| callback | AsyncCallback<[FormStateInfo](js-apis-app-form-formInfo.md#formstateinfo)> | 是 | 回调函数。当获取卡片状态成功,err为undefined,data为获取到的卡片状态;否则为错误对象。 |
1058
1059**错误码:**
1060
1061| 错误码ID | 错误信息 |
1062| -------- | -------- |
1063| 401 | If the input parameter is not valid parameter. |
1064以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
1065
1066**示例:**
1067
1068```ts
1069var want = {
1070  'deviceId': '',
1071  'bundleName': 'ohos.samples.FormApplication',
1072  'abilityName': 'FormAbility',
1073  'parameters': {
1074    'ohos.extra.param.key.module_name': 'entry',
1075    'ohos.extra.param.key.form_name': 'widget',
1076    'ohos.extra.param.key.form_dimension': 2
1077  }
1078};
1079try {
1080  formHost.acquireFormState(want, (error, data) => {
1081    if (error) {
1082      console.log('formHost acquireFormState, error:' + JSON.stringify(error));
1083    } else {
1084      console.log('formHost acquireFormState, data:' + JSON.stringify(data));
1085    }
1086  });
1087} catch(error) {
1088    console.log(`catch err->${JSON.stringify(error)}`);
1089}
1090```
1091
1092## acquireFormState
1093
1094acquireFormState(want: Want): Promise<formInfo.FormStateInfo>
1095
1096获取卡片状态。使用Promise异步回调。
1097
1098**需要权限**:ohos.permission.REQUIRE_FORMohos.permission.GET_BUNDLE_INFO_PRIVILEGED
1099
1100**系统能力**:SystemCapability.Ability.Form
1101
1102**参数:**
1103
1104| 参数名 | 类型    | 必填 | 说明    |
1105| ------ | ------ | ---- | ------- |
1106| want   | [Want](js-apis-application-want.md) | 是   | 查询卡片状态时携带的want信息。 |
1107
1108**返回值:**
1109
1110| 类型          | 说明                                |
1111| :------------ | :---------------------------------- |
1112| Promise<[FormStateInfo](js-apis-app-form-formInfo.md#formstateinfo)> | Promise对象,返回卡片状态。 |
1113
1114**错误码:**
1115
1116| 错误码ID | 错误信息 |
1117| -------- | -------- |
1118| 401 | If the input parameter is not valid parameter. |
1119以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
1120
1121**示例:**
1122
1123```ts
1124var want = {
1125  'deviceId': '',
1126  'bundleName': 'ohos.samples.FormApplication',
1127  'abilityName': 'FormAbility',
1128  'parameters': {
1129    'ohos.extra.param.key.module_name': 'entry',
1130    'ohos.extra.param.key.form_name': 'widget',
1131    'ohos.extra.param.key.form_dimension': 2
1132  }
1133};
1134try {
1135  formHost.acquireFormState(want).then((data) => {
1136    console.log('formHost acquireFormState, data:' + JSON.stringify(data));
1137  }).catch((error) => {
1138    console.log('formHost acquireFormState, error:' + JSON.stringify(error));
1139  });
1140} catch(error) {
1141    console.log(`catch err->${JSON.stringify(error)}`);
1142}
1143```
1144
1145## on('formUninstall')
1146
1147on(type: 'formUninstall', callback: Callback<string>): void
1148
1149订阅卡片卸载事件。使用callback异步回调。
1150
1151**系统能力**:SystemCapability.Ability.Form
1152
1153**参数:**
1154
1155| 参数名 | 类型    | 必填 | 说明    |
1156| ------ | ------ | ---- | ------- |
1157| type | string | 是   | 填写'formUninstall',表示卡片卸载事件。 |
1158| callback | Callback<string> | 是 | 回调函数。返回卡片标识。 |
1159
1160**示例:**
1161
1162```ts
1163let callback = function(formId) {
1164  console.log('formHost on formUninstall, formId:' + formId);
1165}
1166formHost.on('formUninstall', callback);
1167```
1168
1169## off('formUninstall')
1170
1171off(type: 'formUninstall', callback?: Callback<string>): void
1172
1173取消订阅卡片卸载事件。使用callback异步回调。
1174
1175**系统能力**:SystemCapability.Ability.Form
1176
1177**参数:**
1178
1179| 参数名 | 类型    | 必填 | 说明    |
1180| ------ | ------ | ---- | ------- |
1181| type | string | 是   | 填写'formUninstall',表示卡片卸载事件。 |
1182| callback | Callback<string> | 否 | 回调函数。返回卡片标识。缺省时,表示注销所有已注册事件回调。 |
1183
1184**示例:**
1185
1186```ts
1187let callback = function(formId) {
1188  console.log('formHost on formUninstall, formId:' + formId);
1189}
1190formHost.off('formUninstall', callback);
1191```
1192
1193## notifyFormsVisible
1194
1195notifyFormsVisible(formIds: Array<string>, isVisible: boolean, callback: AsyncCallback<void>): void
1196
1197通知卡片是否可见。使用callback异步回调。
1198
1199**需要权限**:ohos.permission.REQUIRE_FORM
1200
1201**系统能力**:SystemCapability.Ability.Form
1202
1203**参数:**
1204
1205| 参数名 | 类型    | 必填 | 说明    |
1206| ------ | ------ | ---- | ------- |
1207| formIds | Array<string> | 是   | 卡片标识列表。 |
1208| isVisible | boolean | 是   | 是否可见。 |
1209| callback | AsyncCallback<void> | 是 | 回调函数。当通知卡片是否可见成功,err为undefined,否则为错误对象。 |
1210
1211**错误码:**
1212
1213| 错误码ID | 错误信息 |
1214| -------- | -------- |
1215| 401 | If the input parameter is not valid parameter. |
1216以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
1217
1218**示例:**
1219
1220```ts
1221var formIds = new Array('12400633174999288', '12400633174999289');
1222try {
1223  formHost.notifyFormsVisible(formIds, true, (error, data) => {
1224    if (error) {
1225      console.log('formHost notifyFormsVisible, error:' + JSON.stringify(error));
1226    }
1227  });
1228} catch(error) {
1229    console.log(`catch err->${JSON.stringify(error)}`);
1230}
1231```
1232
1233## notifyFormsVisible
1234
1235notifyFormsVisible(formIds: Array<string>, isVisible: boolean): Promise<void>
1236
1237通知卡片是否可见。使用Promise异步回调。
1238
1239**需要权限**:ohos.permission.REQUIRE_FORM
1240
1241**系统能力**:SystemCapability.Ability.Form
1242
1243**参数:**
1244
1245| 参数名 | 类型    | 必填 | 说明    |
1246| ------ | ------ | ---- | ------- |
1247| formIds | Array<string> | 是   | 卡片标识列表。 |
1248| isVisible | boolean | 是   | 是否可见。 |
1249
1250**返回值:**
1251
1252| 类型 | 说明 |
1253| -------- | -------- |
1254| Promise<void> | 无返回结果的Promise对象。 |
1255
1256**错误码:**
1257
1258| 错误码ID | 错误信息 |
1259| -------- | -------- |
1260| 401 | If the input parameter is not valid parameter. |
1261以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
1262
1263**示例:**
1264
1265```ts
1266var formIds = new Array('12400633174999288', '12400633174999289');
1267try {
1268  formHost.notifyFormsVisible(formIds, true).then(() => {
1269    console.log('formHost notifyFormsVisible success');
1270  }).catch((error) => {
1271    console.log('formHost notifyFormsVisible, error:' + JSON.stringify(error));
1272  });
1273} catch(error) {
1274    console.log(`catch err->${JSON.stringify(error)}`);
1275}
1276```
1277
1278## notifyFormsEnableUpdate
1279
1280notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean, callback: AsyncCallback<void>): void
1281
1282通知卡片是否启用更新状态。使用callback异步回调。
1283
1284**需要权限**:ohos.permission.REQUIRE_FORM
1285
1286**系统能力**:SystemCapability.Ability.Form
1287
1288**参数:**
1289
1290| 参数名 | 类型    | 必填 | 说明    |
1291| ------ | ------ | ---- | ------- |
1292| formIds | Array<string> | 是   | 卡片标识列表。 |
1293| isEnableUpdate | boolean | 是   | 是否使能更新。 |
1294| callback | AsyncCallback<void> | 是 | 回调函数。当通知卡片是否启用更新状态成功,err为undefined,否则为错误对象。 |
1295
1296**错误码:**
1297
1298| 错误码ID | 错误信息 |
1299| -------- | -------- |
1300| 401 | If the input parameter is not valid parameter. |
1301以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
1302
1303**示例:**
1304
1305```ts
1306var formIds = new Array('12400633174999288', '12400633174999289');
1307try {
1308  formHost.notifyFormsEnableUpdate(formIds, true, (error, data) => {
1309    if (error) {
1310      console.log('formHost notifyFormsEnableUpdate, error:' + JSON.stringify(error));
1311    }
1312  });
1313} catch(error) {
1314    console.log(`catch err->${JSON.stringify(error)}`);
1315}
1316```
1317
1318## notifyFormsEnableUpdate
1319
1320notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean): Promise<void>
1321
1322通知卡片是否启用更新状态。使用Promise异步回调。
1323
1324**需要权限**:ohos.permission.REQUIRE_FORM
1325
1326**系统能力**:SystemCapability.Ability.Form
1327
1328**参数:**
1329
1330| 参数名 | 类型    | 必填 | 说明    |
1331| ------ | ------ | ---- | ------- |
1332| formIds | Array<string> | 是   | 卡片标识列表。 |
1333| isEnableUpdate | boolean | 是   | 是否使能更新。 |
1334
1335**返回值:**
1336
1337| 类型 | 说明 |
1338| -------- | -------- |
1339| Promise<void> | 无返回结果的Promise对象。 |
1340
1341**错误码:**
1342
1343| 错误码ID | 错误信息 |
1344| -------- | -------- |
1345| 401 | If the input parameter is not valid parameter. |
1346以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
1347
1348**示例:**
1349
1350```ts
1351var formIds = new Array('12400633174999288', '12400633174999289');
1352try {
1353  formHost.notifyFormsEnableUpdate(formIds, true).then(() => {
1354    console.log('formHost notifyFormsEnableUpdate success');
1355  }).catch((error) => {
1356    console.log('formHost notifyFormsEnableUpdate, error:' + JSON.stringify(error));
1357  });
1358} catch(error) {
1359    console.log(`catch err->${JSON.stringify(error)}`);
1360}
1361```
1362## shareForm
1363
1364shareForm(formId: string, deviceId: string, callback: AsyncCallback<void>): void
1365
1366指定formId和远程设备Id进行卡片分享。使用callback异步回调。
1367
1368**需要权限**:ohos.permission.REQUIRE_FORMohos.permission.DISTRIBUTED_DATASYNC
1369
1370**系统能力**:SystemCapability.Ability.Form
1371
1372**参数:**
1373
1374| 参数名 | 类型    | 必填 | 说明    |
1375| ------ | ------ | ---- | ------- |
1376| formId | string | 是   | 卡片标识。 |
1377| deviceId | string | 是   | 远程设备标识。 |
1378| callback | AsyncCallback<void> | 是 | 回调函数。当指定formId和远程设备Id进行卡片分享成功,err为undefined,否则为错误对象。 |
1379
1380**错误码:**
1381
1382| 错误码ID | 错误信息 |
1383| -------- | -------- |
1384| 401 | If the input parameter is not valid parameter. |
1385以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
1386
1387
1388**示例:**
1389
1390```ts
1391var formId = '12400633174999288';
1392var deviceId = 'EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2';
1393try {
1394  formHost.shareForm(formId, deviceId, (error, data) => {
1395    if (error) {
1396      console.log('formHost shareForm, error:' + JSON.stringify(error));
1397    }
1398  });
1399} catch(error) {
1400    console.log(`catch err->${JSON.stringify(error)}`);
1401}
1402```
1403
1404## shareForm
1405
1406shareForm(formId: string, deviceId: string): Promise<void>
1407
1408指定formId和远程设备Id进行卡片分享。使用Promise异步回调。
1409
1410**需要权限**:ohos.permission.REQUIRE_FORMohos.permission.DISTRIBUTED_DATASYNC
1411
1412**系统能力**:SystemCapability.Ability.Form
1413
1414**参数:**
1415
1416| 参数名 | 类型    | 必填 | 说明    |
1417| ------ | ------ | ---- | ------- |
1418| formId | string | 是   | 卡片标识。 |
1419| deviceId | string | 是   | 远程设备标识。 |
1420
1421**返回值:**
1422
1423| 类型 | 说明 |
1424| -------- | -------- |
1425| Promise<void> | 无返回结果的Promise对象。 |
1426
1427**错误码:**
1428
1429| 错误码ID | 错误信息 |
1430| -------- | -------- |
1431| 401 | If the input parameter is not valid parameter. |
1432以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。
1433
1434**参数:**
1435
1436```ts
1437var formId = '12400633174999288';
1438var deviceId = 'EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2';
1439try {
1440  formHost.shareForm(formId, deviceId).then(() => {
1441    console.log('formHost shareForm success');
1442  }).catch((error) => {
1443    console.log('formHost shareForm, error:' + JSON.stringify(error));
1444  });
1445} catch(error) {
1446    console.log(`catch err->${JSON.stringify(error)}`);
1447}
1448```
1449
1450## notifyFormsPrivacyProtected
1451
1452notifyFormsPrivacyProtected(formIds: Array\<string>, isProtected: boolean, callback: AsyncCallback\<void>): void
1453
1454**需要权限**:ohos.permission.REQUIRE_FORM
1455
1456**系统能力**:SystemCapability.Ability.Form
1457
1458**参数:**
1459
1460| 参数名 | 类型    | 必填 | 说明    |
1461| ------ | ------ | ---- | ------- |
1462| formId | string | 是   | 卡片标识。 |
1463| deviceId | string | 是   | 远程设备标识。 |
1464
1465```ts
1466var formIds = new Array('12400633174999288', '12400633174999289');
1467try {
1468  formHost.notifyFormsPrivacyProtected(formIds, true).then(() => {
1469    console.log('formHost shareForm success');
1470  }).catch((error) => {
1471    console.log('formHost shareForm, error:' + JSON.stringify(error));
1472  });
1473} catch(error) {
1474    console.log(`catch err->${JSON.stringify(error)}`);
1475}
1476```
1477