1# @ohos.app.form.formProvider (formProvider) 2 3FormProvider模块提供了卡片提供方相关接口的能力,开发者在开发卡片时,可通过该模块提供接口实现更新卡片、设置卡片更新时间、获取卡片信息、请求发布卡片等。 4 5> **说明:** 6> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 7 8## 导入模块 9 10```ts 11import formProvider from '@ohos.app.form.formProvider'; 12``` 13 14## setFormNextRefreshTime 15 16setFormNextRefreshTime(formId: string, minute: number, callback: AsyncCallback<void>): void 17 18设置指定卡片的下一次更新时间,使用callback异步回调。 19 20**系统能力:** SystemCapability.Ability.Form 21 22**参数:** 23 24| 参数名 | 类型 | 必填 | 说明 | 25| ------ | ------ | ---- | ------------------------------------- | 26| formId | string | 是 | 卡片标识。 | 27| minute | number | 是 | 指定多久之后更新,单位分钟,大于等于5。 | 28| callback | AsyncCallback<void> | 是 | 回调函数。 | 29 30**错误码:** 31 32| 错误码ID | 错误信息 | 33| -------- | -------- | 34| 401 | If the input parameter is not valid parameter. | 35| 16500050 | An IPC connection error happened. | 36| 16500060 | A service connection error happened, please try again later. | 37| 16500100 | Failed to obtain the configuration information. | 38| 16501000 | An internal functional error occurred. | 39| 16501001 | The ID of the form to be operated does not exist. | 40| 16501002 | The number of forms exceeds upper bound. | 41| 16501003 | The form can not be operated by the current application. | 42 43以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。 44 45**示例:** 46 47```ts 48import Base from '@ohos.base'; 49 50let formId: string = '12400633174999288'; 51try { 52 formProvider.setFormNextRefreshTime(formId, 5, (error: Base.BusinessError) => { 53 if (error) { 54 console.error(`callback error, code: ${error.code}, message: ${error.message})`); 55 return; 56 } 57 console.log(`formProvider setFormNextRefreshTime success`); 58 }); 59} catch (error) { 60 console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`); 61} 62``` 63 64## setFormNextRefreshTime 65 66setFormNextRefreshTime(formId: string, minute: number): Promise<void> 67 68设置指定卡片的下一次更新时间,使用Promise异步回调。 69 70**系统能力:** SystemCapability.Ability.Form 71 72**参数:** 73 74| 参数名 | 类型 | 必填 | 说明 | 75| ------ | ------ | ---- | ------------------------------------- | 76| formId | string | 是 | 卡片标识。 | 77| minute | number | 是 | 指定多久之后更新,单位分钟,大于等于5。 | 78 79**返回值:** 80 81| 类型 | 说明 | 82| ------------- | ---------------------------------- | 83| Promise\<void> | 无返回结果的Promise对象。 | 84 85**错误码:** 86 87| 错误码ID | 错误信息 | 88| -------- | -------- | 89| 401 | If the input parameter is not valid parameter. | 90| 16500050 | An IPC connection error happened. | 91| 16500060 | A service connection error happened, please try again later. | 92| 16500100 | Failed to obtain the configuration information. | 93| 16501000 | An internal functional error occurred. | 94| 16501001 | The ID of the form to be operated does not exist. | 95| 16501002 | The number of forms exceeds upper bound. | 96| 16501003 | The form can not be operated by the current application. | 97 98以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。 99 100**示例:** 101 102```ts 103import Base from '@ohos.base'; 104 105let formId: string = '12400633174999288'; 106try { 107 formProvider.setFormNextRefreshTime(formId, 5).then(() => { 108 console.log(`formProvider setFormNextRefreshTime success`); 109 }).catch((error: Base.BusinessError) => { 110 console.error(`promise error, code: ${error.code}, message: ${error.message})`); 111 }); 112} catch (error) { 113 console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`); 114} 115``` 116 117## updateForm 118 119updateForm(formId: string, formBindingData: formBindingData.FormBindingData,callback: AsyncCallback<void>): void 120 121更新指定的卡片,使用callback异步回调。 122 123**系统能力:** SystemCapability.Ability.Form 124 125**参数:** 126 127| 参数名 | 类型 | 必填 | 说明 | 128| ------ | ---------------------------------------------------------------------- | ---- | ---------------- | 129| formId | string | 是 | 请求更新的卡片标识。 | 130| formBindingData.FormBindingData | [FormBindingData](js-apis-app-form-formBindingData.md#formbindingdata) | 是 | 用于更新的数据。 | 131| callback | AsyncCallback<void> | 是 | 回调函数。 | 132 133**错误码:** 134 135| 错误码ID | 错误信息 | 136| -------- | -------- | 137| 401 | If the input parameter is not valid parameter. | 138| 16500050 | An IPC connection error happened. | 139| 16500060 | A service connection error happened, please try again later. | 140| 16500100 | Failed to obtain the configuration information. | 141| 16501000 | An internal functional error occurred. | 142| 16501001 | The ID of the form to be operated does not exist. | 143| 16501003 | The form can not be operated by the current application. | 144 145以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。 146 147**示例:** 148 149```ts 150import formBindingData from '@ohos.app.form.formBindingData'; 151import Base from '@ohos.base'; 152 153let formId: string = '12400633174999288'; 154try { 155 let param: Record<string, string> = { 156 'temperature': '22c', 157 'time': '22:00' 158 } 159 let obj: formBindingData.FormBindingData = formBindingData.createFormBindingData(param); 160 formProvider.updateForm(formId, obj, (error: Base.BusinessError) => { 161 if (error) { 162 console.error(`callback error, code: ${error.code}, message: ${error.message})`); 163 return; 164 } 165 console.log(`formProvider updateForm success`); 166 }); 167} catch (error) { 168 console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`); 169} 170``` 171 172## updateForm 173 174updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Promise<void> 175 176更新指定的卡片,使用Promise异步回调。 177 178**系统能力:** SystemCapability.Ability.Form 179 180**参数:** 181 182| 参数名 | 类型 | 必填 | 说明 | 183| ------ | ---------------------------------------------------------------------- | ---- | ---------------- | 184| formId | string | 是 | 请求更新的卡片标识。 | 185| formBindingData.FormBindingData | [FormBindingData](js-apis-app-form-formBindingData.md#formbindingdata) | 是 | 用于更新的数据。 | 186 187**返回值:** 188 189| 类型 | 说明 | 190| -------------- | ----------------------------------- | 191| Promise\<void> | 无返回结果的Promise对象。 | 192 193**错误码:** 194 195| 错误码ID | 错误信息 | 196| -------- | -------- | 197| 401 | If the input parameter is not valid parameter. | 198| 16500050 | An IPC connection error happened. | 199| 16500060 | A service connection error happened, please try again later. | 200| 16500100 | Failed to obtain the configuration information. | 201| 16501000 | An internal functional error occurred. | 202| 16501001 | The ID of the form to be operated does not exist. | 203| 16501003 | The form can not be operated by the current application. | 204 205以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。 206 207**示例:** 208 209```ts 210import formBindingData from '@ohos.app.form.formBindingData'; 211import Base from '@ohos.base'; 212 213let formId: string = '12400633174999288'; 214let param: Record<string, string> = { 215 'temperature': '22c', 216 'time': '22:00' 217} 218let obj: formBindingData.FormBindingData = formBindingData.createFormBindingData(param); 219try { 220 formProvider.updateForm(formId, obj).then(() => { 221 console.log(`formProvider updateForm success`); 222 }).catch((error: Base.BusinessError) => { 223 console.error(`promise error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`); 224 }); 225} catch (error) { 226 console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`); 227} 228``` 229 230## getFormsInfo 231 232getFormsInfo(callback: AsyncCallback<Array<formInfo.FormInfo>>): void 233 234获取设备上当前应用程序的卡片信息,使用callback异步回调。 235 236**系统能力:** SystemCapability.Ability.Form 237 238**参数:** 239 240| 参数名 | 类型 | 必填 | 说明 | 241| ------ | ------ | ---- | ------- | 242| callback | AsyncCallback<Array<[formInfo.FormInfo](js-apis-app-form-formInfo.md)>> | 是 | 回调函数。返回查询到的卡片信息。 | 243 244**错误码:** 245| 错误码ID | 错误信息 | 246| -------- | -------- | 247| 401 | If the input parameter is not valid parameter. | 248| 16500050 | An IPC connection error happened. | 249| 16500100 | Failed to obtain the configuration information. | 250| 16501000 | An internal functional error occurred. | 251 252以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。 253 254 255**示例:** 256 257```ts 258import Base from '@ohos.base'; 259 260try { 261 formProvider.getFormsInfo((error, data) => { 262 if (error) { 263 console.error(`callback error, code: ${error.code}, message: ${error.message})`); 264 return; 265 } 266 console.log(`formProvider getFormsInfo, data: ${JSON.stringify(data)}`); 267 }); 268} catch (error) { 269 console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`); 270} 271``` 272## getFormsInfo 273 274getFormsInfo(filter: formInfo.FormInfoFilter, callback: AsyncCallback<Array<formInfo.FormInfo>>): void 275 276获取设备上当前应用程序的卡片信息,并筛选符合条件的信息,使用callback异步回调。 277 278**系统能力:** SystemCapability.Ability.Form 279 280**参数:** 281 282| 参数名 | 类型 | 必填 | 说明 | 283| ------ | ------ | ---- | ------- | 284| filter | [formInfo.FormInfoFilter](js-apis-app-form-formInfo.md#forminfofilter) | 是 | 卡片信息过滤器。 | 285| callback | AsyncCallback<Array<[formInfo.FormInfo](js-apis-app-form-formInfo.md)>> | 是 | 回调函数。返回查询到符合条件的卡片信息。 | 286 287**错误码:** 288 289| 错误码ID | 错误信息 | 290| -------- | -------- | 291| 401 | If the input parameter is not valid parameter. | 292| 16500050 | An IPC connection error happened. | 293| 16500100 | Failed to obtain the configuration information. | 294| 16501000 | An internal functional error occurred. | 295 296以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。 297 298**示例:** 299 300```ts 301import Base from '@ohos.base'; 302import formInfo from '@ohos.app.form.formInfo'; 303 304const filter: formInfo.FormInfoFilter = { 305 // get info of forms belong to module entry. 306 moduleName: 'entry' 307}; 308try { 309 formProvider.getFormsInfo(filter, (error, data) => { 310 if (error) { 311 console.error(`callback error, code: ${error.code}, message: ${error.message})`); 312 return; 313 } 314 console.log(`formProvider getFormsInfo, data: ${JSON.stringify(data)}`); 315 }); 316} catch (error) { 317 console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`); 318} 319``` 320 321## getFormsInfo 322 323getFormsInfo(filter?: formInfo.FormInfoFilter): Promise<Array<formInfo.FormInfo>> 324 325获取设备上当前应用程序的卡片信息,使用Promise异步回调。 326 327**系统能力:** SystemCapability.Ability.Form 328 329**参数:** 330 331| 参数名 | 类型 | 必填 | 说明 | 332| ------ | ------ | ---- | ------- | 333| filter | [formInfo.FormInfoFilter](js-apis-app-form-formInfo.md#forminfofilter) | 否 | 卡片信息过滤器, 默认为空,不进行过滤。 | 334 335**返回值:** 336 337| 类型 | 说明 | 338| :------------ | :---------------------------------- | 339| Promise<Array<[formInfo.FormInfo](js-apis-app-form-formInfo.md)>> | Promise对象。返回查询到符合条件的卡片信息。 | 340 341**错误码:** 342 343| 错误码ID | 错误信息 | 344| -------- | -------- | 345| 401 | If the input parameter is not valid parameter. | 346| 16500050 | An IPC connection error happened. | 347| 16500100 | Failed to obtain the configuration information. | 348| 16501000 | An internal functional error occurred. | 349 350以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。 351 352**示例:** 353 354```ts 355import formInfo from '@ohos.app.form.formInfo'; 356import Base from '@ohos.base'; 357 358const filter: formInfo.FormInfoFilter = { 359 // get info of forms belong to module entry. 360 moduleName: 'entry' 361}; 362try { 363 formProvider.getFormsInfo(filter).then((data: formInfo.FormInfo[]) => { 364 console.log(`formProvider getFormsInfo, data: ${JSON.stringify(data)}`); 365 }).catch((error: Base.BusinessError) => { 366 console.error(`promise error, code: ${error.code}, message: ${error.message})`); 367 }); 368} catch (error) { 369 console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`); 370} 371``` 372 373## requestPublishForm 374 375requestPublishForm(want: Want, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback\<string>): void 376 377请求发布一张卡片到使用方。使用方通常为桌面,使用callback异步回调。 378 379**系统能力:** SystemCapability.Ability.Form 380 381**系统接口**: 此接口为系统接口。 382 383**参数:** 384 385| 参数名 | 类型 | 必填 | 说明 | 386| ------ | ---------------------------------------------------------------------- | ---- | ---------------- | 387| want | [Want](js-apis-app-ability-want.md) | 是 | 发布请求。需包含以下字段。<br>abilityName: 目标卡片ability<br>parameters:<br>'ohos.extra.param.key.form_dimension'<br>'ohos.extra.param.key.form_name'<br>'ohos.extra.param.key.module_name' | 388| formBindingData | [formBindingData.FormBindingData](js-apis-app-form-formBindingData.md#formbindingdata) | 是 | 创建卡片的数据。 | 389| callback | AsyncCallback<string> | 是 | 回调函数。返回卡片标识。 | 390 391**错误码:** 392 393| 错误码ID | 错误信息 | 394| -------- | -------- | 395| 202 | The application is not a system application. | 396| 401 | If the input parameter is not valid parameter. | 397| 16500050 | An IPC connection error happened. | 398| 16500100 | Failed to obtain the configuration information. | 399| 16501000 | An internal functional error occurred. | 400 401以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。 402 403**示例:** 404 405```ts 406import formBindingData from '@ohos.app.form.formBindingData'; 407import Want from '@ohos.app.ability.Want'; 408import Base from '@ohos.base'; 409 410let want: Want = { 411 abilityName: 'FormAbility', 412 parameters: { 413 'ohos.extra.param.key.form_dimension': 2, 414 'ohos.extra.param.key.form_name': 'widget', 415 'ohos.extra.param.key.module_name': 'entry' 416 } 417}; 418try { 419 let param: Record<string, string> = { 420 'temperature': '22c', 421 'time': '22:00' 422 } 423 let obj: formBindingData.FormBindingData = formBindingData.createFormBindingData(param); 424 formProvider.requestPublishForm(want, obj, (error: Base.BusinessError, data: string) => { 425 if (error) { 426 console.error(`callback error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`); 427 return; 428 } 429 console.log('formProvider requestPublishForm, form ID is: ${JSON.stringify(data)}'); 430 }); 431} catch (error) { 432 console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`); 433} 434``` 435 436## requestPublishForm 437 438requestPublishForm(want: Want, callback: AsyncCallback<string>): void 439 440请求发布一张卡片到使用方。使用方通常为桌面,使用callback异步回调。 441 442**系统能力:** SystemCapability.Ability.Form 443 444**系统接口**: 此接口为系统接口。 445 446**参数:** 447 448| 参数名 | 类型 | 必填 | 说明 | 449| -------- | ----------------------------------- | ---- | ------------------------------------------------------------ | 450| want | [Want](js-apis-app-ability-want.md) | 是 | 发布请求。需包含以下字段。<br>abilityName: 目标卡片ability<br>parameters:<br>'ohos.extra.param.key.form_dimension'<br>'ohos.extra.param.key.form_name'<br>'ohos.extra.param.key.module_name' | 451| callback | AsyncCallback<string> | 是 | 回调函数。返回卡片标识。 | 452 453**错误码:** 454 455| 错误码ID | 错误信息 | 456| -------- | -------- | 457| 202 | The application is not a system application. | 458| 401 | If the input parameter is not valid parameter. | 459| 16500050 | An IPC connection error happened. | 460| 16500100 | Failed to obtain the configuration information. | 461| 16501000 | An internal functional error occurred. | 462 463以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。 464 465**示例:** 466 467```ts 468import Want from '@ohos.app.ability.Want'; 469import Base from '@ohos.base'; 470 471let want: Want = { 472 abilityName: 'FormAbility', 473 parameters: { 474 'ohos.extra.param.key.form_dimension': 2, 475 'ohos.extra.param.key.form_name': 'widget', 476 'ohos.extra.param.key.module_name': 'entry' 477 } 478}; 479try { 480 formProvider.requestPublishForm(want, (error: Base.BusinessError, data: string) => { 481 if (error) { 482 console.error(`callback error, code: ${error.code}, message: ${error.message})`); 483 return; 484 } 485 console.log(`formProvider requestPublishForm, form ID is: ${JSON.stringify(data)}`); 486 }); 487} catch (error) { 488 console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`); 489} 490``` 491 492## requestPublishForm 493 494requestPublishForm(want: Want, formBindingData?: formBindingData.FormBindingData): Promise<string> 495 496请求发布一张卡片到使用方。使用方通常为桌面,使用Promise异步回调。 497 498**系统能力:** SystemCapability.Ability.Form 499 500**系统接口**: 此接口为系统接口。 501 502**参数:** 503 504| 参数名 | 类型 | 必填 | 说明 | 505| --------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | 506| want | [Want](js-apis-app-ability-want.md) | 是 | 发布请求。需包含以下字段。<br>abilityName: 目标卡片ability<br>parameters:<br>'ohos.extra.param.key.form_dimension'<br>'ohos.extra.param.key.form_name'<br>'ohos.extra.param.key.module_name' | 507| formBindingData | [formBindingData.FormBindingData](js-apis-app-form-formBindingData.md#formbindingdata) | 否 | 创建卡片的数据,默认为空,不提供创建卡片数据。 | 508 509**返回值:** 510 511| 类型 | 说明 | 512| :------------ | :---------------------------------- | 513| Promise<string> | Promise对象。返回卡片标识。 | 514 515**错误码:** 516 517| 错误码ID | 错误信息 | 518| -------- | -------- | 519| 202 | The application is not a system application. | 520| 401 | If the input parameter is not valid parameter. | 521| 16500050 | An IPC connection error happened. | 522| 16500100 | Failed to obtain the configuration information. | 523| 16501000 | An internal functional error occurred. | 524 525以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。 526 527**示例:** 528 529```ts 530import Want from '@ohos.app.ability.Want'; 531import Base from '@ohos.base'; 532 533let want: Want = { 534 abilityName: 'FormAbility', 535 parameters: { 536 'ohos.extra.param.key.form_dimension': 2, 537 'ohos.extra.param.key.form_name': 'widget', 538 'ohos.extra.param.key.module_name': 'entry' 539 } 540}; 541try { 542 formProvider.requestPublishForm(want).then((data: string) => { 543 console.log(`formProvider requestPublishForm success, form ID is : ${JSON.stringify(data)}`); 544 }).catch((error: Base.BusinessError) => { 545 console.error(`promise error, code: ${error.code}, message: ${error.message})`); 546 }); 547} catch (error) { 548 console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`); 549} 550``` 551 552## isRequestPublishFormSupported 553 554isRequestPublishFormSupported(callback: AsyncCallback<boolean>): void 555 556查询是否支持发布一张卡片到使用方,使用callback异步回调。 557 558**系统接口**: 此接口为系统接口。 559 560**系统能力:** SystemCapability.Ability.Form 561 562**参数:** 563 564| 参数名 | 类型 | 必填 | 说明 | 565| ------ | ------ | ---- | ------- | 566| callback | AsyncCallback<boolean> | 是 | 回调函数。返回是否支持发布一张卡片到使用方。| 567 568**错误码:** 569 570| 错误码ID | 错误信息 | 571| -------- | -------- | 572| 202 | If the application is not a system application. | 573| 401 | If the input parameter is not valid parameter. | 574| 16500050 | An IPC connection error happened. | 575| 16501000 | An internal functional error occurred. | 576 577以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。 578 579**示例:** 580 581```ts 582import Want from '@ohos.app.ability.Want'; 583import Base from '@ohos.base'; 584 585try { 586 formProvider.isRequestPublishFormSupported((error: Base.BusinessError, isSupported: boolean) => { 587 if (error) { 588 console.error(`callback error, code: ${error.code}, message: ${error.message})`); 589 } else { 590 if (isSupported) { 591 let want: Want = { 592 abilityName: 'FormAbility', 593 parameters: { 594 'ohos.extra.param.key.form_dimension': 2, 595 'ohos.extra.param.key.form_name': 'widget', 596 'ohos.extra.param.key.module_name': 'entry' 597 } 598 }; 599 try { 600 formProvider.requestPublishForm(want, (error: Base.BusinessError, data: string) => { 601 if (error) { 602 console.error(`callback error, code: ${error.code}, message: ${error.message})`); 603 return; 604 } 605 console.log(`formProvider requestPublishForm, form ID is: ${JSON.stringify(data)}`); 606 }); 607 } catch (error) { 608 console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`); 609 } 610 } 611 } 612 }); 613} catch (error) { 614 console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`); 615} 616``` 617 618## isRequestPublishFormSupported 619 620isRequestPublishFormSupported(): Promise<boolean> 621 622查询是否支持发布一张卡片到使用方,使用Promise异步回调。 623 624**系统接口**: 此接口为系统接口。 625 626**系统能力:** SystemCapability.Ability.Form 627 628**返回值:** 629 630| 类型 | 说明 | 631| :------------ | :---------------------------------- | 632| Promise<boolean> | Promise对象。返回是否支持发布一张卡片到使用方。 | 633 634**错误码:** 635 636| 错误码ID | 错误信息 | 637| -------- | -------- | 638| 202 | If the application is not a system application. | 639| 16500050 | An IPC connection error happened. | 640| 16501000 | An internal functional error occurred. | 641 642以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。 643 644**示例:** 645 646```ts 647import Want from '@ohos.app.ability.Want'; 648import Base from '@ohos.base'; 649 650try { 651 formProvider.isRequestPublishFormSupported().then((isSupported: boolean) => { 652 if (isSupported) { 653 let want: Want = { 654 abilityName: 'FormAbility', 655 parameters: { 656 'ohos.extra.param.key.form_dimension': 2, 657 'ohos.extra.param.key.form_name': 'widget', 658 'ohos.extra.param.key.module_name': 'entry' 659 } 660 }; 661 try { 662 formProvider.requestPublishForm(want).then((data: string) => { 663 console.log(`formProvider requestPublishForm success, form ID is : ${JSON.stringify(data)}`); 664 }).catch((error: Base.BusinessError) => { 665 console.error(`promise error, code: ${error.code}, message: ${error.message})`); 666 }); 667 } catch (error) { 668 console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`); 669 } 670 } 671 }).catch((error: Base.BusinessError) => { 672 console.error(`promise error, code: ${error.code}, message: ${error.message})`); 673 }); 674} catch (error) { 675 console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`); 676} 677```