diff --git a/zh-cn/application-dev/reference/apis/Readme-CN.md b/zh-cn/application-dev/reference/apis/Readme-CN.md index f312bde9d48259e6ad7209bd995a1ce2d2c0b0d7..450bd621b31079bb3267ba9b4b624d6379ae428f 100755 --- a/zh-cn/application-dev/reference/apis/Readme-CN.md +++ b/zh-cn/application-dev/reference/apis/Readme-CN.md @@ -18,7 +18,7 @@ - [@ohos.application.abilityLifecycleCallback (AbilityLifecycleCallback)](js-apis-application-abilityLifecycleCallback.md) - [@ohos.application.DataShareExtensionAbility (数据共享扩展能力)](js-apis-application-DataShareExtensionAbility.md) - [@ohos.application.EnvironmentCallback (EnvironmentCallback)](js-apis-application-EnvironmentCallback.md) - - [@ohos.application.FormExtension (FormExtension)](js-apis-formextension.md) + - [@ohos.app.form.FormExtensionAbility.d.ts](FormExtensionAbility)(js-apis-app-form-formextensionability.md) - [@ohos.application.ServiceExtensionAbility (ServiceExtensionAbility)](js-apis-service-extension-ability.md) - [@ohos.application.StartOptions (StartOptions)](js-apis-application-StartOptions.md) - [@ohos.application.StaticSubscriberExtensionAbility (StaticSubscriberExtensionAbility)](js-apis-application-staticSubscriberExtensionAbility.md) @@ -43,11 +43,11 @@ - [@ohos.application.Configuration (Configuration)](js-apis-application-configuration.md) - [@ohos.application.ConfigurationConstant (ConfigurationConstant)](js-apis-application-configurationConstant.md) - [@ohos.application.errorManager (ErrorManager)](js-apis-errorManager.md) - - [@ohos.application.formBindingData (卡片数据绑定类)](js-apis-formbindingdata.md) + - [@oho.app.form.formBindingData (卡片数据绑定类)](js-apis-app-form-formbindingdata.md) - [@ohos.application.formError (FormError)](js-apis-formerror.md) - - [@ohos.application.formHost (FormHost)](js-apis-formhost.md) - - [@ohos.application.formInfo (FormInfo)](js-apis-formInfo.md) - - [@ohos.application.formProvider (FormProvider)](js-apis-formprovider.md) + - [@ohos.app.form.formHost (FormHost)](js-apis-app-form-formhost.md) + - [@ohos.app.form.formProvider (FormProvider)](js-apis-app-form-formprovider.md) + - [@ohos.app.form.formInfo (FormInfo)](js-apis-app-form-forminfo.md) - [@ohos.application.missionManager (missionManager)](js-apis-missionManager.md) - [@ohos.application.quickFixManager (quickFixManager)](js-apis-application-quickFixManager.md) - [@ohos.application.Want (Want)](js-apis-application-Want.md) @@ -297,6 +297,11 @@ - [@ohos.uitest (UiTest)](js-apis-uitest.md) - 已停止维护的接口 + - [@ohos.application.FormExtension (FormExtension)](js-apis-formextension.md) + - [@ohos.application.formHost (FormHost)](js-apis-formhost.md) + - [@ohos.application.formProvider (FormProvider)](js-apis-formprovider.md) + - [@ohos.application.formInfo (FormInfo)](js-apis-formInfo.md) + - [@ohos.application.formBindingData (卡片数据绑定类)](js-apis-formbindingdata.md) - [@ohos.backgroundTaskManager (后台任务管理)](js-apis-backgroundTaskManager.md) - [@ohos.bundle (Bundle模块)](js-apis-Bundle.md) - [@ohos.bundle.innerBundleManager (innerBundleManager模块)](js-apis-Bundle-InnerBundleManager.md) diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-form-formbindingdata.md b/zh-cn/application-dev/reference/apis/js-apis-app-form-formbindingdata.md new file mode 100644 index 0000000000000000000000000000000000000000..f6e4870156599246ca4c859aa9e69623a11d1798 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-app-form-formbindingdata.md @@ -0,0 +1,67 @@ +# 卡片数据绑定类 + +卡片数据绑定模块提供卡片数据绑定的能力。包括FormBindingData对象的创建、相关信息的描述。 + +> **说明:** +> +> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + +## 导入模块 + +``` +import formBindingData from '@ohos.app.form.formBindingData'; +``` + +## FormBindingData + +FormBindingData相关描述。 + +**系统能力**:SystemCapability.Ability.Form + +| 名称 | 可读 | 可写 | 参数类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | -------- | -------- | +| data | 是 | 否 | Object | 是 | js卡片要展示的数据。可以是包含若干键值对的Object或者 json 格式的字符串。| + + +## createFormBindingData + +createFormBindingData(obj?: Object | string): FormBindingData + +创建一个FormBindingData对象。 + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | -------------- | ---- | ------------------------------------------------------------ | +| obj | Object或string | 否 | js卡片要展示的数据。可以是包含若干键值对的Object或者 json 格式的字符串。其中图片数据以"formImages"作为标识,内容为图片标识与图片文件描述符的键值对{"formImages": {"key1": fd1, "key2": fd2}} | + + +**返回值:** + +| 类型 | 说明 | +| ----------------------------------- | --------------------------------------- | +| [FormBindingData](#formbindingdata) | 根据传入数据创建的FormBindingData对象。 | + + +**示例:** + +```js +import featureAbility from '@ohos.ability.featureAbility'; +import fileio from '@ohos.fileio'; +let context=featureAbility.getContext(); +context.getOrCreateLocalDir((err,data)=>{ + let path=data+"/xxx.jpg"; + let fd = fileio.openSync(path); + let obj = { + "temperature": "21°", + "formImages": {"image": fd} + }; + try { + formBindingData.createFormBindingData(obj); + } catch (error) { + console.log(`catch err->${JSON.stringify(err)}`); + } +}) +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-form-formextensionability.md b/zh-cn/application-dev/reference/apis/js-apis-app-form-formextensionability.md new file mode 100644 index 0000000000000000000000000000000000000000..a02593062faa0edc0bde3809ca91f2b172ad93c0 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-app-form-formextensionability.md @@ -0,0 +1,283 @@ +# FormExtensionAbility + +FormExtensionAbility模块提供了卡片扩展相关接口。 + +> **说明:** +> +> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> 本模块接口仅可在Stage模型下使用。 + +## 导入模块 + +``` +import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility'; +``` + +## 属性 + +**系统能力**:SystemCapability.Ability.Form + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ------- | ------------------------------------------------------- | ---- | ---- | --------------------------------------------------- | +| context | [FormExtensionContext](js-apis-formextensioncontext.md) | 是 | 否 | FormExtensionAbility的上下文环境,继承自ExtensionContext。 | + +## onAddForm + +onAddForm(want: Want): formBindingData.FormBindingData + +卡片提供方接收创建卡片的通知接口。 + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | -------------------------------------- | ---- | ------------------------------------------------------------ | +| want | [Want](js-apis-application-Want.md) | 是 | 当前ExtensionAbility相关的Want类型信息,包括卡片ID、卡片名称、卡片样式等。这些卡片信息必须作为持久数据进行管理,以便后续更新和删除卡片。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------------------------------------------------ | ----------------------------------------------------------- | +| [formBindingData.FormBindingData](js-apis-app-form-formbindingdata.md#formbindingdata) | formBindingData.FormBindingData对象,卡片要显示的数据。 | + +**示例:** + +```js +import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility'; +export default class MyFormExtensionAbility extends FormExtensionAbility { + onAddForm(want) { + console.log('FormExtensionAbility onAddForm, want:' + want.abilityName); + let dataObj1 = { + temperature:"11c", + "time":"11:00" + }; + let obj1 = formBindingData.createFormBindingData(dataObj1); + return obj1; + } +} +``` + +## onCastToNormalForm + +onCastToNormalForm(formId: string): void + +卡片提供方接收临时卡片转常态卡片的通知接口。 + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------------ | +| formId | string | 是 | 请求转换为常态的卡片标识。 | + +**示例:** + +```js +export default class MyFormExtensionAbility extends FormExtensionAbility { + onCastToNormalForm(formId) { + console.log('FormExtensionAbility onCastToNormalForm, formId:' + formId); + } +} +``` + +## onUpdateForm + +onUpdateForm(formId: string): void + +卡片提供方接收更新卡片的通知接口。获取最新数据后调用[FormExtensionContext](js-apis-formextensioncontext.md)的updateForm接口刷新卡片数据。 + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------ | +| formId | string | 是 | 请求更新的卡片ID。 | + +**示例:** + +```js +import formBindingData from '@ohos.app.form.formBindingData' +export default class MyFormExtensionAbility extends FormExtensionAbility { + onUpdateForm(formId) { + console.log('FormExtensionAbility onUpdateForm, formId:' + formId); + let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); + this.context.updateForm(formId, obj2).then((data)=>{ + console.log('FormExtensionAbility context updateForm, data:' + data); + }).catch((error) => { + console.error('Operation updateForm failed. Cause: ' + error);}); + } +} +``` + +## onChangeFormVisibility + +onChangeFormVisibility(newStatus: { [key: string]: number }): void + +卡片提供方接收修改可见性的通知接口。 + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------------------------- | ---- | ---------------------------- | +| newStatus | { [key: string]: number } | 是 | 请求修改的卡片标识和可见状态。 | + +**示例:** + +```js +import formBindingData from '@ohos.app.form.formBindingData' +export default class MyFormExtensionAbility extends FormExtensionAbility { + onChangeFormVisibility(newStatus) { + console.log('FormExtensionAbility onChangeFormVisibility, newStatus:' + newStatus); + let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); + + for (let key in newStatus) { + console.log('FormExtensionAbility onChangeFormVisibility, key:' + key + ", value=" + newStatus[key]); + this.context.updateForm(key, obj2).then((data)=>{ + console.log('FormExtensionAbility context updateForm, data:' + data); + }).catch((error) => { + console.error('Operation updateForm failed. Cause: ' + error);}); + } + } +} +``` + +## onFormEvent + +onFormEvent(formId: string, message: string): void + +卡片提供方接收处理卡片事件的通知接口。 + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | ---------------------- | +| formId | string | 是 | 请求触发事件的卡片标识。 | +| message | string | 是 | 事件消息。 | + +**示例:** + +```js +export default class MyFormExtension extends FormExtensionAbility { + onFormEvent(formId, message) { + console.log('FormExtensionAbility onFormEvent, formId:' + formId + ", message:" + message); + } +} +``` + +## onRemoveForm + +onRemoveForm(formId: string): void + +卡片提供方接收销毁卡片的通知接口。 + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------ | +| formId | string | 是 | 请求销毁的卡片标识。 | + +**示例:** + +```js +export default class MyFormExtensionAbility extends FormExtensionAbility { + onRemoveForm(formId) { + console.log('FormExtensionAbility onRemoveForm, formId:' + formId); + } +} +``` + +## onConfigurationUpdate + +onConfigurationUpdate(config: Configuration): void; + +当系统配置更新时调用。 + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| config | [Configuration](js-apis-configuration.md) | 是 | 表示需要更新的配置信息。 | + +**示例:** + +```js +class MyFormExtensionAbility extends FormExtensionAbility { + onConfigurationUpdate(config) { + console.log('onConfigurationUpdate, config:' + JSON.stringify(config)); + } +} +``` + +## onAcquireFormState + +onAcquireFormState?(want: Want): formInfo.FormState; + +卡片提供方接收查询卡片状态通知接口。默认返回卡片初始状态。 + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | 否 | want表示获取卡片状态的描述。描述包括包名称、能力名称、模块名称、卡片名和卡片维度。 | + +**示例:** + +```js +import formInfo from '@ohos.app.form.formInfo'; +class MyFormExtensionAbility extends FormExtensionAbility { + onAcquireFormState(want) { + console.log('FormExtensionAbility onAcquireFormState, want:' + want); + return formInfo.FormState.UNKNOWN; + } +} +``` + +## onShareForm + +onShareForm?(formId: string): { [key: string]: any } + +卡片提供方接收卡片分享的通知接口。 + +**系统接口**: 此接口为系统接口。 + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| formId | string | 是 | 卡片标识。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------------------------------------------------ | ----------------------------------------------------------- | +| {[key: string]: any} | 卡片要分享的数据,由开发者自行决定传入的键值对。 | + +**示例:** + +```js +class MyFormExtensionAbility extends FormExtensionAbility { + onShareForm(formId) { + console.log('FormExtensionAbility onShareForm, formId:' + formId); + let wantParams = { + "temperature":"20", + "time":"2022-8-8 09:59", + }; + return wantParams; + } +} +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-form-formhost.md b/zh-cn/application-dev/reference/apis/js-apis-app-form-formhost.md new file mode 100644 index 0000000000000000000000000000000000000000..a47a3dcfb98c1bc4996bf4df835509d1db2f212b --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-app-form-formhost.md @@ -0,0 +1,1491 @@ +# FormHost + +FormHost模块提供了卡片使用方相关接口的能力,包括对使用方同一用户下安装的卡片进行删除、释放、请求更新、获取卡片信息、状态等操作。 + +> **说明:** +> +> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> 本模块接口均为系统接口。 + +## 导入模块 + +``` +import formHost from '@ohos.app.form.formHost'; +``` + +## deleteForm + +deleteForm(formId: string, callback: AsyncCallback<void>): void + +删除指定的卡片。调用此方法后,应用程序将无法使用该卡片,卡片管理器服务不再保留有关该卡片的信息。使用callback异步回调。 + +**需要权限**:ohos.permission.REQUIRE_FORM + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formId | string | 是 | 卡片标识。 | +| callback | AsyncCallback<void> | 是 | 回调函数。当删除指定的卡片成功,error为undefined,否则为错误对象 | + +**错误码:** + +以下错误码的详细介绍请参见[卡片错误码](../errorcodes/errcode-form.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 16501001 | The ID of the form to be operated does not exist. | +| 16501003 | The form can not be operated by the current application. | + +**示例:** + +```js +try { + var formId = "12400633174999288"; + formHost.deleteForm(formId, (error, data) => { + if (error) { + console.log('formHost deleteForm, error:' + JSON.stringify(error)); + } else { + console.log('formHost deleteForm success'); + } + }); +} catch (error) { + console.log(`catch err->${JSON.stringify(error)}`); +} + +``` + +## deleteForm + +deleteForm(formId: string): Promise<void> + +删除指定的卡片。调用此方法后,应用程序将无法使用该卡片,卡片管理器服务不再保留有关该卡片的信息。使用Promise异步回调。 + +**需要权限**:ohos.permission.REQUIRE_FORM + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formId | string | 是 | 卡片标识。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| Promise<void> | 无返回结果的Promise对象。 | + + +**错误码:** + +以下错误码的详细介绍请参见[卡片错误码](../errorcodes/errcode-form.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 16501001 | The ID of the form to be operated does not exist. | +| 16501003 | The form can not be operated by the current application. | + +**参数:** + +```js +try { + var formId = "12400633174999288"; + formHost.deleteForm(formId).then(() => { + console.log('formHost deleteForm success'); + }).catch((error) => { + console.log('formHost deleteForm, error:' + JSON.stringify(error)); + }); +} catch(error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` + +## releaseForm + +releaseForm(formId: string, callback: AsyncCallback<void>): void + +释放指定的卡片。调用此方法后,应用程序将无法使用该卡片,但卡片管理器服务仍然保留有关该卡片的缓存信息和存储信息。使用callback异步回调。 + +**需要权限**:ohos.permission.REQUIRE_FORM + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formId | string | 是 | 卡片标识。 | +| callback | AsyncCallback<void> | 是 | 回调函数。当释放指定的卡片成功,error为undefined;否则为错误对象。| + +**错误码:** + +以下错误码的详细介绍请参见[卡片错误码](../errorcodes/errcode-form.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 16501001 | The ID of the form to be operated does not exist. | +| 16501003 | The form can not be operated by the current application. | + +**示例:** + +```js +try { + var formId = "12400633174999288"; + formHost.releaseForm(formId, (error, data) => { + if (error) { + console.log('formHost releaseForm, error:' + JSON.stringify(error)); + } + }); +} catch(error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` + +## releaseForm + +releaseForm(formId: string, isReleaseCache: boolean, callback: AsyncCallback<void>): void + +释放指定的卡片。调用此方法后,应用程序将无法使用该卡片,卡片管理器服务保留有关该卡片的存储信息,可以选择是否保留缓存信息。使用callback异步回调。 + +**需要权限**:ohos.permission.REQUIRE_FORM + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ------ | ---- | ----------- | +| formId | string | 是 | 卡片标识。 | +| isReleaseCache | boolean | 是 | 是否释放缓存。 | +| callback | AsyncCallback<void> | 是 | 回调函数。当释放指定的卡片成功,error为undefined;否则为错误对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[卡片错误码](../errorcodes/errcode-form.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 16501001 | The ID of the form to be operated does not exist. | +| 16501003 | The form can not be operated by the current application. | + +**示例:** + +```js +try { + var formId = "12400633174999288"; + formHost.releaseForm(formId, true, (error, data) => { + if (error) { + console.log('formHost releaseForm, error:' + JSON.stringify(error)); + } + }); +} catch(error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` + +## releaseForm + +releaseForm(formId: string, isReleaseCache?: boolean): Promise<void> + +释放指定的卡片。调用此方法后,应用程序将无法使用该卡片,卡片管理器服务保留有关该卡片的存储信息,可以选择是否保留缓存信息。使用Promise异步回调。 + +**需要权限**:ohos.permission.REQUIRE_FORM + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ------ | ---- | ----------- | +| formId | string | 是 | 卡片标识。 | +| isReleaseCache | boolean | 否 | 是否释放缓存。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| Promise<void> | 无返回结果的Promise对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[卡片错误码](../errorcodes/errcode-form.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 16501001 | The ID of the form to be operated does not exist. | +| 16501003 | The form can not be operated by the current application. | + +**示例:** + +```js +try { + var formId = "12400633174999288"; + formHost.releaseForm(formId, true).then(() => { + console.log('formHost releaseForm success'); + }).catch((error) => { + console.log('formHost releaseForm, error:' + JSON.stringify(error)); + }); +} catch(error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` + +## requestForm + +requestForm(formId: string, callback: AsyncCallback<void>): void + +请求卡片更新。使用callback异步回调。 + +**需要权限**:ohos.permission.REQUIRE_FORM + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formId | string | 是 | 卡片标识。 | +| callback | AsyncCallback<void> | 是 | 回调函数。当请求卡片更新成功,error为undefined;否则为错误对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[卡片错误码](../errorcodes/errcode-form.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 16501001 | The ID of the form to be operated does not exist. | +| 16501003 | The form can not be operated by the current application. | + +**示例:** + +```js +try { + var formId = "12400633174999288"; + formHost.requestForm(formId, (error, data) => { + if (error) { + console.log('formHost requestForm, error:' + JSON.stringify(error)); + } + }); +} catch(error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` + +## requestForm + +requestForm(formId: string): Promise<void> + +请求卡片更新。使用Promise异步回调。 + +**需要权限**:ohos.permission.REQUIRE_FORM + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formId | string | 是 | 卡片标识。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| Promise<void> | 无返回结果的Promise对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[卡片错误码](../errorcodes/errcode-form.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 16501001 | The ID of the form to be operated does not exist. | +| 16501003 | The form can not be operated by the current application. | + +**示例:** + +```js +try { + var formId = "12400633174999288"; + formHost.requestForm(formId).then(() => { + console.log('formHost requestForm success'); + }).catch((error) => { + console.log('formHost requestForm, error:' + JSON.stringify(error)); + }); +} catch(error) { + console.log(`catch err->${JSON.stringify(error)}`); +} + +``` + +## castTempForm + +castTempForm(formId: string, callback: AsyncCallback<void>): void + +将指定的临时卡片转换为普通卡片。使用callback异步回调。 + +**需要权限**:ohos.permission.REQUIRE_FORM + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formId | string | 是 | 卡片标识。 | +| callback | AsyncCallback<void> | 是 | 回调函数。当将指定的临时卡片转换为普通卡片成功,err为undefined,否则为错误对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[卡片错误码](../errorcodes/errcode-form.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 16501001 | The ID of the form to be operated does not exist. | +| 16501003 | The form can not be operated by the current application. | + +**示例:** + +```js +try { + var formId = "12400633174999288"; + formHost.castTempForm(formId, (error, data) => { + if (error) { + console.log('formHost castTempForm, error:' + JSON.stringify(error)); + } + }); +} catch(error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` + +## castTempForm + +castTempForm(formId: string): Promise<void> + +将指定的临时卡片转换为普通卡片。使用Promise异步回调。 + +**需要权限**:ohos.permission.REQUIRE_FORM + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formId | string | 是 | 卡片标识。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| Promise<void> | 无返回结果的Promise对象。| + +**错误码:** + +以下错误码的详细介绍请参见[卡片错误码](../errorcodes/errcode-form.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 16501001 | The ID of the form to be operated does not exist. | +| 16501003 | The form can not be operated by the current application. | + +**示例:** + +```js +try { + var formId = "12400633174999288"; + formHost.castTempForm(formId).then(() => { + console.log('formHost castTempForm success'); + }).catch((error) => { + console.log('formHost castTempForm, error:' + JSON.stringify(error)); + }); +} catch(error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` + +## notifyVisibleForms + +notifyVisibleForms(formIds: Array<string>, callback: AsyncCallback<void>): void + +向卡片框架发送通知以使指定的卡片可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。使用callback异步回调。 + +**需要权限**:ohos.permission.REQUIRE_FORM + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formIds | Array<string> | 是 | 卡片标识列表。 | +| callback | AsyncCallback<void> | 是 | 回调函数。当向卡片框架发送通知以使指定的卡片可见成功,err为undefined,否则为错误对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[卡片错误码](../errorcodes/errcode-form.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 16501000 | A functional error occurred. | + +**示例:** + +```js +try { + var formId = ["12400633174999288"]; + formHost.notifyVisibleForms(formId, (error, data) => { + if (error) { + console.log('formHost notifyVisibleForms, error:' + JSON.stringify(error)); + } + }); +} catch(error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` + +## notifyVisibleForms + +notifyVisibleForms(formIds: Array<string>): Promise<void> + +向卡片框架发送通知以使指定的卡片可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。使用Promise异步回调。 + +**需要权限**:ohos.permission.REQUIRE_FORM + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formIds | Array<string> | 是 | 卡片标识列表。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| Promise<void> | 无返回结果的Promise对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[卡片错误码](../errorcodes/errcode-form.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 16501000 | A functional error occurred. | + +**示例:** + +```js +try { + var formId = ["12400633174999288"]; + formHost.notifyVisibleForms(formId).then(() => { + console.log('formHost notifyVisibleForms success'); + }).catch((error) => { + console.log('formHost notifyVisibleForms, error:' + JSON.stringify(error)); + }); +} catch(error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` + +## notifyInvisibleForms + +notifyInvisibleForms(formIds: Array<string>, callback: AsyncCallback<void>): void + +向卡片框架发送通知以使指定的卡片不可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。使用callback异步回调。 + +**需要权限**:ohos.permission.REQUIRE_FORM + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formIds | Array<string> | 是 | 卡片标识列表。| +| callback | AsyncCallback<void> | 是 | 回调函数。当向卡片框架发送通知以使指定的卡片不可见成功,err为undefined,否则为错误对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[卡片错误码](../errorcodes/errcode-form.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 16501000 | A functional error occurred. | + +**示例:** + +```js +try { + var formId = ["12400633174999288"]; + formHost.notifyInvisibleForms(formId, (error, data) => { + if (error) { + console.log('formHost notifyInvisibleForms, error:' + JSON.stringify(error)); + } + }); +} catch(error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` + +## notifyInvisibleForms + +notifyInvisibleForms(formIds: Array<string>): Promise<void> + +向卡片框架发送通知以使指定的卡片不可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。使用Promise异步回调。 + +**需要权限**:ohos.permission.REQUIRE_FORM + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formIds | Array<string> | 是 | 卡片标识列表。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| Promise<void> | 无返回结果的Promise对象。| + +**错误码:** + +以下错误码的详细介绍请参见[卡片错误码](../errorcodes/errcode-form.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 16501000 | A functional error occurred. | + +**示例:** + +```js +try { + var formId = ["12400633174999288"]; + formHost.notifyInvisibleForms(formId).then(() => { + console.log('formHost notifyInvisibleForms success'); + }).catch((error) => { + console.log('formHost notifyInvisibleForms, error:' + JSON.stringify(error)); + }); +} catch(error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` + +## enableFormsUpdate + +enableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void>): void + +向卡片框架发送通知以使指定的卡片可以更新。该方法调用成功后,卡片刷新状态设置为使能,卡片可以接收来自卡片提供方的更新。使用callback异步回调。 + +**需要权限**:ohos.permission.REQUIRE_FORM + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formIds | Array<string> | 是 | 卡片标识列表。 | +| callback | AsyncCallback<void> | 是 | 回调函数。当向卡片框架发送通知以使指定的卡片可以更新成功,err为undefined,否则为错误对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[卡片错误码](../errorcodes/errcode-form.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 16501000 | A functional error occurred. | +| 16501003 | The form can not be operated by the current application. | + +**示例:** + +```js +try { + var formId = ["12400633174999288"]; + formHost.enableFormsUpdate(formId, (error, data) => { + if (error) { + console.log('formHost enableFormsUpdate, error:' + JSON.stringify(error)); + } + }); +} catch(error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` + +## enableFormsUpdate + +enableFormsUpdate(formIds: Array<string>): Promise<void> + +向卡片框架发送通知以使指定的卡片可以更新。该方法调用成功后,卡片刷新状态设置为使能,卡片可以接收来自卡片提供方的更新。使用Promise异步回调。 + +**需要权限**:ohos.permission.REQUIRE_FORM + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formIds | Array<string> | 是 | 卡片标识列表。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| Promise<void> | 无返回结果的Promise对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[卡片错误码](../errorcodes/errcode-form.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 16501000 | A functional error occurred. | +| 16501003 | The form can not be operated by the current application. | + +**示例:** + +```js +try { + var formId = ["12400633174999288"]; + formHost.enableFormsUpdate(formId).then(() => { + console.log('formHost enableFormsUpdate success'); + }).catch((error) => { + console.log('formHost enableFormsUpdate, error:' + JSON.stringify(error)); + }); +} catch(error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` + +## disableFormsUpdate + +disableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void>): void + +向卡片框架发送通知以使指定的卡片不可以更新。该方法调用成功后,卡片刷新状态设置为去使能,卡片不可以接收来自卡片提供方的更新。使用callback异步回调。 + +**需要权限**:ohos.permission.REQUIRE_FORM + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formIds | Array<string> | 是 | 卡片标识列表。 | +| callback | AsyncCallback<void> | 是 | 回调函数。当向卡片框架发送通知以使指定的卡片不可以更新成功,err为undefined,否则为错误对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[卡片错误码](../errorcodes/errcode-form.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 16501000 | A functional error occurred. | +| 16501003 | The form can not be operated by the current application. | + +**示例:** + +```js +try { + var formId = ["12400633174999288"]; + formHost.disableFormsUpdate(formId, (error, data) => { + if (error) { + console.log('formHost disableFormsUpdate, error:' + JSON.stringify(error)); + } + }); +} catch(error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` + +## disableFormsUpdate + +disableFormsUpdate(formIds: Array<string>): Promise<void> + +向卡片框架发送通知以使指定的卡片不可以更新。该方法调用成功后,卡片刷新状态设置为去使能,卡片不可以接收来自卡片提供方的更新。使用Promise异步回调。 + +**需要权限**:ohos.permission.REQUIRE_FORM + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formIds | Array<string> | 是 | 卡片标识列表。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| Promise<void> | 无返回结果的Promise对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[卡片错误码](../errorcodes/errcode-form.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 16501000 | A functional error occurred. | +| 16501003 | The form can not be operated by the current application. | + +**示例:** + +```js +try { + var formId = ["12400633174999288"]; + formHost.disableFormsUpdate(formId).then(() => { + console.log('formHost disableFormsUpdate success'); + }).catch((error) => { + console.log('formHost disableFormsUpdate, error:' + JSON.stringify(error)); + }); +} catch(error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` + +## isSystemReady + +isSystemReady(callback: AsyncCallback<void>): void + +检查系统是否准备好。使用callback异步回调。 + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| callback | AsyncCallback<void> | 是 | 回调函数。当检查系统是否准备好成功,err为undefined,否则为错误对象。 | + +**示例:** + +```js +try { + var formId = "12400633174999288"; + formHost.isSystemReady((error, data) => { + if (error) { + console.log('formHost isSystemReady, error:' + JSON.stringify(error)); + } + }); +} catch(error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` + +## isSystemReady + +isSystemReady(): Promise<void> + +检查系统是否准备好。使用Promise异步回调。 + +**系统能力**:SystemCapability.Ability.Form + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| Promise<void> | 无返回结果的Promise对象。 | + +**示例:** + +```js +try { + var formId = "12400633174999288"; + formHost.isSystemReady().then(() => { + console.log('formHost isSystemReady success'); + }).catch((error) => { + console.log('formHost isSystemReady, error:' + JSON.stringify(error)); + }); +} catch(error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` + +## getAllFormsInfo + +getAllFormsInfo(callback: AsyncCallback<Array<formInfo.FormInfo>>): void + +获取设备上所有应用提供的卡片信息。使用callback异步回调。 + +**需要权限**:ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| callback | AsyncCallback<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | 是 | 回调函数。当获取设备上所有应用提供的卡片信息成功,err为undefined,data为查询到的卡片信息;否则为错误对象。 | + +**示例:** + +```js +try { + formHost.getAllFormsInfo((error, data) => { + if (error) { + console.log('formHost getAllFormsInfo, error:' + JSON.stringify(error)); + } else { + console.log('formHost getAllFormsInfo, data:' + JSON.stringify(data)); + } + }); +} catch(error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` + +## getAllFormsInfo + +getAllFormsInfo(): Promise<Array<formInfo.FormInfo>> + +获取设备上所有应用提供的卡片信息。使用Promise异步回调。 + +**需要权限**:ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**系统能力**:SystemCapability.Ability.Form + +**返回值:** + +| 类型 | 说明 | +| :------------ | :---------------------------------- | +| Promise<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | Promise对象,返回查询到的卡片信息。 | + +**示例:** + +```js +try { + formHost.getAllFormsInfo().then((data) => { + console.log('formHost getAllFormsInfo data:' + JSON.stringify(data)); + }).catch((error) => { + console.log('formHost getAllFormsInfo, error:' + JSON.stringify(error)); + }); +} catch(error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` + +## getFormsInfo + +getFormsInfo(bundleName: string, callback: AsyncCallback<Array<formInfo.FormInfo>>): void + +获取设备上指定应用程序提供的卡片信息。使用callback异步回调。 + +**需要权限**:ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| bundleName | string | 是 | 要查询的应用程序包名称。 | +| callback | AsyncCallback<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | 是 | 回调函数。当获取设备上指定应用程序提供的卡片信息成功,err为undefined,data为查询到的卡片信息;否则为错误对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[卡片错误码](../errorcodes/errcode-form.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 16500100 | Failed to obtain configuration information. | + +**示例:** + +```js +try { + formHost.getFormsInfo("com.example.ohos.formjsdemo", (error, data) => { + if (error) { + console.log('formHost getFormsInfo, error:' + JSON.stringify(error)); + } else { + console.log('formHost getFormsInfo, data:' + JSON.stringify(data)); + } + }); +} catch(error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` + +## getFormsInfo + +getFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback<Array<formInfo.FormInfo>>): void + +获取设备上指定应用程序提供的卡片信息。使用callback异步回调。 + +**需要权限**:ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| bundleName | string | 是 | 要查询的应用程序包名称。 | +| moduleName | string | 是 | 要查询的模块名称。 | +| callback | AsyncCallback<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | 是 | 回调函数。当获取设备上指定应用程序提供的卡片信息成功,err为undefined,data为查询到的卡片信息;否则为错误对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[卡片错误码](../errorcodes/errcode-form.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 16500100 | Failed to obtain configuration information. | + +**示例:** + +```js +try { + formHost.getFormsInfo("com.example.ohos.formjsdemo", "entry", (error, data) => { + if (error) { + console.log('formHost getFormsInfo, error:' + JSON.stringify(error)); + } else { + console.log('formHost getFormsInfo, data:' + JSON.stringify(data)); + } + }); +} catch(error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` + +## getFormsInfo + +getFormsInfo(bundleName: string, moduleName?: string): Promise<Array<formInfo.FormInfo>> + +获取设备上指定应用程序提供的卡片信息。使用Promise异步回调。 + +**需要权限**:ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| bundleName | string | 是 | 要查询的应用程序包名称。 | +| moduleName | string | 否 | 要查询的模块名称。 | + +**返回值:** + +| 类型 | 说明 | +| :------------ | :---------------------------------- | +| Promise<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | Promise对象,返回查询到的卡片信息。 | + +**错误码:** + +以下错误码的详细介绍请参见[卡片错误码](../errorcodes/errcode-form.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 16500100 | Failed to obtain configuration information. | + +**示例:** + +```js +try { + formHost.getFormsInfo("com.example.ohos.formjsdemo", "entry").then((data) => { + console.log('formHost getFormsInfo, data:' + JSON.stringify(data)); + }).catch((error) => { + console.log('formHost getFormsInfo, error:' + JSON.stringify(error)); + }); +} catch(error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` + +## deleteInvalidForms + +deleteInvalidForms(formIds: Array<string>, callback: AsyncCallback<number>): void + +根据列表删除应用程序的无效卡片。使用callback异步回调。 + +**需要权限**:ohos.permission.REQUIRE_FORM + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formIds | Array<string> | 是 | 有效卡片标识列表。 | +| callback | AsyncCallback<number> | 是 | 回调函数。当根据列表删除应用程序的无效卡片成功,err为undefined,data为删除的卡片个数;否则为错误对象。 | + +**示例:** + +```js +try { + var formIds = new Array("12400633174999288", "12400633174999289"); + formHost.deleteInvalidForms(formIds, (error, data) => { + if (error) { + console.log('formHost deleteInvalidForms, error:' + JSON.stringify(error)); + } else { + console.log('formHost deleteInvalidForms, data:' + JSON.stringify(data)); + } + }); +} catch(error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` + +## deleteInvalidForms + +deleteInvalidForms(formIds: Array<string>): Promise<number> + +根据列表删除应用程序的无效卡片。使用Promise异步回调。 + +**需要权限**:ohos.permission.REQUIRE_FORM + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formIds | Array<string> | 是 | 有效卡片标识列表。 | + +**返回值:** + +| 类型 | 说明 | +| :------------ | :---------------------------------- | +| Promise<number> | Promise对象,返回删除的卡片个数。 | + +**示例:** + +```js +try { + var formIds = new Array("12400633174999288", "12400633174999289"); + formHost.deleteInvalidForms(formIds).then((data) => { + console.log('formHost deleteInvalidForms, data:' + JSON.stringify(data)); + }).catch((error) => { + console.log('formHost deleteInvalidForms, error:' + JSON.stringify(error)); + }); +} catch(error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` + +## acquireFormState + +acquireFormState(want: Want, callback: AsyncCallback<formInfo.FormStateInfo>): void + +获取卡片状态。使用callback异步回调。 + +**需要权限**:ohos.permission.REQUIRE_FORM 和 ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| want | [Want](js-apis-application-Want.md) | 是 | 查询卡片状态时携带的want信息。 | +| callback | AsyncCallback<[FormStateInfo](js-apis-formInfo.md#formstateinfo)> | 是 | 回调函数。当获取卡片状态成功,err为undefined,data为获取到的卡片状态;否则为错误对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[卡片错误码](../errorcodes/errcode-form.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 16501000 | A functional error occurred. | + +**示例:** + +```js +var want = { + "deviceId": "", + "bundleName": "ohos.samples.FormApplication", + "abilityName": "FormAbility", + "parameters": { + "ohos.extra.param.key.module_name": "entry", + "ohos.extra.param.key.form_name": "widget", + "ohos.extra.param.key.form_dimension": 2 + } +}; +try { + formHost.acquireFormState(want, (error, data) => { + if (error) { + console.log('formHost acquireFormState, error:' + JSON.stringify(error)); + } else { + console.log('formHost acquireFormState, data:' + JSON.stringify(data)); + } + }); +} catch(error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` + +## acquireFormState + +acquireFormState(want: Want): Promise<formInfo.FormStateInfo> + +获取卡片状态。使用Promise异步回调。 + +**需要权限**:ohos.permission.REQUIRE_FORM 和 ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| want | [Want](js-apis-application-Want.md) | 是 | 查询卡片状态时携带的want信息。 | + +**返回值:** + +| 类型 | 说明 | +| :------------ | :---------------------------------- | +| Promise<[FormStateInfo](js-apis-formInfo.md#formstateinfo)> | Promise对象,返回卡片状态。 | + +**错误码:** + +以下错误码的详细介绍请参见[卡片错误码](../errorcodes/errcode-form.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 16501000 | A functional error occurred. | + +**示例:** + +```js +var want = { + "deviceId": "", + "bundleName": "ohos.samples.FormApplication", + "abilityName": "FormAbility", + "parameters": { + "ohos.extra.param.key.module_name": "entry", + "ohos.extra.param.key.form_name": "widget", + "ohos.extra.param.key.form_dimension": 2 + } +}; +try { + formHost.acquireFormState(want).then((data) => { + console.log('formHost acquireFormState, data:' + JSON.stringify(data)); + }).catch((error) => { + console.log('formHost acquireFormState, error:' + JSON.stringify(error)); + }); +} catch(error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` + +## on("formUninstall") + +on(type: "formUninstall", callback: Callback<string>): void + +订阅卡片卸载事件。使用callback异步回调。 + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| type | string | 是 | 填写"formUninstall",表示卡片卸载事件。 | +| callback | Callback<string> | 是 | 回调函数。返回卡片标识。 | + +**示例:** + +```js +let callback = function(formId) { + console.log('formHost on formUninstall, formId:' + formId); +} +formHost.on("formUninstall", callback); +``` + +## off("formUninstall") + +off(type: "formUninstall", callback?: Callback<string>): void + +取消订阅卡片卸载事件。使用callback异步回调。 + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| type | string | 是 | 填写"formUninstall",表示卡片卸载事件。 | +| callback | Callback<string> | 否 | 回调函数。返回卡片标识。缺省时,表示注销所有已注册事件回调。 | + +**示例:** + +```js +let callback = function(formId) { + console.log('formHost on formUninstall, formId:' + formId); +} +formHost.off("formUninstall", callback); +``` + +## notifyFormsVisible + +notifyFormsVisible(formIds: Array<string>, isVisible: boolean, callback: AsyncCallback<void>): void + +通知卡片是否可见。使用callback异步回调。 + +**需要权限**:ohos.permission.REQUIRE_FORM + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formIds | Array<string> | 是 | 卡片标识列表。 | +| isVisible | boolean | 是 | 是否可见。 | +| callback | AsyncCallback<void> | 是 | 回调函数。当通知卡片是否可见成功,err为undefined,否则为错误对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[卡片错误码](../errorcodes/errcode-form.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 16501003 | The form can not be operated by the current application. | + +**示例:** + +```js +var formIds = new Array("12400633174999288", "12400633174999289"); +try { + formHost.notifyFormsVisible(formIds, true, (error, data) => { + if (error) { + console.log('formHost notifyFormsVisible, error:' + JSON.stringify(error)); + } + }); +} catch(error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` + +## notifyFormsVisible + +notifyFormsVisible(formIds: Array<string>, isVisible: boolean): Promise<void> + +通知卡片是否可见。使用Promise异步回调。 + +**需要权限**:ohos.permission.REQUIRE_FORM + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formIds | Array<string> | 是 | 卡片标识列表。 | +| isVisible | boolean | 是 | 是否可见。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| Promise<void> | 无返回结果的Promise对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[卡片错误码](../errorcodes/errcode-form.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 16501003 | The form can not be operated by the current application. | + +**示例:** + +```js +var formIds = new Array("12400633174999288", "12400633174999289"); +try { + formHost.notifyFormsVisible(formIds, true).then(() => { + console.log('formHost notifyFormsVisible success'); + }).catch((error) => { + console.log('formHost notifyFormsVisible, error:' + JSON.stringify(error)); + }); +} catch(error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` + +## notifyFormsEnableUpdate + +notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean, callback: AsyncCallback<void>): void + +通知卡片是否启用更新状态。使用callback异步回调。 + +**需要权限**:ohos.permission.REQUIRE_FORM + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formIds | Array<string> | 是 | 卡片标识列表。 | +| isEnableUpdate | boolean | 是 | 是否使能更新。 | +| callback | AsyncCallback<void> | 是 | 回调函数。当通知卡片是否启用更新状态成功,err为undefined,否则为错误对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[卡片错误码](../errorcodes/errcode-form.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 16501003 | The form can not be operated by the current application. | + +**示例:** + +```js +var formIds = new Array("12400633174999288", "12400633174999289"); +try { + formHost.notifyFormsEnableUpdate(formIds, true, (error, data) => { + if (error) { + console.log('formHost notifyFormsEnableUpdate, error:' + JSON.stringify(error)); + } + }); +} catch(error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` + +## notifyFormsEnableUpdate + +notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean): Promise<void> + +通知卡片是否启用更新状态。使用Promise异步回调。 + +**需要权限**:ohos.permission.REQUIRE_FORM + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formIds | Array<string> | 是 | 卡片标识列表。 | +| isEnableUpdate | boolean | 是 | 是否使能更新。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| Promise<void> | 无返回结果的Promise对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[卡片错误码](../errorcodes/errcode-form.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 16501003 | The form can not be operated by the current application. | + +**示例:** + +```js +var formIds = new Array("12400633174999288", "12400633174999289"); +try { + formHost.notifyFormsEnableUpdate(formIds, true).then(() => { + console.log('formHost notifyFormsEnableUpdate success'); + }).catch((error) => { + console.log('formHost notifyFormsEnableUpdate, error:' + JSON.stringify(error)); + }); +} catch(error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` +## shareForm + +shareForm(formId: string, deviceId: string, callback: AsyncCallback<void>): void + +指定formId和远程设备Id进行卡片分享。使用callback异步回调。 + +**需要权限**:ohos.permission.REQUIRE_FORM + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formId | string | 是 | 卡片标识。 | +| deviceId | string | 是 | 远程设备标识。 | +| callback | AsyncCallback<void> | 是 | 回调函数。当指定formId和远程设备Id进行卡片分享成功,err为undefined,否则为错误对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[卡片错误码](../errorcodes/errcode-form.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 16500100 | Failed to obtain configuration information. | +| 16501000 | A functional error occurred. | + + +**示例:** + +```js +var formId = "12400633174999288"; +var deviceId = "EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2"; +try { + formHost.shareForm(formId, deviceId, (error, data) => { + if (error) { + console.log('formHost shareForm, error:' + JSON.stringify(error)); + } + }); +} catch(error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` + +## shareForm + +shareForm(formId: string, deviceId: string): Promise<void> + +指定formId和远程设备Id进行卡片分享。使用Promise异步回调。 + +**需要权限**:ohos.permission.REQUIRE_FORM + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formId | string | 是 | 卡片标识。 | +| deviceId | string | 是 | 远程设备标识。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| Promise<void> | 无返回结果的Promise对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[卡片错误码](../errorcodes/errcode-form.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 16500100 | Failed to obtain configuration information. | +| 16501000 | A functional error occurred. | + +**参数:** + +```js +var formId = "12400633174999288"; +var deviceId = "EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2"; +try { + formHost.shareForm(formId, deviceId).then(() => { + console.log('formHost shareForm success'); + }).catch((error) => { + console.log('formHost shareForm, error:' + JSON.stringify(error)); + }); +} catch(error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` + +## notifyFormsPrivacyProtected + +notifyFormsPrivacyProtected(formIds: Array, isProtected: boolean, callback: AsyncCallback): void + +**需要权限**:ohos.permission.REQUIRE_FORM + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formId | string | 是 | 卡片标识。 | +| deviceId | string | 是 | 远程设备标识。 | + +```js +var formIds = new Array("12400633174999288", "12400633174999289"); +try { + formHost.notifyFormsPrivacyProtected(formIds, true).then(() => { + console.log('formHost shareForm success'); + }).catch((error) => { + console.log('formHost shareForm, error:' + JSON.stringify(error)); + }); +} catch(error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-form-forminfo.md b/zh-cn/application-dev/reference/apis/js-apis-app-form-forminfo.md new file mode 100644 index 0000000000000000000000000000000000000000..3eeda5931dc0d081bf6d1ef2d2f4bb6d77040fbe --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-app-form-forminfo.md @@ -0,0 +1,141 @@ +# FormInfo + +FormInfo模块提供对卡片的相关卡片信息和状态进行设置和查询的能力。 + +> **说明:** +> +> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + +## 导入模块 + +``` +import formInfo from '@ohos.app.form.formInfo'; +``` + +## FormInfo + +卡片信息 + +**系统能力**:SystemCapability.Ability.Form + +| 名称 | 读写属性 | 类型 | 描述 | +| ----------- | -------- | -------------------- | ------------------------------------------------------------ | +| bundleName | 只读 | string | 卡片所属包的包名。 | +| moduleName | 只读 | string | 卡片所属模块的模块名。 | +| abilityName | 只读 | string | 卡片所属的Ability名称。 | +| name | 只读 | string | 卡片名称。 | +| description | 只读 | string | 卡片描述。 | +| type | 只读 | [FormType](#formtype) | 卡片类型。当前支持JS卡片。 | +| jsComponentName | 只读 | string | js卡片的组件名。 | +| colorMode | 只读 | [ColorMode](#colormode) | 卡片颜色模式。 | +| isDefault | 只读 | boolean | 卡片是否是默认卡片。 | +| updateEnabled | 只读 | boolean | 卡片是否使能更新。 | +| formVisibleNotify | 只读 | string | 卡片是否使能可见通知。 | +| relatedBundleName | 只读 | string | 卡片所属的相关联包名。 | +| scheduledUpdateTime | 只读 | string | 卡片更新时间。 | +| formConfigAbility | 只读 | string | 卡片配置ability。指定长按卡片弹出的选择框内,编辑选项所对应的ability。 | +| updateDuration | 只读 | string | 卡片更新周期。 | +| defaultDimension | 只读 | number | 表示卡片规格 | +| supportDimensions | 只读 | Array<number> | 卡片支持的规格。具体可选规格参考[FormDimension](#formdimension) | +| customizeData | 只读 | {[key: string]: [value: string]} | 卡片用户数据。 | + +## FormType + +支持的卡片类型枚举。 + +**系统能力**:SystemCapability.Ability.Form + +| 名称 | 值 | 说明 | +| ----------- | ---- | ------------ | +| JS | 1 | 卡片类型为JS。 | +| eTS | 2 | 卡片类型为eTS。 | + +## ColorMode + +卡片支持的颜色模式枚举。 + +**系统能力**:SystemCapability.Ability.Form + +| 名称 | 值 | 说明 | +| ----------- | ---- | ------------ | +| MODE_AUTO | -1 | 表示自动模式。 | +| MODE_DARK | 0 | 表示暗色。 | +| MODE_LIGHT | 1 | 表示亮色。 | + +## FormStateInfo + +卡片状态信息。 + +**系统能力**:SystemCapability.Ability.Form + +| 名称 | 读写属性 | 类型 | 描述 | +| ----------- | -------- | -------------------- | ------------------------------------------------------------ | +| formState | 只读 | [FormState](#formstate) | 卡片状态。 | +| want | 只读 | Want | Want文本内容。 | + +## FormState + +卡片状态枚举。 + +**系统能力**:SystemCapability.Ability.Form + +| 名称 | 值 | 说明 | +| ----------- | ---- | ------------ | +| UNKNOWN | -1 | 表示未知状态。 | +| DEFAULT | 0 | 表示默认状态。 | +| READY | 1 | 表示就绪状态。 | + +## FormParam + +卡片参数枚举。 + +**系统能力**:SystemCapability.Ability.Form + +| 名称 | 值 | 说明 | +| ----------- | ---- | ------------ | +| IDENTITY_KEY | "ohos.extra.param.key.form_identity" | 卡片标识。
**系统接口**: 此接口为系统接口。 | +| DIMENSION_KEY | "ohos.extra.param.key.form_dimension" | 卡片规格样式。 | +| NAME_KEY | "ohos.extra.param.key.form_name" | 卡片名称。 | +| MODULE_NAME_KEY | "ohos.extra.param.key.module_name" | 卡片所属模块名称。 | +| WIDTH_KEY | "ohos.extra.param.key.form_width" | 卡片宽度。 | +| HEIGHT_KEY | "ohos.extra.param.key.form_height" | 卡片高度。 | +| TEMPORARY_KEY | "ohos.extra.param.key.form_temporary" | 临时卡片。 | +| ABILITY_NAME_KEY | "ohos.extra.param.key.ability_name" | ability名称 | +| DEVICE_ID_KEY | "ohos.extra.param.key.device_id" | 设备标识。
**系统接口**: 此接口为系统接口。 | +| BUNDLE_NAME_KEY | "ohos.extra.param.key.bundle_name" | 指示指定要获取的捆绑包名称的键。| + +## FormDimension + +定义卡片尺寸枚举。 + +**系统能力**:SystemCapability.Ability.Form + +| 名称 | 值 | 说明 | +| ----------- | ---- | ------------ | +| Dimension_1_2 | 1 | 1 x 2 form。 | +| Dimension_2_2 | 2 | 2 x 2 form。 | +| Dimension_2_4 | 3 | 2 x 4 form。 | +| Dimension_4_4 | 4 | 4 x 4 form。 | +| Dimension_2_1 | 5 | 2 x 1 form。 | + + +## FormInfoFilter + +卡片信息过滤器,仅将符合过滤器内要求的卡片信息返回。 + +**系统能力**:SystemCapability.Ability.Form + +| 名称 | 必选 | 说明 | +| ----------- | ---- | ------------ | +| moduleName | 否 | 仅保留moduleName与提供值相符的卡片信息。 | + +## VisibilityType + +卡片当前可见类型枚举。 + +**系统能力**:SystemCapability.Ability.Form + +| 名称 | 值 | 说明 | +| ----------- | ---- | ------------ | +| FORM_VISIBLE | 否 | 表示卡片为可见。 | +| FORM_INVISIBLE | 否 | 表示卡片为不可见。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-form-formprovider.md b/zh-cn/application-dev/reference/apis/js-apis-app-form-formprovider.md new file mode 100644 index 0000000000000000000000000000000000000000..6b07b85c77ccb627edad9ce6957b174e47671a64 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-app-form-formprovider.md @@ -0,0 +1,560 @@ +# FormProvider + +FormProvider模块提供了卡片提供方相关接口的能力,开发者在开发卡片时,可通过该模块提供接口实现更新卡片,设置卡片更新时间,获取卡片信息,请求发布卡片等。 + +> **说明:** +> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + +## 导入模块 + +``` +import formProvider from '@ohos.app.form.formProvider'; +``` + +## setFormNextRefreshTime + +setFormNextRefreshTime(formId: string, minute: number, callback: AsyncCallback<void>): void + +设置指定卡片的下一次更新时间,使用callback异步回调。 + +**系统能力:** SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------------------------- | +| formId | string | 是 | 卡片标识。 | +| minute | number | 是 | 指定多久之后更新,单位分钟,大于等于5。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +以下错误码的详细介绍请参见[卡片错误码](../errorcodes/errcode-form.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 16500100 | Failed to obtain configuration information. | +| 16501001 | The ID of the form to be operated does not exist. | +| 16501002 | The number of forms exceeds the upper bound. | +| 16501003 | The form can not be operated by the current application. | + +**示例:** + +```js +var formId = "12400633174999288"; +try { + formProvider.setFormNextRefreshTime(formId, 5, (error, data) => { + if (error) { + console.log('formProvider setFormNextRefreshTime, error:' + JSON.stringify(error)); + } else { + console.log(`formProvider setFormNextRefreshTime success`); + } + }); +} catch (error) { + console.log("error" + JSON.stringify(error)) +} +``` + +## setFormNextRefreshTime + +setFormNextRefreshTime(formId: string, minute: number): Promise<void> + +设置指定卡片的下一次更新时间,使用Promise异步回调。 + +**系统能力:** SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------------------------- | +| formId | string | 是 | 卡片标识。 | +| minute | number | 是 | 指定多久之后更新,单位分钟,大于等于5。 | + +**返回值:** + +| 类型 | 说明 | +| ------------- | ---------------------------------- | +| Promise\ | 无返回结果的Promise对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[卡片错误码](../errorcodes/errcode-form.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 16500100 | Failed to obtain configuration information. | +| 16501001 | The ID of the form to be operated does not exist. | +| 16501002 | The number of forms exceeds the upper bound. | +| 16501003 | The form can not be operated by the current application. | + +**示例:** + +```js +var formId = "12400633174999288"; +try { + formProvider.setFormNextRefreshTime(formId, 5).then(() => { + console.log('formProvider setFormNextRefreshTime success'); + }).catch((error) => { + console.log('formProvider setFormNextRefreshTime, error:' + JSON.stringify(error)); + }); +} catch (error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` + +## updateForm + +updateForm(formId: string, formBindingData: formBindingData.FormBindingData,callback: AsyncCallback<void>): void + +更新指定的卡片,使用callback异步回调。 + +**系统能力:** SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ---------------------------------------------------------------------- | ---- | ---------------- | +| formId | string | 是 | 请求更新的卡片标识。 | +| formBindingData | [FormBindingData](js-apis-formbindingdata.md#formbindingdata) | 是 | 用于更新的数据。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**错误码:** + +以下错误码的详细介绍请参见[卡片错误码](../errorcodes/errcode-form.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 16501001 | The ID of the form to be operated does not exist. | + +**示例:** + +```js +import formBindingData from '@ohos.application.formBindingData'; +var formId = "12400633174999288"; +try { + let obj = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); + formProvider.updateForm(formId, obj, (error, data) => { + if (error) { + console.log('formProvider updateForm, error:' + JSON.stringify(error)); + } else { + console.log(`formProvider updateForm success`); + } + }); +} catch (error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` + +## updateForm + +updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Promise<void> + +更新指定的卡片,使用Promise异步回调。 + +**系统能力:** SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ---------------------------------------------------------------------- | ---- | ---------------- | +| formId | string | 是 | 请求更新的卡片标识。 | +| formBindingData | [FormBindingData](js-apis-formbindingdata.md#formbindingdata) | 是 | 用于更新的数据。 | + +**返回值:** + +| 类型 | 说明 | +| -------------- | ----------------------------------- | +| Promise\ | 无返回结果的Promise对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[卡片错误码](../errorcodes/errcode-form.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 16501001 | The ID of the form to be operated does not exist. | + +**示例:** + +```js +import formBindingData from '@ohos.application.formBindingData'; +var formId = "12400633174999288"; +let obj = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); +try { + formProvider.updateForm(formId, obj).then(() => { + console.log('formProvider updateForm success'); + }).catch((error) => { + console.log('formProvider updateForm, error:' + JSON.stringify(error)); + }); +} catch (error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` + +## getFormsInfo + +getFormsInfo(callback: AsyncCallback<Array<formInfo.FormInfo>>): void + +获取设备上当前应用程序的卡片信息,使用callback异步回调。 + +**系统能力:** SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| callback | AsyncCallback<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | 是 | 回调函数。返回查询到的卡片信息。 | + +**错误码:** + +以下错误码的详细介绍请参见[卡片错误码](../errorcodes/errcode-form.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 16500100 | Failed to obtain configuration information. | + + +**示例:** + +```js +try { + formProvider.getFormsInfo((error, data) => { + if (error) { + console.log('formProvider getFormsInfo, error:' + JSON.stringify(error)); + } else { + console.log('formProvider getFormsInfo, data:' + JSON.stringify(data)); + } + }); +} catch (error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` +## getFormsInfo + +getFormsInfo(filter: formInfo.FormInfoFilter, callback: AsyncCallback<Array<formInfo.FormInfo>>): void + +获取设备上当前应用程序的卡片信息,并筛选符合条件的信息,使用callback异步回调。 + +**系统能力:** SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| filter | [formInfo.FormInfoFilter](./js-apis-formInfo.md#forminfofilter) | 是 | 卡片信息过滤器。 | +| callback | AsyncCallback<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | 是 | 回调函数。返回查询到符合条件的卡片信息。 | + +**错误码:** + +以下错误码的详细介绍请参见[卡片错误码](../errorcodes/errcode-form.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 16500100 | Failed to obtain configuration information. | + +**示例:** + +```js +import formInfo from '@ohos.application.formInfo'; +const filter : formInfo.FormInfoFilter = { + // get info of forms belong to module entry. + moduleName : "entry" +}; +try { + formProvider.getFormsInfo(filter, (error, data) => { + if (error) { + console.log('formProvider getFormsInfo, error:' + JSON.stringify(error)); + } else { + console.log('formProvider getFormsInfo, data:' + JSON.stringify(data)); + } + }); +} catch(error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` + +## getFormsInfo + +getFormsInfo(filter?: formInfo.FormInfoFilter): Promise<Array<formInfo.FormInfo>> + +获取设备上当前应用程序的卡片信息,使用Promise异步回调。 + +**系统能力:** SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| filter | [formInfo.FormInfoFilter](./js-apis-formInfo.md) | 否 | 卡片信息过滤器。 | + +**返回值:** + +| 类型 | 说明 | +| :------------ | :---------------------------------- | +| Promise<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | Promise对象。返回查询到符合条件的卡片信息。 | + +**错误码:** + +以下错误码的详细介绍请参见[卡片错误码](../errorcodes/errcode-form.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 16500100 | Failed to obtain configuration information. | + +**示例:** + +```js +import formInfo from '@ohos.application.formInfo'; +const filter : formInfo.FormInfoFilter = { + // get info of forms belong to module entry. + moduleName : "entry" +}; +try { + formProvider.getFormsInfo(filter).then((data) => { + console.log('formProvider getFormsInfo, data:' + JSON.stringify(data)); + }).catch((error) => { + console.log('formProvider getFormsInfo, error:' + JSON.stringify(error)); + }); +} catch (error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` + +## requestPublishForm + +requestPublishForm(want: Want, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback\): void + +请求发布一张卡片到使用方。使用方通常为桌面。 + +**系统能力:** SystemCapability.Ability.Form + +**系统接口**: 此接口为系统接口。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ---------------------------------------------------------------------- | ---- | ---------------- | +| want | [Want](js-apis-application-Want.md) | 是 | 发布请求。需包含以下字段。
abilityName: 目标卡片ability
parameters:
"ohos.extra.param.key.form_dimension"
"ohos.extra.param.key.form_name"
"ohos.extra.param.key.module_name" | +| formBindingData | [FormBindingData](js-apis-formbindingdata.md#formbindingdata) | 是 | 创建卡片的数据。 | +| callback | AsyncCallback<string> | 是 | 回调函数。返回卡片标识。 | + +以下错误码的详细介绍请参见[卡片错误码](../errorcodes/errcode-form.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 16501000 | A functional error occurred. | + +**示例:** + +```js +import formBindingData from '@ohos.application.formBindingData'; +var want = { + abilityName: "FormAbility", + parameters: { + "ohos.extra.param.key.form_dimension": 2, + "ohos.extra.param.key.form_name": "widget", + "ohos.extra.param.key.module_name": "entry" + } +}; +try { + let obj = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); + formProvider.requestPublishForm(want, obj, (error, data) => { + if (error) { + console.log('formProvider requestPublishForm, error: ' + JSON.stringify(error)); + } else { + console.log('formProvider requestPublishForm, form ID is: ' + JSON.stringify(data)); + } + }); +} catch (error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` + +## requestPublishForm + +requestPublishForm(want: Want, callback: AsyncCallback<string>): void + +请求发布一张卡片到使用方。使用方通常为桌面。 + +**系统能力:** SystemCapability.Ability.Form + +**系统接口**: 此接口为系统接口。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------- | ---- | ------------------------------------------------------------ | +| want | [Want](js-apis-application-Want.md) | 是 | 发布请求。需包含以下字段。
abilityName: 目标卡片ability
parameters:
"ohos.extra.param.key.form_dimension"
"ohos.extra.param.key.form_name"
"ohos.extra.param.key.module_name" | +| callback | AsyncCallback<string> | 是 | 回调函数。返回卡片标识。 | + +以下错误码的详细介绍请参见[卡片错误码](../errorcodes/errcode-form.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 16501000 | A functional error occurred. | + +**示例:** + +```js +var want = { + abilityName: "FormAbility", + parameters: { + "ohos.extra.param.key.form_dimension": 2, + "ohos.extra.param.key.form_name": "widget", + "ohos.extra.param.key.module_name": "entry" + } +}; +try { + formProvider.requestPublishForm(want, (error, data) => { + if (error) { + console.log('formProvider requestPublishForm, error: ' + JSON.stringify(error)); + } else { + console.log('formProvider requestPublishForm, form ID is: ' + JSON.stringify(data)); + } + }); +} catch (error) { + console.log(`catch err->${JSON.stringify(error)}`); +} + +``` + +## requestPublishForm + +requestPublishForm(want: Want, formBindingData?: formBindingData.FormBindingData): Promise<string> + +请求发布一张卡片到使用方。使用方通常为桌面。 + +**系统能力:** SystemCapability.Ability.Form + +**系统接口**: 此接口为系统接口。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| want | [Want](js-apis-application-Want.md) | 是 | 发布请求。需包含以下字段。
abilityName: 目标卡片ability
parameters:
"ohos.extra.param.key.form_dimension"
"ohos.extra.param.key.form_name"
"ohos.extra.param.key.module_name" | +| formBindingData | [FormBindingData](js-apis-formbindingdata.md#formbindingdata) | 否 | 创建卡片的数据。 | + +**返回值:** + +| 类型 | 说明 | +| :------------ | :---------------------------------- | +| Promise<string> | Promise对象。返回卡片标识。 | + +以下错误码的详细介绍请参见[卡片错误码](../errorcodes/errcode-form.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 16501000 | A functional error occurred. | + +**示例:** + +```js +var want = { + abilityName: "FormAbility", + parameters: { + "ohos.extra.param.key.form_dimension": 2, + "ohos.extra.param.key.form_name": "widget", + "ohos.extra.param.key.module_name": "entry" + } +}; +try { + formProvider.requestPublishForm(want).then((data) => { + console.log('formProvider requestPublishForm success, form ID is :' + JSON.stringify(data)); + }).catch((error) => { + console.log('formProvider requestPublishForm, error: ' + JSON.stringify(error)); + }); +} catch (error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` + +## isRequestPublishFormSupported + +isRequestPublishFormSupported(callback: AsyncCallback<boolean>): void + +查询是否支持发布一张卡片到使用方。 + +**系统接口**: 此接口为系统接口。 + +**系统能力:** SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| callback | AsyncCallback<boolean> | 是 | 回调函数。返回是否支持发布一张卡片到使用方。| + +**示例:** + +```js +try { + formProvider.isRequestPublishFormSupported((error, isSupported) => { + if (error) { + console.log('formProvider isRequestPublishFormSupported, error:' + JSON.stringify(error)); + } else { + if (isSupported) { + var want = { + abilityName: "FormAbility", + parameters: { + "ohos.extra.param.key.form_dimension": 2, + "ohos.extra.param.key.form_name": "widget", + "ohos.extra.param.key.module_name": "entry" + } + }; + try { + formProvider.requestPublishForm(want, (error, data) => { + if (error) { + console.log('formProvider requestPublishForm, error: ' + JSON.stringify(error)); + } else { + console.log('formProvider requestPublishForm, form ID is: ' + JSON.stringify(data)); + } + }); + } catch (error) { + console.log(`catch err->${JSON.stringify(error)}`); + } + + } + } +}); +} catch (error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` + +## isRequestPublishFormSupported + +isRequestPublishFormSupported(): Promise<boolean> + +查询是否支持发布一张卡片到使用方。 + +**系统接口**: 此接口为系统接口。 + +**系统能力:** SystemCapability.Ability.Form + +**返回值:** + +| 类型 | 说明 | +| :------------ | :---------------------------------- | +| Promise<boolean> | Promise对象。返回是否支持发布一张卡片到使用方。 | + +**示例:** + +```js +try { + formProvider.isRequestPublishFormSupported().then((isSupported) => { + if (isSupported) { + var want = { + abilityName: "FormAbility", + parameters: { + "ohos.extra.param.key.form_dimension": 2, + "ohos.extra.param.key.form_name": "widget", + "ohos.extra.param.key.module_name": "entry" + } + }; + try { + formProvider.requestPublishForm(want).then((data) => { + console.log('formProvider requestPublishForm success, form ID is :' + JSON.stringify(data)); + }).catch((error) => { + console.log('formProvider requestPublishForm, error: ' + JSON.stringify(error)); + }); + } catch (error) { + console.log(`catch err->${JSON.stringify(error)}`); + } + + } + }).catch((error) => { + console.log('formProvider isRequestPublishFormSupported, error:' + JSON.stringify(error)); + }); +} catch (error) { + console.log(`catch err->${JSON.stringify(error)}`); +} +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-formInfo.md b/zh-cn/application-dev/reference/apis/js-apis-formInfo.md index b1f21bf39ea946b8a324b0031f244922b8658dd6..9dd1ffa224f5cdf9622ebc97ce374e286dbf3850 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-formInfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-formInfo.md @@ -5,6 +5,7 @@ FormInfo模块提供对卡片的相关卡片信息和状态进行设置和查询 > **说明:** > > 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> 从API version 9 开始不再维护,建议使用[FormInfo](js-apis-app-form-forminfo.md)替代。 ## 导入模块 @@ -12,10 +13,6 @@ FormInfo模块提供对卡片的相关卡片信息和状态进行设置和查询 import formInfo from '@ohos.application.formInfo'; ``` -## 权限 - -无 - ## FormInfo 卡片信息 @@ -24,46 +21,47 @@ import formInfo from '@ohos.application.formInfo'; | 名称 | 读写属性 | 类型 | 描述 | | ----------- | -------- | -------------------- | ------------------------------------------------------------ | -| bundleName | 只读 | string | 表示卡片所属包的包名。 | -| moduleName | 只读 | string | 表示卡片所属模块的模块名。 | -| abilityName | 只读 | string | 表示卡片所属的Ability名称。 | -| name | 只读 | string | 表示卡片名称。 | -| description | 只读 | string | 表示卡片描述。 | -| type | 只读 | [FormType](#formtype) | 表示卡片类型,当前支持JS卡片。 | -| jsComponentName | 只读 | string | 表示js卡片的组件名。 | -| colorMode | 只读 | [ColorMode](#colormode) | 表示卡片颜色模式。 | -| isDefault | 只读 | boolean | 表示是否是默认卡片。 | -| updateEnabled | 只读 | boolean | 表示卡片是否使能更新。 | -| formVisibleNotify | 只读 | string | 表示卡片是否使能可见通知。 | -| relatedBundleName | 只读 | string | 表示卡片所属的相关联包名。 | -| scheduledUpdateTime | 只读 | string | 表示卡片更新时间。 | -| formConfigAbility | 只读 | string | 表示卡片配置ability。 | -| updateDuration | 只读 | string | 表示卡片更新周期。 | +| bundleName | 只读 | string | 卡片所属包的包名。 | +| moduleName | 只读 | string | 卡片所属模块的模块名。 | +| abilityName | 只读 | string | 卡片所属的Ability名称。 | +| name | 只读 | string | 卡片名称。 | +| description | 只读 | string | 卡片描述。 | +| type | 只读 | [FormType](#formtype) | 卡片类型。当前支持JS卡片。 | +| jsComponentName | 只读 | string | js卡片的组件名。 | +| colorMode | 只读 | [ColorMode](#colormode) | 卡片颜色模式。 | +| isDefault | 只读 | boolean | 卡片是否是默认卡片。 | +| updateEnabled | 只读 | boolean | 卡片是否使能更新。 | +| formVisibleNotify | 只读 | string | 卡片是否使能可见通知。 | +| relatedBundleName | 只读 | string | 卡片所属的相关联包名。 | +| scheduledUpdateTime | 只读 | string | 卡片更新时间。 | +| formConfigAbility | 只读 | string | 卡片配置ability。指定长按卡片弹出的选择框内,编辑选项所对应的ability。 | +| updateDuration | 只读 | string | 卡片更新周期。 | | defaultDimension | 只读 | number | 表示卡片规格 | -| supportDimensions | 只读 | Array<number> | 表示卡片支持的规格。 | -| customizeData | 只读 | {[key: string]: [value: string]} | 表示卡片用户数据。 | +| supportDimensions | 只读 | Array<number> | 卡片支持的规格。具体可选规格参考[FormDimension](#formdimension) | +| customizeData | 只读 | {[key: string]: [value: string]} | 卡片用户数据。 | ## FormType -枚举,支持的卡片类型。 +支持的卡片类型枚举。 **系统能力**:SystemCapability.Ability.Form | 名称 | 值 | 说明 | | ----------- | ---- | ------------ | | JS | 1 | 卡片类型为JS。 | +| eTS | 2 | 卡片类型为eTS。 | ## ColorMode -枚举,卡片支持的颜色模式。 +卡片支持的颜色模式枚举。 **系统能力**:SystemCapability.Ability.Form | 名称 | 值 | 说明 | | ----------- | ---- | ------------ | -| MODE_AUTO | -1 | 自动模式。 | -| MODE_DARK | 0 | 暗色。 | -| MODE_LIGHT | 1 | 亮色。 | +| MODE_AUTO | -1 | 表示自动模式。 | +| MODE_DARK | 0 | 表示暗色。 | +| MODE_LIGHT | 1 | 表示亮色。 | ## FormStateInfo @@ -73,30 +71,30 @@ import formInfo from '@ohos.application.formInfo'; | 名称 | 读写属性 | 类型 | 描述 | | ----------- | -------- | -------------------- | ------------------------------------------------------------ | -| formState | 只读 | [FormState](#formstate) | 表示卡片状态。 | +| formState | 只读 | [FormState](#formstate) | 卡片状态。 | | want | 只读 | Want | Want文本内容。 | ## FormState -枚举,卡片状态。 +卡片状态枚举。 **系统能力**:SystemCapability.Ability.Form | 名称 | 值 | 说明 | | ----------- | ---- | ------------ | -| UNKNOWN | -1 | 未知状态。 | -| DEFAULT | 0 | 默认状态。 | -| READY | 1 | 就绪状态。 | +| UNKNOWN | -1 | 表示未知状态。 | +| DEFAULT | 0 | 表示默认状态。 | +| READY | 1 | 表示就绪状态。 | ## FormParam -枚举,卡片参数。 +卡片参数枚举。 **系统能力**:SystemCapability.Ability.Form | 名称 | 值 | 说明 | | ----------- | ---- | ------------ | -| IDENTITY_KEY9+ | "ohos.extra.param.key.form_identity" | 卡片标识。
**系统API**: 此接口为系统接口,三方应用不支持调用。 | +| IDENTITY_KEY9+ | "ohos.extra.param.key.form_identity" | 卡片标识。
**系统接口**: 此接口为系统接口。 | | DIMENSION_KEY | "ohos.extra.param.key.form_dimension" | 卡片规格样式。 | | NAME_KEY | "ohos.extra.param.key.form_name" | 卡片名称。 | | MODULE_NAME_KEY | "ohos.extra.param.key.module_name" | 卡片所属模块名称。 | @@ -104,7 +102,7 @@ import formInfo from '@ohos.application.formInfo'; | HEIGHT_KEY | "ohos.extra.param.key.form_height" | 卡片高度。 | | TEMPORARY_KEY | "ohos.extra.param.key.form_temporary" | 临时卡片。 | | ABILITY_NAME_KEY9+ | "ohos.extra.param.key.ability_name" | ability名称 | -| DEVICE_ID_KEY9+ | "ohos.extra.param.key.device_id" | 设备标识。
此接口为系统接口。 | +| DEVICE_ID_KEY9+ | "ohos.extra.param.key.device_id" | 设备标识。
**系统接口**: 此接口为系统接口。 | | BUNDLE_NAME_KEY9+ | "ohos.extra.param.key.bundle_name" | 指示指定要获取的捆绑包名称的键。| ## FormDimension @@ -122,7 +120,7 @@ import formInfo from '@ohos.application.formInfo'; | Dimension_2_19+ | 5 | 2 x 1 form。 | -## FormInfoFilter +## FormInfoFilter9+ 卡片信息过滤器,仅将符合过滤器内要求的卡片信息返回。 @@ -130,4 +128,15 @@ import formInfo from '@ohos.application.formInfo'; | 名称 | 必选 | 说明 | | ----------- | ---- | ------------ | -| moduleName9+ | 否 | 可选字段,表示仅保留moduleName与提供值相符的卡片信息。 | +| moduleName9+ | 否 | 仅保留moduleName与提供值相符的卡片信息。 | + +## VisibilityType9+ + +卡片当前可见类型枚举。 + +**系统能力**:SystemCapability.Ability.Form + +| 名称 | 值 | 说明 | +| ----------- | ---- | ------------ | +| FORM_VISIBLE9+ | 否 | 表示卡片为可见。 | +| FORM_INVISIBLE9+ | 否 | 表示卡片为不可见。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-formbindingdata.md b/zh-cn/application-dev/reference/apis/js-apis-formbindingdata.md index 1d4badb7a5d77b04e3ad598f88757973ce34570d..9332e15c6219278b5675e64539e99f6569f7324a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-formbindingdata.md +++ b/zh-cn/application-dev/reference/apis/js-apis-formbindingdata.md @@ -3,20 +3,27 @@ 卡片数据绑定模块提供卡片数据绑定的能力。包括FormBindingData对象的创建、相关信息的描述。 > **说明:** -> +> > 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - +> 从API version 9 开始不再维护,建议使用[FormBindingData](js-apis-app-form-formbindingdata.md)替代。 ## 导入模块 ``` import formBindingData from '@ohos.application.formBindingData'; ``` -## 权限 +## FormBindingData + +FormBindingData相关描述。 + +**系统能力**:SystemCapability.Ability.Form + +| 名称 | 可读 | 可写 | 参数类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | -------- | -------- | +| data | 是 | 否 | Object | 是 | js卡片要展示的数据。可以是包含若干键值对的Object或者 json 格式的字符串。| -无 -## formBindingData.createFormBindingData +## createFormBindingData createFormBindingData(obj?: Object | string): FormBindingData @@ -40,30 +47,17 @@ createFormBindingData(obj?: Object | string): FormBindingData **示例:** - ```js - import featureAbility from '@ohos.ability.featureAbility'; - import fileio from '@ohos.fileio'; - let context=featureAbility.getContext(); - context.getOrCreateLocalDir((err,data)=>{ - let path=data+"/xxx.jpg"; - let fd = fileio.openSync(path); - let obj = { - "temperature": "21°", - "formImages": {"image": fd} - }; - let formBindingDataObj = formBindingData.createFormBindingData(obj); - }) - - - ``` - -## 属性 - -FormBindingData相关描述。 - -**系统能力**:SystemCapability.Ability.Form - -| 名称 | 可读 | 可写 | 参数类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -------- | -| data | 是 | 否 | Object | 是 | js卡片要展示的数据。可以是包含若干键值对的Object或者 json 格式的字符串。| - +```js +import featureAbility from '@ohos.ability.featureAbility'; +import fileio from '@ohos.fileio'; +let context=featureAbility.getContext(); +context.getOrCreateLocalDir((err,data)=>{ + let path=data+"/xxx.jpg"; + let fd = fileio.openSync(path); + let obj = { + "temperature": "21°", + "formImages": {"image": fd} + }; + let formBindingDataObj = formBindingData.createFormBindingData(obj); +}) +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-formerror.md b/zh-cn/application-dev/reference/apis/js-apis-formerror.md index 6a76c6188ef030c87a7d1f09bb9e7bc7fd361767..36b638a3633db86761e4eb2d87e4d10268820825 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-formerror.md +++ b/zh-cn/application-dev/reference/apis/js-apis-formerror.md @@ -3,8 +3,9 @@ FormError模块提供获取卡片错误码的能力。 > **说明:** -> +> > 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> 从API version 9 开始不再维护,建议使用[Form错误码](../errorcodes/errcode-form.md)替代。 ## 导入模块 @@ -16,9 +17,9 @@ import formError from '@ohos.application.formError'; 无 -## enum FormError +## FormError -支持的卡片类型 +枚举,支持的卡片类型 **系统能力:** @@ -26,27 +27,27 @@ SystemCapability.Ability.Form | 名称 | 值 | 说明 | | ----------- | ---- | ------------ | -| ERR_COMMON | 1 | 默认错误码 | -| ERR_PERMISSION_DENY | 2 | 没有操作权限 | -| ERR_GET_INFO_FAILED | 4 | 查询卡片信息失败 | -| ERR_GET_BUNDLE_FAILED | 5 | 查询应用信息失败 | -| ERR_GET_LAYOUT_FAILED | 6 | 查询布局信息失败 | -| ERR_ADD_INVALID_PARAM | 7 | 无效参数 | -| ERR_CFG_NOT_MATCH_ID | 8 | 卡片ID不匹配 | -| ERR_NOT_EXIST_ID | 9 | 卡片ID不存在 | -| ERR_BIND_PROVIDER_FAILED | 10 | 绑定卡片提供方失败 | -| ERR_MAX_SYSTEM_FORMS | 11 | 系统卡片实例数量超过限制 | -| ERR_MAX_INSTANCES_PER_FORM | 12 | 每张卡片实例数量超过限制 | -| ERR_OPERATION_FORM_NOT_SELF | 13 | 操作非自己应用申请的卡片 | -| ERR_PROVIDER_DEL_FAIL | 14 | 卡片提供方删除卡片失败 | -| ERR_MAX_FORMS_PER_CLIENT | 15 | 使用方申请卡片实例数超过限制 | -| ERR_MAX_SYSTEM_TEMP_FORMS | 16 | 临时卡片实例数超过限制 | -| ERR_FORM_NO_SUCH_MODULE | 17 | 模块不存在 | -| ERR_FORM_NO_SUCH_ABILITY | 18 | ability组件不存在 | -| ERR_FORM_NO_SUCH_DIMENSION | 19 | 卡片尺寸不存在 | -| ERR_FORM_FA_NOT_INSTALLED | 20 | 卡片所在FA未安装 | -| ERR_SYSTEM_RESPONSES_FAILED | 30 | 系统服务响应失败 | -| ERR_FORM_DUPLICATE_ADDED | 31 | 重复添加卡片 | -| ERR_IN_RECOVERY | 36 | 卡片数据覆盖失败 | -| ERR_DISTRIBUTED_SCHEDULE_FAILED9+ | 37 | 分布式调度失败。
此接口为系统接口。 | +| ERR_COMMON | 1 | 默认错误码。 | +| ERR_PERMISSION_DENY | 2 | 没有操作权限。 | +| ERR_GET_INFO_FAILED | 4 | 查询卡片信息失败。 | +| ERR_GET_BUNDLE_FAILED | 5 | 查询应用信息失败。 | +| ERR_GET_LAYOUT_FAILED | 6 | 查询布局信息失败。 | +| ERR_ADD_INVALID_PARAM | 7 | 无效参数。 | +| ERR_CFG_NOT_MATCH_ID | 8 | 卡片ID不匹配。 | +| ERR_NOT_EXIST_ID | 9 | 卡片ID不存在。 | +| ERR_BIND_PROVIDER_FAILED | 10 | 绑定卡片提供方失败。 | +| ERR_MAX_SYSTEM_FORMS | 11 | 系统卡片实例数量超过限制。 | +| ERR_MAX_INSTANCES_PER_FORM | 12 | 每张卡片实例数量超过限制。 | +| ERR_OPERATION_FORM_NOT_SELF | 13 | 操作非自己应用申请的卡片。 | +| ERR_PROVIDER_DEL_FAIL | 14 | 卡片提供方删除卡片失败。 | +| ERR_MAX_FORMS_PER_CLIENT | 15 | 使用方申请卡片实例数超过限制。 | +| ERR_MAX_SYSTEM_TEMP_FORMS | 16 | 临时卡片实例数超过限制。 | +| ERR_FORM_NO_SUCH_MODULE | 17 | 模块不存在。 | +| ERR_FORM_NO_SUCH_ABILITY | 18 | ability组件不存在。 | +| ERR_FORM_NO_SUCH_DIMENSION | 19 | 卡片尺寸不存在。 | +| ERR_FORM_FA_NOT_INSTALLED | 20 | 卡片所在FA未安装。 | +| ERR_SYSTEM_RESPONSES_FAILED | 30 | 系统服务响应失败。 | +| ERR_FORM_DUPLICATE_ADDED | 31 | 重复添加卡片。 | +| ERR_IN_RECOVERY | 36 | 卡片数据覆盖失败。 | +| ERR_DISTRIBUTED_SCHEDULE_FAILED9+ | 37 | 分布式调度失败。
**系统接口**: 此接口为系统接口。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-formextension.md b/zh-cn/application-dev/reference/apis/js-apis-formextension.md index 9ce62fea510de235c644cb1cd2aab41aeb894414..e6771dfe88b4305c6771b39b325202643f9deaea 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-formextension.md +++ b/zh-cn/application-dev/reference/apis/js-apis-formextension.md @@ -3,8 +3,9 @@ FormExtension模块提供了FormExtension卡片扩展相关接口。 > **说明:** -> -> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> +> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> 从API version 9 开始不再维护,建议使用[FormExtensionAbility](js-apis-app-form-formextensionability.md)替代。 > 本模块接口仅可在Stage模型下使用。 ## 导入模块 @@ -13,10 +14,6 @@ FormExtension模块提供了FormExtension卡片扩展相关接口。 import FormExtension from '@ohos.application.FormExtension'; ``` -## 权限 - -无 - ## 属性 **系统能力**:SystemCapability.Ability.Form @@ -35,32 +32,32 @@ onCreate(want: Want): formBindingData.FormBindingData **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | -------------------------------------- | ---- | ------------------------------------------------------------ | - | want | [Want](js-apis-application-Want.md) | 是 | 当前Extension相关的Want类型信息,包括卡片ID、卡片名称、卡片样式等。这些卡片信息必须作为持久数据进行管理,以便后续更新和删除卡片。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | -------------------------------------- | ---- | ------------------------------------------------------------ | +| want | [Want](js-apis-application-Want.md) | 是 | 当前Extension相关的Want类型信息,包括卡片ID、卡片名称、卡片样式等。这些卡片信息必须作为持久数据进行管理,以便后续更新和删除卡片。 | **返回值:** - | 类型 | 说明 | - | ------------------------------------------------------------ | ----------------------------------------------------------- | - | [formBindingData.FormBindingData](js-apis-formbindingdata.md#formbindingdata) | 一个formBindingData.FormBindingData对象,卡片要显示的数据。 | +| 类型 | 说明 | +| ------------------------------------------------------------ | ----------------------------------------------------------- | +| [formBindingData.FormBindingData](js-apis-formbindingdata.md#formbindingdata) | formBindingData.FormBindingData对象,卡片要显示的数据。 | **示例:** - ```js - import formBindingData from '@ohos.application.formBindingData' - export default class MyFormExtension extends FormExtension { - onCreate(want) { - console.log('FormExtension onCreate, want:' + want.abilityName); - let dataObj1 = { - temperature:"11c", - "time":"11:00" - }; - let obj1 = formBindingData.createFormBindingData(dataObj1); - return obj1; - } +```js +import formBindingData from '@ohos.application.formBindingData' +export default class MyFormExtension extends FormExtension { + onCreate(want) { + console.log('FormExtension onCreate, want:' + want.abilityName); + let dataObj1 = { + temperature:"11c", + "time":"11:00" + }; + let obj1 = formBindingData.createFormBindingData(dataObj1); + return obj1; } - ``` +} +``` ## FormExtension.onCastToNormal @@ -72,19 +69,19 @@ onCastToNormal(formId: string): void **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------------------------ | - | formId | string | 是 | 请求转换为常态的卡片ID。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------------ | +| formId | string | 是 | 请求转换为常态的卡片标识。 | **示例:** - ``` - export default class MyFormExtension extends FormExtension { - onCastToNormal(formId) { - console.log('FormExtension onCastToNormal, formId:' + formId); - } +```js +export default class MyFormExtension extends FormExtension { + onCastToNormal(formId) { + console.log('FormExtension onCastToNormal, formId:' + formId); } - ``` +} +``` ## FormExtension.onUpdate @@ -96,26 +93,25 @@ onUpdate(formId: string): void **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------------------ | - | formId | string | 是 | 请求更新的卡片ID。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------ | +| formId | string | 是 | 请求更新的卡片ID。 | **示例:** - ```js - import formBindingData from '@ohos.application.formBindingData' - export default class MyFormExtension extends FormExtension { - onUpdate(formId) { - console.log('FormExtension onUpdate, formId:' + formId); - let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); - this.context.updateForm(formId, obj2) - .then((data)=>{ - console.log('FormExtension context updateForm, data:' + data); - }).catch((error) => { - console.error('Operation updateForm failed. Cause: ' + error);}); - } - } - ``` +```js +import formBindingData from '@ohos.application.formBindingData' +export default class MyFormExtension extends FormExtension { + onUpdate(formId) { + console.log('FormExtension onUpdate, formId:' + formId); + let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); + this.context.updateForm(formId, obj2).then((data)=>{ + console.log('FormExtension context updateForm, data:' + data); + }).catch((error) => { + console.error('Operation updateForm failed. Cause: ' + error);}); + } +} +``` ## FormExtension.onVisibilityChange @@ -127,30 +123,29 @@ onVisibilityChange(newStatus: { [key: string]: number }): void **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | --------- | ------------------------- | ---- | ---------------------------- | - | newStatus | { [key: string]: number } | 是 | 请求修改的卡片ID和可见状态。 | +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------------------------- | ---- | ---------------------------- | +| newStatus | { [key: string]: number } | 是 | 请求修改的卡片ID和可见状态。 | **示例:** - ```js - import formBindingData from '@ohos.application.formBindingData' - export default class MyFormExtension extends FormExtension { - onVisibilityChange(newStatus) { - console.log('FormExtension onVisibilityChange, newStatus:' + newStatus); - let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); - - for (let key in newStatus) { - console.log('FormExtension onVisibilityChange, key:' + key + ", value=" + newStatus[key]); - this.context.updateForm(key, obj2) - .then((data)=>{ - console.log('FormExtension context updateForm, data:' + data); - }).catch((error) => { - console.error('Operation updateForm failed. Cause: ' + error);}); - } - } +```js +import formBindingData from '@ohos.application.formBindingData' +export default class MyFormExtension extends FormExtension { + onVisibilityChange(newStatus) { + console.log('FormExtension onVisibilityChange, newStatus:' + newStatus); + let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); + + for (let key in newStatus) { + console.log('FormExtension onVisibilityChange, key:' + key + ", value=" + newStatus[key]); + this.context.updateForm(key, obj2).then((data)=>{ + console.log('FormExtension context updateForm, data:' + data); + }).catch((error) => { + console.error('Operation updateForm failed. Cause: ' + error);}); + } } - ``` +} +``` ## FormExtension.onEvent @@ -162,20 +157,20 @@ onEvent(formId: string, message: string): void **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------ | ---- | ---------------------- | - | formId | string | 是 | 请求触发事件的卡片ID。 | - | message | string | 是 | 事件消息。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | ---------------------- | +| formId | string | 是 | 请求触发事件的卡片标识。 | +| message | string | 是 | 事件消息。 | **示例:** - ```js - export default class MyFormExtension extends FormExtension { - onEvent(formId, message) { - console.log('FormExtension onEvent, formId:' + formId + ", message:" + message); - } +```js +export default class MyFormExtension extends FormExtension { + onEvent(formId, message) { + console.log('FormExtension onEvent, formId:' + formId + ", message:" + message); } - ``` +} +``` ## FormExtension.onDestroy @@ -187,19 +182,19 @@ onDestroy(formId: string): void **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------------------ | - | formId | string | 是 | 请求销毁的卡片ID。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------ | +| formId | string | 是 | 请求销毁的卡片标识。 | **示例:** - ```js - export default class MyFormExtension extends FormExtension { - onDestroy(formId) { - console.log('FormExtension onDestroy, formId:' + formId); - } +```js +export default class MyFormExtension extends FormExtension { + onDestroy(formId) { + console.log('FormExtension onDestroy, formId:' + formId); } - ``` +} +``` ## FormExtension.onConfigurationUpdated @@ -211,19 +206,19 @@ onConfigurationUpdated(config: Configuration): void; **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | config | [Configuration](js-apis-configuration.md) | 是 | 表示需要更新的配置信息。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| config | [Configuration](js-apis-configuration.md) | 是 | 表示需要更新的配置信息。 | **示例:** - - ```js - class MyFormExtension extends FormExtension { - onConfigurationUpdated(config) { - console.log('onConfigurationUpdated, config:' + JSON.stringify(config)); - } + +```js +class MyFormExtension extends FormExtension { + onConfigurationUpdated(config) { + console.log('onConfigurationUpdated, config:' + JSON.stringify(config)); } - ``` +} +``` ## FormExtension.onAcquireFormState @@ -235,21 +230,21 @@ onAcquireFormState?(want: Want): formInfo.FormState; **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-application-Want.md) | 否 | want表示获取卡片状态的描述。描述包括包名称、能力名称、模块名称、卡片名和卡片维度。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | 否 | want表示获取卡片状态的描述。描述包括包名称、能力名称、模块名称、卡片名和卡片维度。 | **示例:** - - ```js - import formInfo from '@ohos.application.formInfo' - class MyFormExtension extends FormExtension { - onAcquireFormState(want) { - console.log('FormExtension onAcquireFormState, want:' + want); - return formInfo.FormState.UNKNOWN; - } + +```js +import formInfo from '@ohos.application.formInfo' +class MyFormExtension extends FormExtension { + onAcquireFormState(want) { + console.log('FormExtension onAcquireFormState, want:' + want); + return formInfo.FormState.UNKNOWN; } - ``` +} +``` ## FormExtension.onShare @@ -257,33 +252,33 @@ onShare?(formId: string): {[key: string]: any}; 卡片提供方接收卡片分享的通知接口。 -此接口为系统接口。 +**系统接口**: 此接口为系统接口。 **系统能力**:SystemCapability.Ability.Form **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | formId | string | 是 | 卡片标识 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| formId | string | 是 | 卡片标识。 | **返回值:** - | 类型 | 说明 | - | ------------------------------------------------------------ | ----------------------------------------------------------- | - | {[key: string]: any} | 卡片要分享的数据,由开发者自行决定传入的键值对。 | +| 类型 | 说明 | +| ------------------------------------------------------------ | ----------------------------------------------------------- | +| {[key: string]: any} | 卡片要分享的数据,由开发者自行决定传入的键值对。 | **示例:** - - ```js - class MyFormExtension extends FormExtension { - onShare(formId) { - console.log('FormExtension onShare, formId:' + formId); - let wantParams = { - "temperature":"20", - "time":"2022-8-8 09:59", - }; - return wantParams; - } + +```js +class MyFormExtension extends FormExtension { + onShare(formId) { + console.log('FormExtension onShare, formId:' + formId); + let wantParams = { + "temperature":"20", + "time":"2022-8-8 09:59", + }; + return wantParams; } - ``` \ No newline at end of file +} +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-formextensioncontext.md b/zh-cn/application-dev/reference/apis/js-apis-formextensioncontext.md index 6a87544db5dc4e834e36b7e2d4b57298784aea74..40965e6dc39c7c2f3e99eebfd06071ae951af8ba 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-formextensioncontext.md +++ b/zh-cn/application-dev/reference/apis/js-apis-formextensioncontext.md @@ -13,10 +13,10 @@ FormExtensionContext模块提供FormExtension具有的接口和能力。 在使用FormExtensionContext的功能前,需要通过FormExtension获取。 ```js -import FormExtension from '@ohos.application.FormExtension'; -import formBindingData from '@ohos.application.formBindingData' -export default class MyFormExtension extends FormExtension { - onCreate() { +import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility'; +import formBindingData from '@ohos.app.form.formBindingData'; +export default class MyFormExtensionAbility extends FormExtensionAbility { + onAddForm() { let dataObj1 = { temperature:"11c", "time":"11:00" @@ -28,22 +28,22 @@ export default class MyFormExtension extends FormExtension { ``` -## FormExtensionContext.startAbility +## startAbility startAbility(want: Want, callback: AsyncCallback<void>): void -拉起一个卡片所属应用的Ability。 +拉起一个卡片所属应用的Ability。使用callback异步回调。 -**系统能力**:SystemCapability.Ability.Form +**系统接口**:此接口为系统接口。 -**系统API**: 此接口为系统接口,三方应用不支持调用。 +**系统能力**:SystemCapability.Ability.Form **参数:** | 参数名 | 类型 | 必填 | 说明 | | ------| --------------------------------- | ---- | -------------------------------------- | | want| [Want](js-apis-application-Want.md) | 是 | 包含bundleName,abilityName以及用户自定参数用于拉起Ability。 | -| callback| AsyncCallback<void> | 是 | 回调函数,返回接口调用是否成功的结果。 | +| callback| AsyncCallback<void> | 是 | 回调函数。当拉起一个卡片所属应用的Ability成功,err为undefined,否则为错误对象。 | **示例:** @@ -58,20 +58,24 @@ var want = { uri: "key={true,true,false}", parameters: {} } -this.context.startAbility(want, function(err) { - console.info(err.code); +this.context.startAbility(want, (error, data) => { + if (error) { + console.log('FormExtensionContext startAbility, error:' + JSON.stringify(error)); + } else { + console.log(`FormExtensionContext startAbility success`); + } }) ``` -## FormExtensionContext.startAbility +## startAbility startAbility(want: Want): Promise<void> -拉起一个卡片所属应用的Ability。 +拉起一个卡片所属应用的Ability。使用Promise异步回调。 -**系统能力**:SystemCapability.Ability.Form +**系统接口**:此接口为系统接口。 -**系统API**: 此接口为系统接口,三方应用不支持调用。 +**系统能力**:SystemCapability.Ability.Form **参数:** @@ -83,7 +87,7 @@ startAbility(want: Want): Promise<void> | 类型 | 说明 | | ------------ | ---------------------------------- | -| Promise<void< | Promise实例,返回接口调用是否成功的结果。 | +| Promise<void< | 无返回结果的Promise对象。 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-formhost.md b/zh-cn/application-dev/reference/apis/js-apis-formhost.md index 43d151bee751df7e975aefe7a67176d59b0e4b94..2bf67a31df5f7cf2fe43e40d48c9044e21a50b83 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-formhost.md +++ b/zh-cn/application-dev/reference/apis/js-apis-formhost.md @@ -1,11 +1,12 @@ # FormHost -FormHost模块提供了卡片使用方相关接口的能力,包括删除、释放、请求更新卡片,发送通知到指定卡片,获取卡片信息、状态等。 +FormHost模块提供了卡片使用方相关接口的能力,包括对使用方同一用户下安装的卡片进行删除、释放、请求更新,获取信息、状态等操作。 > **说明:** -> -> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 -> 本模块接口均为系统接口,三方应用不支持调用。 +> +> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> 从API version 9 开始不再维护,建议使用[FormHost](js-apis-app-form-formhost.md)替代。 +> 本模块接口均为系统接口。 ## 导入模块 @@ -13,17 +14,11 @@ FormHost模块提供了卡片使用方相关接口的能力,包括删除、释 import formHost from '@ohos.application.formHost'; ``` -## 权限 - -ohos.permission.REQUIRE_FORM - -ohos.permission.GET_BUNDLE_INFO_PRIVILEGED - ## deleteForm -deleteForm(formId: string, callback: AsyncCallback<void>): void; +deleteForm(formId: string, callback: AsyncCallback<void>): void -删除指定的卡片。调用此方法后,应用程序将无法使用该卡片,卡片管理器服务不再保留有关该卡片的信息。 +删除指定的卡片。调用此方法后,应用程序将无法使用该卡片,卡片管理器服务不再保留有关该卡片的信息。使用callback异步回调。 **需要权限**:ohos.permission.REQUIRE_FORM @@ -33,25 +28,25 @@ deleteForm(formId: string, callback: AsyncCallback<void>): void; | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------- | -| formId | string | 是 | 卡片标识 | -| callback | AsyncCallback<void> | 是 | callback形式返回结果 | +| formId | string | 是 | 卡片标识。 | +| callback | AsyncCallback<void> | 是 | 回调函数。当删除指定的卡片成功,error为undefined,否则为错误对象 | **示例:** - ```js - var formId = "12400633174999288"; - formHost.deleteForm(formId, (error, data) => { - if (error.code) { - console.log('formHost deleteForm, error:' + JSON.stringify(error)); - } - }); - ``` +```js +var formId = "12400633174999288"; +formHost.deleteForm(formId, (error, data) => { + if (error.code) { + console.log('formHost deleteForm, error:' + JSON.stringify(error)); + } +}); +``` ## deleteForm -deleteForm(formId: string): Promise<void>; +deleteForm(formId: string): Promise<void> -删除指定的卡片。调用此方法后,应用程序将无法使用该卡片,卡片管理器服务不再保留有关该卡片的信息。 +删除指定的卡片。调用此方法后,应用程序将无法使用该卡片,卡片管理器服务不再保留有关该卡片的信息。使用Promise异步回调。 **需要权限**:ohos.permission.REQUIRE_FORM @@ -59,32 +54,32 @@ deleteForm(formId: string): Promise<void>; **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------- | - | formId | string | 是 | 卡片标识 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formId | string | 是 | 卡片标识。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Promise<void> | 返回一个Promise,包含接口的结果 | +| 类型 | 说明 | +| -------- | -------- | +| Promise<void> | 无返回结果的Promise对象。 | **参数:** - ```js - var formId = "12400633174999288"; - formHost.deleteForm(formId).then(() => { - console.log('formHost deleteForm success'); - }).catch((error) => { - console.log('formHost deleteForm, error:' + JSON.stringify(error)); - }); - ``` +```js +var formId = "12400633174999288"; +formHost.deleteForm(formId).then(() => { + console.log('formHost deleteForm success'); +}).catch((error) => { + console.log('formHost deleteForm, error:' + JSON.stringify(error)); +}); +``` ## releaseForm -releaseForm(formId: string, callback: AsyncCallback<void>): void; +releaseForm(formId: string, callback: AsyncCallback<void>): void -释放指定的卡片。调用此方法后,应用程序将无法使用该卡片,但卡片管理器服务仍然保留有关该卡片的缓存信息和存储信息。 +释放指定的卡片。调用此方法后,应用程序将无法使用该卡片,但卡片管理器服务仍然保留有关该卡片的缓存信息和存储信息。使用callback异步回调。 **需要权限**:ohos.permission.REQUIRE_FORM @@ -94,25 +89,25 @@ releaseForm(formId: string, callback: AsyncCallback<void>): void; | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------- | -| formId | string | 是 | 卡片标识 | -| callback | AsyncCallback<void> | 是 | callback形式返回结果 | +| formId | string | 是 | 卡片标识。 | +| callback | AsyncCallback<void> | 是 | 回调函数。当释放指定的卡片成功,error为undefined;否则为错误对象。| **示例:** - ```js - var formId = "12400633174999288"; - formHost.releaseForm(formId, (error, data) => { - if (error.code) { - console.log('formHost releaseForm, error:' + JSON.stringify(error)); - } - }); - ``` +```js +var formId = "12400633174999288"; +formHost.releaseForm(formId, (error, data) => { + if (error.code) { + console.log('formHost releaseForm, error:' + JSON.stringify(error)); + } +}); +``` ## releaseForm -releaseForm(formId: string, isReleaseCache: boolean, callback: AsyncCallback<void>): void; +releaseForm(formId: string, isReleaseCache: boolean, callback: AsyncCallback<void>): void -释放指定的卡片。调用此方法后,应用程序将无法使用该卡片,卡片管理器服务保留有关该卡片的存储信息,可以选择是否保留缓存信息。 +释放指定的卡片。调用此方法后,应用程序将无法使用该卡片,卡片管理器服务保留有关该卡片的存储信息,可以选择是否保留缓存信息。使用callback异步回调。 **需要权限**:ohos.permission.REQUIRE_FORM @@ -122,26 +117,26 @@ releaseForm(formId: string, isReleaseCache: boolean, callback: AsyncCallback< | 参数名 | 类型 | 必填 | 说明 | | -------------- | ------ | ---- | ----------- | -| formId | string | 是 | 卡片标识 | -| isReleaseCache | boolean | 是 | 是否释放缓存 | -| callback | AsyncCallback<void> | 是 | callback形式返回结果 | +| formId | string | 是 | 卡片标识。 | +| isReleaseCache | boolean | 是 | 是否释放缓存。 | +| callback | AsyncCallback<void> | 是 | 回调函数。当释放指定的卡片成功,error为undefined;否则为错误对象。 | **示例:** - ```js - var formId = "12400633174999288"; - formHost.releaseForm(formId, true, (error, data) => { - if (error.code) { - console.log('formHost releaseForm, error:' + JSON.stringify(error)); - } - }); - ``` +```js +var formId = "12400633174999288"; +formHost.releaseForm(formId, true, (error, data) => { + if (error.code) { + console.log('formHost releaseForm, error:' + JSON.stringify(error)); + } +}); +``` ## releaseForm -releaseForm(formId: string, isReleaseCache?: boolean): Promise<void>; +releaseForm(formId: string, isReleaseCache?: boolean): Promise<void> -释放指定的卡片。调用此方法后,应用程序将无法使用该卡片,卡片管理器服务保留有关该卡片的存储信息,可以选择是否保留缓存信息。 +释放指定的卡片。调用此方法后,应用程序将无法使用该卡片,卡片管理器服务保留有关该卡片的存储信息,可以选择是否保留缓存信息。使用Promise异步回调。 **需要权限**:ohos.permission.REQUIRE_FORM @@ -149,33 +144,33 @@ releaseForm(formId: string, isReleaseCache?: boolean): Promise<void>; **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------------- | ------ | ---- | ----------- | - | formId | string | 是 | 卡片标识 | - | isReleaseCache | boolean | 否 | 是否释放缓存 | +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ------ | ---- | ----------- | +| formId | string | 是 | 卡片标识。 | +| isReleaseCache | boolean | 否 | 是否释放缓存。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Promise<void> | 返回一个Promise,包含接口的结果 | +| 类型 | 说明 | +| -------- | -------- | +| Promise<void> | 无返回结果的Promise对象。 | **示例:** - ```js - var formId = "12400633174999288"; - formHost.releaseForm(formId, true).then(() => { - console.log('formHost releaseForm success'); - }).catch((error) => { - console.log('formHost releaseForm, error:' + JSON.stringify(error)); - }); - ``` +```js +var formId = "12400633174999288"; +formHost.releaseForm(formId, true).then(() => { + console.log('formHost releaseForm success'); +}).catch((error) => { + console.log('formHost releaseForm, error:' + JSON.stringify(error)); +}); +``` ## requestForm -requestForm(formId: string, callback: AsyncCallback<void>): void; +requestForm(formId: string, callback: AsyncCallback<void>): void -请求卡片更新。 +请求卡片更新。使用callback异步回调。 **需要权限**:ohos.permission.REQUIRE_FORM @@ -185,25 +180,25 @@ requestForm(formId: string, callback: AsyncCallback<void>): void; | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------- | -| formId | string | 是 | 卡片标识 | -| callback | AsyncCallback<void> | 是 | callback形式返回结果 | +| formId | string | 是 | 卡片标识。 | +| callback | AsyncCallback<void> | 是 | 回调函数。当请求卡片更新成功,error为undefined;否则为错误对象。 | **示例:** - ```js - var formId = "12400633174999288"; - formHost.requestForm(formId, (error, data) => { - if (error.code) { - console.log('formHost requestForm, error:' + JSON.stringify(error)); - } - }); - ``` +```js +var formId = "12400633174999288"; +formHost.requestForm(formId, (error, data) => { + if (error.code) { + console.log('formHost requestForm, error:' + JSON.stringify(error)); + } +}); +``` ## requestForm -requestForm(formId: string): Promise<void>; +requestForm(formId: string): Promise<void> -请求卡片更新。 +请求卡片更新。使用Promise异步回调。 **需要权限**:ohos.permission.REQUIRE_FORM @@ -211,32 +206,32 @@ requestForm(formId: string): Promise<void>; **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------- | - | formId | string | 是 | 卡片标识 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formId | string | 是 | 卡片标识。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Promise<void> | 返回一个Promise,包含接口的结果 | +| 类型 | 说明 | +| -------- | -------- | +| Promise<void> | 无返回结果的Promise对象。 | **示例:** - ```js - var formId = "12400633174999288"; - formHost.requestForm(formId).then(() => { - console.log('formHost requestForm success'); - }).catch((error) => { - console.log('formHost requestForm, error:' + JSON.stringify(error)); - }); - ``` +```js +var formId = "12400633174999288"; +formHost.requestForm(formId).then(() => { + console.log('formHost requestForm success'); +}).catch((error) => { + console.log('formHost requestForm, error:' + JSON.stringify(error)); +}); +``` ## castTempForm -castTempForm(formId: string, callback: AsyncCallback<void>): void; +castTempForm(formId: string, callback: AsyncCallback<void>): void -将指定的临时卡片转换为普通卡片。 +将指定的临时卡片转换为普通卡片。使用callback异步回调。 **需要权限**:ohos.permission.REQUIRE_FORM @@ -246,25 +241,25 @@ castTempForm(formId: string, callback: AsyncCallback<void>): void; | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------- | -| formId | string | 是 | 卡片标识 | -| callback | AsyncCallback<void> | 是 | callback形式返回结果 | +| formId | string | 是 | 卡片标识。 | +| callback | AsyncCallback<void> | 是 | 回调函数。当将指定的临时卡片转换为普通卡片成功,err为undefined,否则为错误对象。 | **示例:** - ```js - var formId = "12400633174999288"; - formHost.castTempForm(formId, (error, data) => { - if (error.code) { - console.log('formHost castTempForm, error:' + JSON.stringify(error)); - } - }); - ``` +```js +var formId = "12400633174999288"; +formHost.castTempForm(formId, (error, data) => { + if (error.code) { + console.log('formHost castTempForm, error:' + JSON.stringify(error)); + } +}); +``` ## castTempForm -castTempForm(formId: string): Promise<void>; +castTempForm(formId: string): Promise<void> -将指定的临时卡片转换为普通卡片。 +将指定的临时卡片转换为普通卡片。使用Promise异步回调。 **需要权限**:ohos.permission.REQUIRE_FORM @@ -272,32 +267,32 @@ castTempForm(formId: string): Promise<void>; **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------- | - | formId | string | 是 | 卡片标识 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formId | string | 是 | 卡片标识。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Promise<void> | 返回一个Promise,包含接口的结果 | +| 类型 | 说明 | +| -------- | -------- | +| Promise<void> | 无返回结果的Promise对象。| **示例:** - ```js - var formId = "12400633174999288"; - formHost.castTempForm(formId).then(() => { - console.log('formHost castTempForm success'); - }).catch((error) => { - console.log('formHost castTempForm, error:' + JSON.stringify(error)); - }); - ``` +```js +var formId = "12400633174999288"; +formHost.castTempForm(formId).then(() => { + console.log('formHost castTempForm success'); +}).catch((error) => { + console.log('formHost castTempForm, error:' + JSON.stringify(error)); +}); +``` ## notifyVisibleForms -notifyVisibleForms(formIds: Array<string>, callback: AsyncCallback<void>): void; +notifyVisibleForms(formIds: Array<string>, callback: AsyncCallback<void>): void -向卡片框架发送通知以使指定的卡片可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。 +向卡片框架发送通知以使指定的卡片可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。使用callback异步回调。 **需要权限**:ohos.permission.REQUIRE_FORM @@ -307,25 +302,25 @@ notifyVisibleForms(formIds: Array<string>, callback: AsyncCallback<void | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------- | -| formIds | Array<string> | 是 | 卡片标识列表 | -| callback | AsyncCallback<void> | 是 | callback形式返回结果 | +| formIds | Array<string> | 是 | 卡片标识列表。 | +| callback | AsyncCallback<void> | 是 | 回调函数。当向卡片框架发送通知以使指定的卡片可见成功,err为undefined,否则为错误对象。 | **示例:** - ```js - var formId = ["12400633174999288"]; - formHost.notifyVisibleForms(formId, (error, data) => { - if (error.code) { - console.log('formHost notifyVisibleForms, error:' + JSON.stringify(error)); - } - }); - ``` +```js +var formId = ["12400633174999288"]; +formHost.notifyVisibleForms(formId, (error, data) => { + if (error.code) { + console.log('formHost notifyVisibleForms, error:' + JSON.stringify(error)); + } +}); +``` ## notifyVisibleForms -notifyVisibleForms(formIds: Array<string>): Promise<void>; +notifyVisibleForms(formIds: Array<string>): Promise<void> -向卡片框架发送通知以使指定的卡片可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。 +向卡片框架发送通知以使指定的卡片可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。使用Promise异步回调。 **需要权限**:ohos.permission.REQUIRE_FORM @@ -335,30 +330,30 @@ notifyVisibleForms(formIds: Array<string>): Promise<void>; | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------- | -| formIds | Array<string> | 是 | 卡片标识列表 | +| formIds | Array<string> | 是 | 卡片标识列表。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Promise<void> | 返回一个Promise,包含接口的结果 | +| 类型 | 说明 | +| -------- | -------- | +| Promise<void> | 无返回结果的Promise对象。 | **示例:** - ```js - var formId = ["12400633174999288"]; - formHost.notifyVisibleForms(formId).then(() => { - console.log('formHost notifyVisibleForms success'); - }).catch((error) => { - console.log('formHost notifyVisibleForms, error:' + JSON.stringify(error)); - }); - ``` +```js +var formId = ["12400633174999288"]; +formHost.notifyVisibleForms(formId).then(() => { + console.log('formHost notifyVisibleForms success'); +}).catch((error) => { + console.log('formHost notifyVisibleForms, error:' + JSON.stringify(error)); +}); +``` ## notifyInvisibleForms -notifyInvisibleForms(formIds: Array<string>, callback: AsyncCallback<void>): void; +notifyInvisibleForms(formIds: Array<string>, callback: AsyncCallback<void>): void -向卡片框架发送通知以使指定的卡片不可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。 +向卡片框架发送通知以使指定的卡片不可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。使用callback异步回调。 **需要权限**:ohos.permission.REQUIRE_FORM @@ -368,25 +363,25 @@ notifyInvisibleForms(formIds: Array<string>, callback: AsyncCallback<vo | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------- | -| formIds | Array<string> | 是 | 卡片标识列表 | -| callback | AsyncCallback<void> | 是 | callback形式返回结果 | +| formIds | Array<string> | 是 | 卡片标识列表。| +| callback | AsyncCallback<void> | 是 | 回调函数。当向卡片框架发送通知以使指定的卡片不可见成功,err为undefined,否则为错误对象。 | **示例:** - ```js - var formId = ["12400633174999288"]; - formHost.notifyInvisibleForms(formId, (error, data) => { - if (error.code) { - console.log('formHost notifyInvisibleForms, error:' + JSON.stringify(error)); - } - }); - ``` +```js +var formId = ["12400633174999288"]; +formHost.notifyInvisibleForms(formId, (error, data) => { + if (error.code) { + console.log('formHost notifyInvisibleForms, error:' + JSON.stringify(error)); + } +}); +``` ## notifyInvisibleForms -notifyInvisibleForms(formIds: Array<string>): Promise<void>; +notifyInvisibleForms(formIds: Array<string>): Promise<void> -向卡片框架发送通知以使指定的卡片不可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。 +向卡片框架发送通知以使指定的卡片不可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。使用Promise异步回调。 **需要权限**:ohos.permission.REQUIRE_FORM @@ -396,30 +391,30 @@ notifyInvisibleForms(formIds: Array<string>): Promise<void>; | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------- | -| formIds | Array<string> | 是 | 卡片标识列表 | +| formIds | Array<string> | 是 | 卡片标识列表。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Promise<void> | 返回一个Promise,包含接口的结果 | +| 类型 | 说明 | +| -------- | -------- | +| Promise<void> | 无返回结果的Promise对象。| **示例:** - ```js - var formId = ["12400633174999288"]; - formHost.notifyInvisibleForms(formId).then(() => { - console.log('formHost notifyInvisibleForms success'); - }).catch((error) => { - console.log('formHost notifyInvisibleForms, error:' + JSON.stringify(error)); - }); - ``` +```js +var formId = ["12400633174999288"]; +formHost.notifyInvisibleForms(formId).then(() => { + console.log('formHost notifyInvisibleForms success'); +}).catch((error) => { + console.log('formHost notifyInvisibleForms, error:' + JSON.stringify(error)); +}); +``` ## enableFormsUpdate -enableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void>): void; +enableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void>): void -向卡片框架发送通知以使指定的卡片可以更新。该方法调用成功后,卡片刷新状态设置为使能,卡片可以接收来自卡片提供方的更新。 +向卡片框架发送通知以使指定的卡片可以更新。该方法调用成功后,卡片刷新状态设置为使能,卡片可以接收来自卡片提供方的更新。使用callback异步回调。 **需要权限**:ohos.permission.REQUIRE_FORM @@ -429,25 +424,25 @@ enableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void& | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------- | -| formIds | Array<string> | 是 | 卡片标识列表 | -| callback | AsyncCallback<void> | 是 | callback形式返回结果 | +| formIds | Array<string> | 是 | 卡片标识列表。 | +| callback | AsyncCallback<void> | 是 | 回调函数。当向卡片框架发送通知以使指定的卡片可以更新成功,err为undefined,否则为错误对象。 | **示例:** - ```js - var formId = ["12400633174999288"]; - formHost.enableFormsUpdate(formId, (error, data) => { - if (error.code) { - console.log('formHost enableFormsUpdate, error:' + JSON.stringify(error)); - } - }); - ``` +```js +var formId = ["12400633174999288"]; +formHost.enableFormsUpdate(formId, (error, data) => { + if (error.code) { + console.log('formHost enableFormsUpdate, error:' + JSON.stringify(error)); + } +}); +``` ## enableFormsUpdate -enableFormsUpdate(formIds: Array<string>): Promise<void>; +enableFormsUpdate(formIds: Array<string>): Promise<void> -向卡片框架发送通知以使指定的卡片可以更新。该方法调用成功后,卡片刷新状态设置为使能,卡片可以接收来自卡片提供方的更新。 +向卡片框架发送通知以使指定的卡片可以更新。该方法调用成功后,卡片刷新状态设置为使能,卡片可以接收来自卡片提供方的更新。使用Promise异步回调。 **需要权限**:ohos.permission.REQUIRE_FORM @@ -457,30 +452,30 @@ enableFormsUpdate(formIds: Array<string>): Promise<void>; | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------- | -| formIds | Array<string> | 是 | 卡片标识列表 | +| formIds | Array<string> | 是 | 卡片标识列表。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Promise<void> | 返回一个Promise,包含接口的结果 | +| 类型 | 说明 | +| -------- | -------- | +| Promise<void> | 无返回结果的Promise对象。 | **示例:** - ```js - var formId = ["12400633174999288"]; - formHost.enableFormsUpdate(formId).then(() => { - console.log('formHost enableFormsUpdate success'); - }).catch((error) => { - console.log('formHost enableFormsUpdate, error:' + JSON.stringify(error)); - }); - ``` +```js +var formId = ["12400633174999288"]; +formHost.enableFormsUpdate(formId).then(() => { + console.log('formHost enableFormsUpdate success'); +}).catch((error) => { + console.log('formHost enableFormsUpdate, error:' + JSON.stringify(error)); +}); +``` ## disableFormsUpdate -disableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void>): void; +disableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void>): void -向卡片框架发送通知以使指定的卡片不可以更新。该方法调用成功后,卡片刷新状态设置为去使能,卡片不可以接收来自卡片提供方的更新。 +向卡片框架发送通知以使指定的卡片不可以更新。该方法调用成功后,卡片刷新状态设置为去使能,卡片不可以接收来自卡片提供方的更新。使用callback异步回调。 **需要权限**:ohos.permission.REQUIRE_FORM @@ -490,25 +485,25 @@ disableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------- | -| formIds | Array<string> | 是 | 卡片标识列表 | -| callback | AsyncCallback<void> | 是 | callback形式返回结果 | +| formIds | Array<string> | 是 | 卡片标识列表。 | +| callback | AsyncCallback<void> | 是 | 回调函数。当向卡片框架发送通知以使指定的卡片不可以更新成功,err为undefined,否则为错误对象。 | **示例:** - ```js - var formId = ["12400633174999288"]; - formHost.disableFormsUpdate(formId, (error, data) => { - if (error.code) { - console.log('formHost disableFormsUpdate, error:' + JSON.stringify(error)); - } - }); - ``` +```js +var formId = ["12400633174999288"]; +formHost.disableFormsUpdate(formId, (error, data) => { + if (error.code) { + console.log('formHost disableFormsUpdate, error:' + JSON.stringify(error)); + } +}); +``` ## disableFormsUpdate -disableFormsUpdate(formIds: Array<string>): Promise<void>; +disableFormsUpdate(formIds: Array<string>): Promise<void> -向卡片框架发送通知以使指定的卡片不可以更新。该方法调用成功后,卡片刷新状态设置为去使能,卡片不可以接收来自卡片提供方的更新。 +向卡片框架发送通知以使指定的卡片不可以更新。该方法调用成功后,卡片刷新状态设置为去使能,卡片不可以接收来自卡片提供方的更新。使用Promise异步回调。 **需要权限**:ohos.permission.REQUIRE_FORM @@ -518,30 +513,30 @@ disableFormsUpdate(formIds: Array<string>): Promise<void>; | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------- | -| formIds | Array<string> | 是 | 卡片标识列表 | +| formIds | Array<string> | 是 | 卡片标识列表。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Promise<void> | 返回一个Promise,包含接口的结果 | +| 类型 | 说明 | +| -------- | -------- | +| Promise<void> | 无返回结果的Promise对象。 | **示例:** - ```js - var formId = ["12400633174999288"]; - formHost.disableFormsUpdate(formId).then(() => { - console.log('formHost disableFormsUpdate success'); - }).catch((error) => { - console.log('formHost disableFormsUpdate, error:' + JSON.stringify(error)); - }); - ``` +```js +var formId = ["12400633174999288"]; +formHost.disableFormsUpdate(formId).then(() => { + console.log('formHost disableFormsUpdate success'); +}).catch((error) => { + console.log('formHost disableFormsUpdate, error:' + JSON.stringify(error)); +}); +``` ## isSystemReady -isSystemReady(callback: AsyncCallback<void>): void; +isSystemReady(callback: AsyncCallback<void>): void -检查系统是否准备好。 +检查系统是否准备好。使用callback异步回调。 **系统能力**:SystemCapability.Ability.Form @@ -549,49 +544,49 @@ isSystemReady(callback: AsyncCallback<void>): void; | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------- | -| callback | AsyncCallback<void> | 是 | callback形式返回结果 | +| callback | AsyncCallback<void> | 是 | 回调函数。当检查系统是否准备好成功,err为undefined,否则为错误对象。 | **示例:** - ```js - var formId = "12400633174999288"; - formHost.isSystemReady((error, data) => { - if (error.code) { - console.log('formHost isSystemReady, error:' + JSON.stringify(error)); - } - }); - ``` +```js +var formId = "12400633174999288"; +formHost.isSystemReady((error, data) => { + if (error.code) { + console.log('formHost isSystemReady, error:' + JSON.stringify(error)); + } +}); +``` ## isSystemReady -isSystemReady(): Promise<void>; +isSystemReady(): Promise<void> -检查系统是否准备好。 +检查系统是否准备好。使用Promise异步回调。 **系统能力**:SystemCapability.Ability.Form **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Promise<void> | 返回一个Promise,包含接口的结果 | +| 类型 | 说明 | +| -------- | -------- | +| Promise<void> | 无返回结果的Promise对象。 | **示例:** - ```js - var formId = "12400633174999288"; - formHost.isSystemReady().then(() => { - console.log('formHost isSystemReady success'); - }).catch((error) => { - console.log('formHost isSystemReady, error:' + JSON.stringify(error)); - }); - ``` +```js +var formId = "12400633174999288"; +formHost.isSystemReady().then(() => { + console.log('formHost isSystemReady success'); +}).catch((error) => { + console.log('formHost isSystemReady, error:' + JSON.stringify(error)); +}); +``` ## getAllFormsInfo -getAllFormsInfo(callback: AsyncCallback<Array<formInfo.FormInfo>>): void; +getAllFormsInfo(callback: AsyncCallback<Array<formInfo.FormInfo>>): void -获取设备上所有应用提供的卡片信息。 +获取设备上所有应用提供的卡片信息。使用callback异步回调。 **需要权限**:ohos.permission.GET_BUNDLE_INFO_PRIVILEGED @@ -599,28 +594,27 @@ getAllFormsInfo(callback: AsyncCallback<Array<formInfo.FormInfo>>): **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------- | - | callback | AsyncCallback<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | 是 | callback形式返回查询到的卡片信息 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| callback | AsyncCallback<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | 是 | 回调函数。当获取设备上所有应用提供的卡片信息成功,err为undefined,data为查询到的卡片信息;否则为错误对象。 | **示例:** - ```js - formHost.getAllFormsInfo((error, data) => { - if (error.code) { - console.log('formHost getAllFormsInfo, error:' + JSON.stringify(error)); - } else { - console.log('formHost getAllFormsInfo, data:' + JSON.stringify(data)); - } - }); - ``` +```js +formHost.getAllFormsInfo((error, data) => { + if (error.code) { + console.log('formHost getAllFormsInfo, error:' + JSON.stringify(error)); + } else { + console.log('formHost getAllFormsInfo, data:' + JSON.stringify(data)); + } +}); +``` ## getAllFormsInfo -getAllFormsInfo(): Promise<Array<formInfo.FormInfo>>; +getAllFormsInfo(): Promise<Array<formInfo.FormInfo>> - -获取设备上所有应用提供的卡片信息。 +获取设备上所有应用提供的卡片信息。使用Promise异步回调。 **需要权限**:ohos.permission.GET_BUNDLE_INFO_PRIVILEGED @@ -630,7 +624,7 @@ getAllFormsInfo(): Promise<Array<formInfo.FormInfo>>; | 类型 | 说明 | | :------------ | :---------------------------------- | -| Promise<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | Promise实例,用于获取异步返回查询到的卡片信息 | +| Promise<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | Promise对象,返回查询到的卡片信息。 | **示例:** @@ -644,10 +638,9 @@ getAllFormsInfo(): Promise<Array<formInfo.FormInfo>>; ## getFormsInfo -getFormsInfo(bundleName: string, callback: AsyncCallback<Array<formInfo.FormInfo>>): void; - +getFormsInfo(bundleName: string, callback: AsyncCallback<Array<formInfo.FormInfo>>): void -获取设备上指定应用程序提供的卡片信息。 +获取设备上指定应用程序提供的卡片信息。使用callback异步回调。 **需要权限**:ohos.permission.GET_BUNDLE_INFO_PRIVILEGED @@ -655,29 +648,28 @@ getFormsInfo(bundleName: string, callback: AsyncCallback<Array<formInfo.Fo **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------- | - | bundleName | string | 是 | 要查询的应用程序包名称 | - | callback | AsyncCallback<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | 是 | callback形式返回查询到的卡片信息 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| bundleName | string | 是 | 要查询的应用程序包名称。 | +| callback | AsyncCallback<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | 是 | 回调函数。当获取设备上指定应用程序提供的卡片信息成功,err为undefined,data为查询到的卡片信息;否则为错误对象。 | **示例:** - ```js - formHost.getFormsInfo("com.example.ohos.formjsdemo", (error, data) => { - if (error.code) { - console.log('formHost getFormsInfo, error:' + JSON.stringify(error)); - } else { - console.log('formHost getFormsInfo, data:' + JSON.stringify(data)); - } - }); - ``` +```js +formHost.getFormsInfo("com.example.ohos.formjsdemo", (error, data) => { + if (error.code) { + console.log('formHost getFormsInfo, error:' + JSON.stringify(error)); + } else { + console.log('formHost getFormsInfo, data:' + JSON.stringify(data)); + } +}); +``` ## getFormsInfo -getFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback<Array<formInfo.FormInfo>>): void; - +getFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback<Array<formInfo.FormInfo>>): void -获取设备上指定应用程序提供的卡片信息。 +获取设备上指定应用程序提供的卡片信息。使用callback异步回调。 **需要权限**:ohos.permission.GET_BUNDLE_INFO_PRIVILEGED @@ -685,30 +677,29 @@ getFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback< **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------- | - | bundleName | string | 是 | 要查询的应用程序包名称 | - | moduleName | string | 是 | 要查询的模块名称 | - | callback | AsyncCallback<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | 是 | callback形式返回查询到的卡片信息 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| bundleName | string | 是 | 要查询的应用程序包名称。 | +| moduleName | string | 是 | 要查询的模块名称。 | +| callback | AsyncCallback<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | 是 | 回调函数。当获取设备上指定应用程序提供的卡片信息成功,err为undefined,data为查询到的卡片信息;否则为错误对象。 | **示例:** - ```js - formHost.getFormsInfo("com.example.ohos.formjsdemo", "entry", (error, data) => { - if (error.code) { - console.log('formHost getFormsInfo, error:' + JSON.stringify(error)); - } else { - console.log('formHost getFormsInfo, data:' + JSON.stringify(data)); - } - }); - ``` +```js +formHost.getFormsInfo("com.example.ohos.formjsdemo", "entry", (error, data) => { + if (error.code) { + console.log('formHost getFormsInfo, error:' + JSON.stringify(error)); + } else { + console.log('formHost getFormsInfo, data:' + JSON.stringify(data)); + } +}); +``` ## getFormsInfo -getFormsInfo(bundleName: string, moduleName?: string): Promise<Array<formInfo.FormInfo>>; - +getFormsInfo(bundleName: string, moduleName?: string): Promise<Array<formInfo.FormInfo>> -获取设备上指定应用程序提供的卡片信息。 +获取设备上指定应用程序提供的卡片信息。使用Promise异步回调。 **需要权限**:ohos.permission.GET_BUNDLE_INFO_PRIVILEGED @@ -716,32 +707,32 @@ getFormsInfo(bundleName: string, moduleName?: string): Promise<Array<formI **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------- | - | bundleName | string | 是 | 要查询的应用程序包名称 | - | moduleName | string | 否 | 要查询的模块名称 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| bundleName | string | 是 | 要查询的应用程序包名称。 | +| moduleName | string | 否 | 要查询的模块名称。 | **返回值:** | 类型 | 说明 | | :------------ | :---------------------------------- | -| Promise<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | Promise实例,用于获取异步返回查询到的卡片信息 | +| Promise<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | Promise对象,返回查询到的卡片信息。 | **示例:** ```js formHost.getFormsInfo("com.example.ohos.formjsdemo", "entry").then((data) => { - console.log('formHost getFormsInfo, data:' + JSON.stringify(data)); + console.log('formHost getFormsInfo, data:' + JSON.stringify(data)); }).catch((error) => { - console.log('formHost getFormsInfo, error:' + JSON.stringify(error)); + console.log('formHost getFormsInfo, error:' + JSON.stringify(error)); }); ``` ## deleteInvalidForms -deleteInvalidForms(formIds: Array<string>, callback: AsyncCallback<number>): void; +deleteInvalidForms(formIds: Array<string>, callback: AsyncCallback<number>): void -根据列表删除应用程序的无效卡片。 +根据列表删除应用程序的无效卡片。使用callback异步回调。 **需要权限**:ohos.permission.REQUIRE_FORM @@ -751,27 +742,27 @@ deleteInvalidForms(formIds: Array<string>, callback: AsyncCallback<numb | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------- | -| formIds | Array<string> | 是 | 有效卡片标识列表 | -| callback | AsyncCallback<number> | 是 | callback形式返回删除的卡片个数 | +| formIds | Array<string> | 是 | 有效卡片标识列表。 | +| callback | AsyncCallback<number> | 是 | 回调函数。当根据列表删除应用程序的无效卡片成功,err为undefined,data为删除的卡片个数;否则为错误对象。 | **示例:** - ```js - var formIds = new Array("12400633174999288", "12400633174999289"); - formHost.deleteInvalidForms(formIds, (error, data) => { - if (error.code) { - console.log('formHost deleteInvalidForms, error:' + JSON.stringify(error)); - } else { - console.log('formHost deleteInvalidForms, data:' + JSON.stringify(data)); - } - }); - ``` +```js +var formIds = new Array("12400633174999288", "12400633174999289"); +formHost.deleteInvalidForms(formIds, (error, data) => { + if (error.code) { + console.log('formHost deleteInvalidForms, error:' + JSON.stringify(error)); + } else { + console.log('formHost deleteInvalidForms, data:' + JSON.stringify(data)); + } +}); +``` ## deleteInvalidForms -deleteInvalidForms(formIds: Array<string>): Promise<number>; +deleteInvalidForms(formIds: Array<string>): Promise<number> -根据列表删除应用程序的无效卡片。 +根据列表删除应用程序的无效卡片。使用Promise异步回调。 **需要权限**:ohos.permission.REQUIRE_FORM @@ -781,30 +772,30 @@ deleteInvalidForms(formIds: Array<string>): Promise<number>; | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------- | -| formIds | Array<string> | 是 | 有效卡片标识列表 | +| formIds | Array<string> | 是 | 有效卡片标识列表。 | **返回值:** | 类型 | 说明 | | :------------ | :---------------------------------- | -| Promise<number> | Promise实例,用于获取异步返回删除的卡片个数 | +| Promise<number> | Promise对象,返回删除的卡片个数。 | **示例:** - ```js - var formIds = new Array("12400633174999288", "12400633174999289"); - formHost.deleteInvalidForms(formIds).then((data) => { - console.log('formHost deleteInvalidForms, data:' + JSON.stringify(data)); - }).catch((error) => { - console.log('formHost deleteInvalidForms, error:' + JSON.stringify(error)); - }); - ``` +```js +var formIds = new Array("12400633174999288", "12400633174999289"); +formHost.deleteInvalidForms(formIds).then((data) => { + console.log('formHost deleteInvalidForms, data:' + JSON.stringify(data)); +}).catch((error) => { + console.log('formHost deleteInvalidForms, error:' + JSON.stringify(error)); +}); +``` ## acquireFormState -acquireFormState(want: Want, callback: AsyncCallback<formInfo.FormStateInfo>): void; +acquireFormState(want: Want, callback: AsyncCallback<formInfo.FormStateInfo>): void -获取卡片状态 +获取卡片状态。使用callback异步回调。 **需要权限**:ohos.permission.REQUIRE_FORM 和 ohos.permission.GET_BUNDLE_INFO_PRIVILEGED @@ -814,36 +805,36 @@ acquireFormState(want: Want, callback: AsyncCallback<formInfo.FormStateInfo&g | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------- | -| want | [Want](js-apis-application-Want.md) | 是 | 查询卡片状态时携带的want信息 | -| callback | AsyncCallback<[FormStateInfo](js-apis-formInfo.md#formstateinfo)> | 是 | callback形式返回卡片状态 | +| want | [Want](js-apis-application-Want.md) | 是 | 查询卡片状态时携带的want信息。 | +| callback | AsyncCallback<[FormStateInfo](js-apis-formInfo.md#formstateinfo)> | 是 | 回调函数。当获取卡片状态成功,err为undefined,data为获取到的卡片状态;否则为错误对象。 | **示例:** - ```js - var want = { - "deviceId": "", - "bundleName": "ohos.samples.FormApplication", - "abilityName": "FormAbility", - "parameters": { - "ohos.extra.param.key.module_name": "entry", - "ohos.extra.param.key.form_name": "widget", - "ohos.extra.param.key.form_dimension": 2 - } - }; - formHost.acquireFormState(want, (error, data) => { - if (error.code) { - console.log('formHost acquireFormState, error:' + JSON.stringify(error)); - } else { - console.log('formHost acquireFormState, data:' + JSON.stringify(data)); - } - }); - ``` +```js +var want = { + "deviceId": "", + "bundleName": "ohos.samples.FormApplication", + "abilityName": "FormAbility", + "parameters": { + "ohos.extra.param.key.module_name": "entry", + "ohos.extra.param.key.form_name": "widget", + "ohos.extra.param.key.form_dimension": 2 + } +}; +formHost.acquireFormState(want, (error, data) => { + if (error.code) { + console.log('formHost acquireFormState, error:' + JSON.stringify(error)); + } else { + console.log('formHost acquireFormState, data:' + JSON.stringify(data)); + } +}); +``` ## acquireFormState -acquireFormState(want: Want): Promise<formInfo.FormStateInfo>; +acquireFormState(want: Want): Promise<formInfo.FormStateInfo> -获取卡片状态。 +获取卡片状态。使用Promise异步回调。 **需要权限**:ohos.permission.REQUIRE_FORM 和 ohos.permission.GET_BUNDLE_INFO_PRIVILEGED @@ -853,39 +844,39 @@ acquireFormState(want: Want): Promise<formInfo.FormStateInfo>; | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------- | -| want | [Want](js-apis-application-Want.md) | 是 | 查询卡片状态时携带的want信息 | +| want | [Want](js-apis-application-Want.md) | 是 | 查询卡片状态时携带的want信息。 | **返回值:** | 类型 | 说明 | | :------------ | :---------------------------------- | -| Promise<[FormStateInfo](js-apis-formInfo.md#formstateinfo)> | Promise实例,用于返回卡片状态 | +| Promise<[FormStateInfo](js-apis-formInfo.md#formstateinfo)> | Promise对象,返回卡片状态。 | **示例:** - ```js - var want = { - "deviceId": "", - "bundleName": "ohos.samples.FormApplication", - "abilityName": "FormAbility", - "parameters": { - "ohos.extra.param.key.module_name": "entry", - "ohos.extra.param.key.form_name": "widget", - "ohos.extra.param.key.form_dimension": 2 - } - }; - formHost.acquireFormState(want).then((data) => { - console.log('formHost acquireFormState, data:' + JSON.stringify(data)); - }).catch((error) => { - console.log('formHost acquireFormState, error:' + JSON.stringify(error)); - }); - ``` +```js +var want = { + "deviceId": "", + "bundleName": "ohos.samples.FormApplication", + "abilityName": "FormAbility", + "parameters": { + "ohos.extra.param.key.module_name": "entry", + "ohos.extra.param.key.form_name": "widget", + "ohos.extra.param.key.form_dimension": 2 + } +}; +formHost.acquireFormState(want).then((data) => { + console.log('formHost acquireFormState, data:' + JSON.stringify(data)); +}).catch((error) => { + console.log('formHost acquireFormState, error:' + JSON.stringify(error)); +}); +``` ## on("formUninstall") -on(type: "formUninstall", callback: Callback<string>): void; +on(type: "formUninstall", callback: Callback<string>): void -订阅卡片卸载事件。 +订阅卡片卸载事件。使用callback异步回调。 **系统能力**:SystemCapability.Ability.Form @@ -893,23 +884,23 @@ on(type: "formUninstall", callback: Callback<string>): void; | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------- | -| type | string | 是 | 填写"formUninstall",表示卡片卸载事件 | -| callback | Callback<string> | 是 | 需要注册的事件回调方法 | +| type | string | 是 | 填写"formUninstall",表示卡片卸载事件。 | +| callback | Callback<string> | 是 | 回调函数。返回卡片标识。 | **示例:** - ```js - let callback = function(formId) { - console.log('formHost on formUninstall, formId:' + formId); - } - formHost.on("formUninstall", callback); - ``` +```js +let callback = function(formId) { + console.log('formHost on formUninstall, formId:' + formId); +} +formHost.on("formUninstall", callback); +``` ## off("formUninstall") -off(type: "formUninstall", callback?: Callback<string>): void; +off(type: "formUninstall", callback?: Callback<string>): void -取消订阅卡片卸载事件。 +取消订阅卡片卸载事件。使用callback异步回调。 **系统能力**:SystemCapability.Ability.Form @@ -917,23 +908,23 @@ off(type: "formUninstall", callback?: Callback<string>): void; | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------- | -| type | string | 是 | 填写"formUninstall",表示卡片卸载事件 | -| callback | Callback<string> | 否 | 需要注销的事件回调方法。缺省时,表示注销所有已注册事件回调 | +| type | string | 是 | 填写"formUninstall",表示卡片卸载事件。 | +| callback | Callback<string> | 否 | 回调函数。返回卡片标识。缺省时,表示注销所有已注册事件回调。 | **示例:** - ```js - let callback = function(formId) { - console.log('formHost on formUninstall, formId:' + formId); - } - formHost.off("formUninstall", callback); - ``` +```js +let callback = function(formId) { + console.log('formHost on formUninstall, formId:' + formId); +} +formHost.off("formUninstall", callback); +``` ## notifyFormsVisible -notifyFormsVisible(formIds: Array<string>, isVisible: boolean, callback: AsyncCallback<void>): void; +notifyFormsVisible(formIds: Array<string>, isVisible: boolean, callback: AsyncCallback<void>): void -通知卡片是否可见。 +通知卡片是否可见。使用callback异步回调。 **需要权限**:ohos.permission.REQUIRE_FORM @@ -943,26 +934,26 @@ notifyFormsVisible(formIds: Array<string>, isVisible: boolean, callback: A | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------- | -| formIds | Array<string> | 是 | 卡片标识列表 | -| isVisible | boolean | 是 | 是否可见 | -| callback | AsyncCallback<void> | 是 | callback形式返回结果 | +| formIds | Array<string> | 是 | 卡片标识列表。 | +| isVisible | boolean | 是 | 是否可见。 | +| callback | AsyncCallback<void> | 是 | 回调函数。当通知卡片是否可见成功,err为undefined,否则为错误对象。 | **示例:** - ```js - var formIds = new Array("12400633174999288", "12400633174999289"); - formHost.notifyFormsVisible(formIds, true, (error, data) => { - if (error.code) { - console.log('formHost notifyFormsVisible, error:' + JSON.stringify(error)); - } - }); - ``` +```js +var formIds = new Array("12400633174999288", "12400633174999289"); +formHost.notifyFormsVisible(formIds, true, (error, data) => { + if (error.code) { + console.log('formHost notifyFormsVisible, error:' + JSON.stringify(error)); + } +}); +``` ## notifyFormsVisible -notifyFormsVisible(formIds: Array<string>, isVisible: boolean): Promise<void>; +notifyFormsVisible(formIds: Array<string>, isVisible: boolean): Promise<void> -通知卡片是否可见。 +通知卡片是否可见。使用Promise异步回调。 **需要权限**:ohos.permission.REQUIRE_FORM @@ -970,33 +961,33 @@ notifyFormsVisible(formIds: Array<string>, isVisible: boolean): Promise< **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------- | - | formIds | Array<string> | 是 | 卡片标识列表 | - | isVisible | boolean | 是 | 是否可见 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formIds | Array<string> | 是 | 卡片标识列表。 | +| isVisible | boolean | 是 | 是否可见。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Promise<void> | 返回一个Promise,包含接口的结果 | +| 类型 | 说明 | +| -------- | -------- | +| Promise<void> | 无返回结果的Promise对象。 | **示例:** - ```js - var formIds = new Array("12400633174999288", "12400633174999289"); - formHost.notifyFormsVisible(formIds, true).then(() => { - console.log('formHost notifyFormsVisible success'); - }).catch((error) => { - console.log('formHost notifyFormsVisible, error:' + JSON.stringify(error)); - }); - ``` +```js +var formIds = new Array("12400633174999288", "12400633174999289"); +formHost.notifyFormsVisible(formIds, true).then(() => { + console.log('formHost notifyFormsVisible success'); +}).catch((error) => { + console.log('formHost notifyFormsVisible, error:' + JSON.stringify(error)); +}); +``` ## notifyFormsEnableUpdate -notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean, callback: AsyncCallback<void>): void; +notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean, callback: AsyncCallback<void>): void -通知卡片是否启用更新状态。 +通知卡片是否启用更新状态。使用callback异步回调。 **需要权限**:ohos.permission.REQUIRE_FORM @@ -1006,26 +997,26 @@ notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean, c | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------- | -| formIds | Array<string> | 是 | 卡片标识列表 | -| isEnableUpdate | boolean | 是 | 是否使能更新 | -| callback | AsyncCallback<void> | 是 | callback形式返回结果 | +| formIds | Array<string> | 是 | 卡片标识列表。 | +| isEnableUpdate | boolean | 是 | 是否使能更新。 | +| callback | AsyncCallback<void> | 是 | 回调函数。当通知卡片是否启用更新状态成功,err为undefined,否则为错误对象。 | **示例:** - ```js - var formIds = new Array("12400633174999288", "12400633174999289"); - formHost.notifyFormsEnableUpdate(formIds, true, (error, data) => { - if (error.code) { - console.log('formHost notifyFormsEnableUpdate, error:' + JSON.stringify(error)); - } - }); - ``` +```js +var formIds = new Array("12400633174999288", "12400633174999289"); +formHost.notifyFormsEnableUpdate(formIds, true, (error, data) => { + if (error.code) { + console.log('formHost notifyFormsEnableUpdate, error:' + JSON.stringify(error)); + } +}); +``` ## notifyFormsEnableUpdate -notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean): Promise<void>; +notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean): Promise<void> -通知卡片是否启用更新状态。 +通知卡片是否启用更新状态。使用Promise异步回调。 **需要权限**:ohos.permission.REQUIRE_FORM @@ -1035,32 +1026,30 @@ notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean): | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------- | - | formIds | Array<string> | 是 | 卡片标识列表 | - | isEnableUpdate | boolean | 是 | 是否使能更新 | + | formIds | Array<string> | 是 | 卡片标识列表。 | + | isEnableUpdate | boolean | 是 | 是否使能更新。 | **返回值:** | 类型 | 说明 | | -------- | -------- | - | Promise<void> | 返回一个Promise,包含接口的结果 | + | Promise<void> | 无返回结果的Promise对象。 | **示例:** - ```js - var formIds = new Array("12400633174999288", "12400633174999289"); - formHost.notifyFormsEnableUpdate(formIds, true).then(() => { - console.log('formHost notifyFormsEnableUpdate success'); - }).catch((error) => { - console.log('formHost notifyFormsEnableUpdate, error:' + JSON.stringify(error)); - }); - ``` +```js +var formIds = new Array("12400633174999288", "12400633174999289"); +formHost.notifyFormsEnableUpdate(formIds, true).then(() => { + console.log('formHost notifyFormsEnableUpdate success'); +}).catch((error) => { + console.log('formHost notifyFormsEnableUpdate, error:' + JSON.stringify(error)); +}); +``` ## shareForm9+ -shareForm(formId: string, deviceId: string, callback: AsyncCallback<void>): void; +shareForm(formId: string, deviceId: string, callback: AsyncCallback<void>): void -指定formId和远程设备Id进行卡片分享。 - -此接口为系统接口。 +指定formId和远程设备Id进行卡片分享。使用callback异步回调。 **需要权限**:ohos.permission.REQUIRE_FORM @@ -1070,29 +1059,27 @@ shareForm(formId: string, deviceId: string, callback: AsyncCallback<void>) | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------- | -| formId | string | 是 | 卡片标识 | -| deviceId | string | 是 | 远程设备标识 | -| callback | AsyncCallback<void> | 是 | callback形式返回结果 | +| formId | string | 是 | 卡片标识。 | +| deviceId | string | 是 | 远程设备标识。 | +| callback | AsyncCallback<void> | 是 | 回调函数。当指定formId和远程设备Id进行卡片分享成功,err为undefined,否则为错误对象。 | **示例:** - ```js - var formId = "12400633174999288"; - var deviceId = "EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2"; - formHost.shareForm(formId, deviceId, (error, data) => { - if (error.code) { - console.log('formHost shareForm, error:' + JSON.stringify(error)); - } - }); - ``` +```js +var formId = "12400633174999288"; +var deviceId = "EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2"; +formHost.shareForm(formId, deviceId, (error, data) => { + if (error.code) { + console.log('formHost shareForm, error:' + JSON.stringify(error)); + } +}); +``` ## shareForm9+ -shareForm(formId: string, deviceId: string): Promise<void>; +shareForm(formId: string, deviceId: string): Promise<void> -指定formId和远程设备Id进行卡片分享。 - -此接口为系统接口。 +指定formId和远程设备Id进行卡片分享。使用Promise异步回调。 **需要权限**:ohos.permission.REQUIRE_FORM @@ -1100,25 +1087,49 @@ shareForm(formId: string, deviceId: string): Promise<void>; **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------- | - | formId | string | 是 | 卡片标识 | - | deviceId | string | 是 | 远程设备标识 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formId | string | 是 | 卡片标识。 | +| deviceId | string | 是 | 远程设备标识。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Promise<void> | 返回一个Promise,包含接口的结果 | +| 类型 | 说明 | +| -------- | -------- | +| Promise<void> | 无返回结果的Promise对象。 | **参数:** - ```js - var formId = "12400633174999288"; - var deviceId = "EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2"; - formHost.shareForm(formId, deviceId).then(() => { - console.log('formHost shareForm success'); - }).catch((error) => { - console.log('formHost shareForm, error:' + JSON.stringify(error)); - }); - ``` \ No newline at end of file +```js +var formId = "12400633174999288"; +var deviceId = "EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2"; +formHost.shareForm(formId, deviceId).then(() => { + console.log('formHost shareForm success'); +}).catch((error) => { + console.log('formHost shareForm, error:' + JSON.stringify(error)); +}); +``` + +## notifyFormsPrivacyProtected9+ + +notifyFormsPrivacyProtected(formIds: Array, isProtected: boolean, callback: AsyncCallback): void + +**需要权限**:ohos.permission.REQUIRE_FORM + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------- | +| formId | string | 是 | 卡片标识。 | +| deviceId | string | 是 | 远程设备标识。 | + +```js +var formIds = new Array("12400633174999288", "12400633174999289"); +formHost.notifyFormsPrivacyProtected(formIds, true).then(() => { + console.log('formHost shareForm success'); +}).catch((error) => { + console.log('formHost shareForm, error:' + JSON.stringify(error)); +}); +``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-formprovider.md b/zh-cn/application-dev/reference/apis/js-apis-formprovider.md index 27d8b77bcc1c56e75bb9b5d3977cabbaf01dbfc8..5e8ff5742eb6792e9934d72c263215a09c3e2824 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-formprovider.md +++ b/zh-cn/application-dev/reference/apis/js-apis-formprovider.md @@ -1,10 +1,10 @@ # FormProvider -FormProvider模块提供了卡片提供方相关接口的能力,包括更新卡片,设置卡片更新时间,获取卡片信息,请求发布卡片等。 +FormProvider模块提供了卡片提供方相关接口的能力,开发者在开发卡片时,可通过该模块提供接口实现更新卡片,设置卡片更新时间,获取卡片信息,请求发布卡片等。 > **说明:** -> > 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> 从API version 9 开始不再维护,建议使用[FormProvider](js-apis-app-form-formprovider.md)替代。 ## 导入模块 @@ -12,27 +12,21 @@ FormProvider模块提供了卡片提供方相关接口的能力,包括更新 import formProvider from '@ohos.application.formProvider'; ``` -## 权限 - -无 - ## setFormNextRefreshTime -setFormNextRefreshTime(formId: string, minute: number, callback: AsyncCallback<void>): void; +setFormNextRefreshTime(formId: string, minute: number, callback: AsyncCallback<void>): void -设置指定卡片的下一次更新时间。 +设置指定卡片的下一次更新时间,使用callback异步回调。 -**系统能力:** - -SystemCapability.Ability.Form +**系统能力:** SystemCapability.Ability.Form **参数:** | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------------------------------------- | - | formId | string | 是 | 卡片标识 | - | minute | number | 是 | 指定多久之后更新,单位分钟,大于等于5 | - | callback | AsyncCallback<void> | 是 | callback形式返回启动结果 | + | formId | string | 是 | 卡片标识。 | + | minute | number | 是 | 指定多久之后更新,单位分钟,大于等于5。 | + | callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** @@ -47,26 +41,24 @@ SystemCapability.Ability.Form ## setFormNextRefreshTime -setFormNextRefreshTime(formId: string, minute: number): Promise<void>; +setFormNextRefreshTime(formId: string, minute: number): Promise<void> -设置指定卡片的下一次更新时间,以promise方式返回。 +设置指定卡片的下一次更新时间,使用Promise异步回调。 -**系统能力:** - -SystemCapability.Ability.Form +**系统能力:** SystemCapability.Ability.Form **参数:** | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------------------------------------- | - | formId | string | 是 | 卡片标识 | - | minute | number | 是 | 指定多久之后更新,单位分钟,大于等于5 | + | formId | string | 是 | 卡片标识。 | + | minute | number | 是 | 指定多久之后更新,单位分钟,大于等于5。 | **返回值:** | 类型 | 说明 | | ------------- | ---------------------------------- | - | Promise\ |Promise实例,用于获取异步返回结果。 | + | Promise\ | 无返回结果的Promise对象。 | **示例:** @@ -81,21 +73,19 @@ SystemCapability.Ability.Form ## updateForm -updateForm(formId: string, formBindingData: formBindingData.FormBindingData,callback: AsyncCallback<void>): void; - -更新指定的卡片。 +updateForm(formId: string, formBindingData: formBindingData.FormBindingData,callback: AsyncCallback<void>): void -**系统能力:** +更新指定的卡片,使用callback异步回调。 -SystemCapability.Ability.Form +**系统能力:** SystemCapability.Ability.Form **参数:** | 参数名 | 类型 | 必填 | 说明 | | ------ | ---------------------------------------------------------------------- | ---- | ---------------- | - | formId | string | 是 | 请求更新的卡片标识 | - | formBindingData | [FormBindingData](js-apis-formbindingdata.md#formbindingdata) | 是 | 用于更新的数据 | - | callback | AsyncCallback<void> | 是 | callback形式返回启动结果 | + | formId | string | 是 | 请求更新的卡片标识。 | + | formBindingData | [FormBindingData](js-apis-formbindingdata.md#formbindingdata) | 是 | 用于更新的数据。 | + | callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** @@ -112,26 +102,24 @@ SystemCapability.Ability.Form ## updateForm -updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Promise<void>; - -更新指定的卡片,以promise方式返回。 +updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Promise<void> -**系统能力:** +更新指定的卡片,使用Promise异步回调。 -SystemCapability.Ability.Form +**系统能力:** SystemCapability.Ability.Form **参数:** | 参数名 | 类型 | 必填 | 说明 | | ------ | ---------------------------------------------------------------------- | ---- | ---------------- | - | formId | string | 是 | 请求更新的卡片标识 | - | formBindingData | [FormBindingData](js-apis-formbindingdata.md#formbindingdata) | 是 | 用于更新的数据 | + | formId | string | 是 | 请求更新的卡片标识。 | + | formBindingData | [FormBindingData](js-apis-formbindingdata.md#formbindingdata) | 是 | 用于更新的数据。 | **返回值:** | 类型 | 说明 | | -------------- | ----------------------------------- | -| Promise\ | Promise实例,用于获取异步返回结果。 | +| Promise\ | 无返回结果的Promise对象。 | **示例:** @@ -148,9 +136,9 @@ SystemCapability.Ability.Form ## getFormsInfo9+ -getFormsInfo(callback: AsyncCallback<Array<formInfo.FormInfo>>): void; +getFormsInfo(callback: AsyncCallback<Array<formInfo.FormInfo>>): void -获取设备上当前应用程序的卡片信息。 +获取设备上当前应用程序的卡片信息,使用callback异步回调。 **系统能力:** SystemCapability.Ability.Form @@ -158,7 +146,7 @@ getFormsInfo(callback: AsyncCallback<Array<formInfo.FormInfo>>): voi | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------- | -| callback | AsyncCallback<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | 是 | callback形式返回查询到的卡片信息。 | +| callback | AsyncCallback<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | 是 | 回调函数。返回查询到的卡片信息。 | **示例:** @@ -173,9 +161,9 @@ formProvider.getFormsInfo((error, data) => { ``` ## getFormsInfo9+ -getFormsInfo(filter: formInfo.FormInfoFilter, callback: AsyncCallback<Array<formInfo.FormInfo>>): void; +getFormsInfo(filter: formInfo.FormInfoFilter, callback: AsyncCallback<Array<formInfo.FormInfo>>): void -获取设备上当前应用程序的卡片信息。 +获取设备上当前应用程序的卡片信息,并筛选符合条件的信息,使用callback异步回调。 **系统能力:** SystemCapability.Ability.Form @@ -183,14 +171,15 @@ getFormsInfo(filter: formInfo.FormInfoFilter, callback: AsyncCallback<Array&l | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------- | -| filter | [formInfo.FormInfoFilter](./js-apis-formInfo.md#forminfofilter) | 是 | 过滤卡片信息 | -| callback | AsyncCallback<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | 是 | callback形式返回查询到的卡片信息。 | +| filter | [formInfo.FormInfoFilter](./js-apis-formInfo.md#forminfofilter) | 是 | 卡片信息过滤器。 | +| callback | AsyncCallback<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | 是 | 回调函数。返回查询到符合条件的卡片信息。 | **示例:** ```js import formInfo from '@ohos.application.formInfo'; const filter : formInfo.FormInfoFilter = { + // get info of forms belong to module entry. moduleName : "entry" }; formProvider.getFormsInfo(filter, (error, data) => { @@ -204,9 +193,9 @@ formProvider.getFormsInfo(filter, (error, data) => { ## getFormsInfo9+ -getFormsInfo(filter?: formInfo.FormInfoFilter): Promise<Array<formInfo.FormInfo>>; +getFormsInfo(filter?: formInfo.FormInfoFilter): Promise<Array<formInfo.FormInfo>> -获取设备上当前应用程序的卡片信息。 +获取设备上当前应用程序的卡片信息,使用Promise异步回调。 **系统能力:** SystemCapability.Ability.Form @@ -214,19 +203,20 @@ getFormsInfo(filter?: formInfo.FormInfoFilter): Promise<Array<formInfo.For | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------- | -| filter | [formInfo.FormInfoFilter](./js-apis-formInfo.md) | 否 | 过滤卡片信息 | +| filter | [formInfo.FormInfoFilter](./js-apis-formInfo.md) | 否 | 卡片信息过滤器。 | **返回值:** | 类型 | 说明 | | :------------ | :---------------------------------- | -| Promise<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | Promise实例,用于获取异步返回查询到的卡片信息。 | +| Promise<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | Promise对象。返回查询到符合条件的卡片信息。 | **示例:** ```js import formInfo from '@ohos.application.formInfo'; const filter : formInfo.FormInfoFilter = { + // get info of forms belong to module entry. moduleName : "entry" }; formProvider.getFormsInfo(filter).then((data) => { @@ -238,21 +228,21 @@ formProvider.getFormsInfo(filter).then((data) => { ## requestPublishForm9+ -requestPublishForm(want: Want, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback\): void; +requestPublishForm(want: Want, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback\): void -请求发布一张卡片到使用方。 +请求发布一张卡片到使用方。使用方通常为桌面。 **系统能力:** SystemCapability.Ability.Form -**系统API**: 此接口为系统接口,三方应用不支持调用。 +**系统接口**: 此接口为系统接口。 **参数:** | 参数名 | 类型 | 必填 | 说明 | | ------ | ---------------------------------------------------------------------- | ---- | ---------------- | -| want | [Want](js-apis-application-Want.md) | 是 | abilityName: 目标卡片ability
parameters:
"ohos.extra.param.key.form_dimension"
"ohos.extra.param.key.form_name"
"ohos.extra.param.key.module_name" | -| formBindingData | [FormBindingData](js-apis-formbindingdata.md#formbindingdata) | 是 | 用于创建卡片的数据 | -| callback | AsyncCallback<string> | 是 | callback形式返回卡片标识 | +| want | [Want](js-apis-application-Want.md) | 是 | 发布请求。需包含以下字段。
abilityName: 目标卡片ability
parameters:
"ohos.extra.param.key.form_dimension"
"ohos.extra.param.key.form_name"
"ohos.extra.param.key.module_name" | +| formBindingData | [FormBindingData](js-apis-formbindingdata.md#formbindingdata) | 是 | 创建卡片的数据。 | +| callback | AsyncCallback<string> | 是 | 回调函数。返回卡片标识。 | **示例:** @@ -278,20 +268,20 @@ requestPublishForm(want: Want, formBindingData: formBindingData.FormBindingData, ## requestPublishForm9+ -requestPublishForm(want: Want, callback: AsyncCallback<string>): void; +requestPublishForm(want: Want, callback: AsyncCallback<string>): void -请求发布一张卡片到使用方。 +请求发布一张卡片到使用方。使用方通常为桌面。 **系统能力:** SystemCapability.Ability.Form -**系统API**: 此接口为系统接口,三方应用不支持调用。 +**系统接口**: 此接口为系统接口。 **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------------------- | ---- | ------------------------------------------------------------ | -| want | [Want](js-apis-application-Want.md) | 是 | abilityName: 目标卡片ability
parameters:
"ohos.extra.param.key.form_dimension"
"ohos.extra.param.key.form_name"
"ohos.extra.param.key.module_name" | -| callback | AsyncCallback<string> | 是 | callback形式返回卡片标识 | +| want | [Want](js-apis-application-Want.md) | 是 | 发布请求。需包含以下字段。
abilityName: 目标卡片ability
parameters:
"ohos.extra.param.key.form_dimension"
"ohos.extra.param.key.form_name"
"ohos.extra.param.key.module_name" | +| callback | AsyncCallback<string> | 是 | 回调函数。返回卡片标识。 | **示例:** @@ -315,26 +305,26 @@ requestPublishForm(want: Want, callback: AsyncCallback<string>): void; ## requestPublishForm9+ -requestPublishForm(want: Want, formBindingData?: formBindingData.FormBindingData): Promise<string>; +requestPublishForm(want: Want, formBindingData?: formBindingData.FormBindingData): Promise<string> -请求发布一张卡片到使用方。 +请求发布一张卡片到使用方。使用方通常为桌面。 **系统能力:** SystemCapability.Ability.Form -**系统API**: 此接口为系统接口,三方应用不支持调用。 +**系统接口**: 此接口为系统接口。 **参数:** | 参数名 | 类型 | 必填 | 说明 | | --------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| want | [Want](js-apis-application-Want.md) | 是 | abilityName: 目标卡片ability
parameters:
"ohos.extra.param.key.form_dimension"
"ohos.extra.param.key.form_name"
"ohos.extra.param.key.module_name" | -| formBindingData | [FormBindingData](js-apis-formbindingdata.md#formbindingdata) | 否 | 用于创建卡片的数据 | +| want | [Want](js-apis-application-Want.md) | 是 | 发布请求。需包含以下字段。
abilityName: 目标卡片ability
parameters:
"ohos.extra.param.key.form_dimension"
"ohos.extra.param.key.form_name"
"ohos.extra.param.key.module_name" | +| formBindingData | [FormBindingData](js-apis-formbindingdata.md#formbindingdata) | 否 | 创建卡片的数据。 | **返回值:** | 类型 | 说明 | | :------------ | :---------------------------------- | -| Promise<string> | Promise实例,用于返回卡片标识。 | +| Promise<string> | Promise对象。返回卡片标识。 | **示例:** @@ -356,19 +346,19 @@ requestPublishForm(want: Want, formBindingData?: formBindingData.FormBindingData ## isRequestPublishFormSupported9+ -isRequestPublishFormSupported(callback: AsyncCallback<boolean>): void; +isRequestPublishFormSupported(callback: AsyncCallback<boolean>): void 查询是否支持发布一张卡片到使用方。 -**系统能力:** SystemCapability.Ability.Form +**系统接口**: 此接口为系统接口。 -**系统API**: 此接口为系统接口,三方应用不支持调用。 +**系统能力:** SystemCapability.Ability.Form **参数:** | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------- | -| callback | AsyncCallback<boolean> | 是 | callback形式返回是否支持发布一张卡片到使用方 | +| callback | AsyncCallback<boolean> | 是 | 回调函数。返回是否支持发布一张卡片到使用方。| **示例:** @@ -400,19 +390,19 @@ formProvider.isRequestPublishFormSupported((error, isSupported) => { ## isRequestPublishFormSupported9+ -isRequestPublishFormSupported(): Promise<boolean>; +isRequestPublishFormSupported(): Promise<boolean> 查询是否支持发布一张卡片到使用方。 -**系统能力:** SystemCapability.Ability.Form +**系统接口**: 此接口为系统接口。 -**系统API**: 此接口为系统接口,三方应用不支持调用。 +**系统能力:** SystemCapability.Ability.Form **返回值:** | 类型 | 说明 | | :------------ | :---------------------------------- | -| Promise<boolean> | Promise实例,用于获取异步返回是否支持发布一张卡片到使用方 | +| Promise<boolean> | Promise对象。返回是否支持发布一张卡片到使用方。 | **示例:** diff --git a/zh-cn/application-dev/reference/errorcodes/errcode-form.md b/zh-cn/application-dev/reference/errorcodes/errcode-form.md new file mode 100644 index 0000000000000000000000000000000000000000..37168b50968d92bfab046622719772aebaf95560 --- /dev/null +++ b/zh-cn/application-dev/reference/errorcodes/errcode-form.md @@ -0,0 +1,141 @@ +# 卡片错误码 + +## 16500001 内部错误 + +**错误信息** + +Internal Error. + +**错误描述** + +Malloc等内核通用错误。 + +**可能原因** + +当前内存不足。 + +**处理步骤** + +内存不足,需要分析整个进程的内存占用情况,是否有内存泄露的情况。 + +## 16500050 进程间通信失败 + +**错误信息** + +An IPC connection error happened. + +**错误描述** + +系统内为执行当前请求进行必要进程间通信时出错,系统会报此错误码。 + +**可能原因** + +当调用接口传入的入参过大时,进程间通信对数据校验失败。 + +**处理步骤** + +确认入参是否过长。 + +## 16500060 连接服务失败 + +**错误信息** + +A service connection error happened, please try again later. + +**错误描述** + +系统内为执行当前请求连接必要服务完成请求时出错,系统会报此错误码。 + +**可能原因** + +当前服务繁忙,或服务出现异常。 + +**处理步骤** + +待服务重启后重试。 + +## 16500100 获取卡片配置信息失败 + +**错误信息** + +Failed to obtain configuration information. + +**错误描述** + +系统内为执行当前请求获取卡片相关配置信息时出错,系统会报此错误码。 + +**可能原因** + +卡片相关配置信息字段缺失或非法。 + +**处理步骤** + +确认并验证卡片配置信息正确性。 + +## 16501000 内部错误 + +**错误信息** + +A functional error occurred. + +**错误描述** + +系统内为执行当前请求时发生内部错误,系统会报此错误码。 + +## 16501001 卡片ID不存在 + +**错误信息** + +The ID of the form to be operated does not exist. + +**错误描述** + +当请求所指定的卡片ID未找到或不存在时,系统会报此错误码。 + +**可能原因** + +指定卡片ID不存在,或传入无效卡片ID。 + +**处理步骤** + +检查卡片ID的有效性。 + +## 16501002 卡片数量达到上限 + +**错误信息** + +The number of forms exceeds the upper bound. + +**错误描述** + +当卡片数量已达到上限时继续请求添加卡片,系统会报此错误码。 + +**可能原因** + +当前卡片数量已达到上限,但仍继续请求添加卡片。 + +**处理步骤** + +删除不必要卡片后再请求添加。 + +## 16501003 无法操作指定卡片 + +**错误信息** + +The form can not be operated by the current application. + +**错误描述** + +当前应用无法对指定卡片进行操作时,系统会报此错误码。 + +**可能原因** + +指定的卡片非当前应用所有。 + +**处理步骤** + +1. 检查传入卡片ID所有权 +2. 升级权限为SystemApp + + +