Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
1743c481
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
1743c481
编写于
8月 29, 2023
作者:
X
xuzhihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Bugfix: arkts整改
Signed-off-by:
N
xuzhihao
<
xuzhihao16@huawei.com
>
上级
9e7839e2
变更
16
显示空白变更内容
内联
并排
Showing
16 changed file
with
1020 addition
and
756 deletion
+1020
-756
en/application-dev/application-models/arkts-ui-widget-event-formextensionability.md
...tion-models/arkts-ui-widget-event-formextensionability.md
+5
-8
en/application-dev/reference/apis/js-apis-app-form-formBindingData.md
...on-dev/reference/apis/js-apis-app-form-formBindingData.md
+8
-5
en/application-dev/reference/apis/js-apis-notificationManager.md
...ication-dev/reference/apis/js-apis-notificationManager.md
+259
-178
en/application-dev/reference/apis/js-apis-system-notification.md
...ication-dev/reference/apis/js-apis-system-notification.md
+19
-13
zh-cn/application-dev/application-models/arkts-ui-widget-event-formextensionability.md
...tion-models/arkts-ui-widget-event-formextensionability.md
+5
-8
zh-cn/application-dev/reference/apis/js-apis-app-form-formBindingData.md
...on-dev/reference/apis/js-apis-app-form-formBindingData.md
+11
-6
zh-cn/application-dev/reference/apis/js-apis-app-form-formExtensionAbility.md
...v/reference/apis/js-apis-app-form-formExtensionAbility.md
+35
-19
zh-cn/application-dev/reference/apis/js-apis-app-form-formHost.md
...plication-dev/reference/apis/js-apis-app-form-formHost.md
+100
-92
zh-cn/application-dev/reference/apis/js-apis-app-form-formProvider.md
...ation-dev/reference/apis/js-apis-app-form-formProvider.md
+66
-35
zh-cn/application-dev/reference/apis/js-apis-application-formBindingData.md
...dev/reference/apis/js-apis-application-formBindingData.md
+7
-5
zh-cn/application-dev/reference/apis/js-apis-application-formHost.md
...cation-dev/reference/apis/js-apis-application-formHost.md
+92
-85
zh-cn/application-dev/reference/apis/js-apis-application-formProvider.md
...on-dev/reference/apis/js-apis-application-formProvider.md
+27
-12
zh-cn/application-dev/reference/apis/js-apis-inner-application-formExtensionContext.md
...ce/apis/js-apis-inner-application-formExtensionContext.md
+107
-98
zh-cn/application-dev/reference/apis/js-apis-inner-application-missionSnapshot.md
...ference/apis/js-apis-inner-application-missionSnapshot.md
+1
-1
zh-cn/application-dev/reference/apis/js-apis-notificationManager.md
...ication-dev/reference/apis/js-apis-notificationManager.md
+259
-178
zh-cn/application-dev/reference/apis/js-apis-system-notification.md
...ication-dev/reference/apis/js-apis-system-notification.md
+19
-13
未找到文件。
en/application-dev/application-models/arkts-ui-widget-event-formextensionability.md
浏览文件 @
1743c481
...
@@ -42,18 +42,15 @@ On the widget page, the **postCardAction** API can be used to trigger a message
...
@@ -42,18 +42,15 @@ On the widget page, the **postCardAction** API can be used to trigger a message
import
formProvider
from
'
@ohos.app.form.formProvider
'
;
import
formProvider
from
'
@ohos.app.form.formProvider
'
;
export
default
class
EntryFormAbility
extends
FormExtensionAbility
{
export
default
class
EntryFormAbility
extends
FormExtensionAbility
{
onFormEvent
(
formId
,
message
)
{
onFormEvent
(
formId
:
string
,
message
:
string
)
{
// Called when a specified message event defined by the form provider is triggered.
// Called when a specified message event defined by the form provider is triggered.
console
.
info
(
`FormAbility onEvent, formId =
${
formId
}
, message:
${
JSON
.
stringify
(
message
)}
`
);
console
.
info
(
`FormAbility onEvent, formId =
${
formId
}
, message:
${
JSON
.
stringify
(
message
)}
`
);
let
formData
=
{
let
formData
=
new
Map
<
Object
,
string
>
();
'
title
'
:
'
Title Update Success.
'
,
// Matches the widget layout.
formData
.
set
(
'
title
'
,
'
Title Update.
'
);
// It matches the widget layout.
'
detail
'
:
'
Detail Update Success.
'
,
// Matches the widget layout.
formData
.
set
(
'
detail
'
,
'
Description update success.
'
);
// It matches the widget layout.
};
let
formInfo
=
formBindingData
.
createFormBindingData
(
formData
)
let
formInfo
=
formBindingData
.
createFormBindingData
(
formData
)
formProvider
.
updateForm
(
formId
,
formInfo
).
then
((
data
)
=>
{
formProvider
.
updateForm
(
formId
,
formInfo
).
then
((
data
)
=>
{
console
.
info
(
'
FormAbility updateForm success.
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
FormAbility updateForm success.
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
console
.
error
(
'
FormAbility updateForm failed:
'
+
JSON
.
stringify
(
error
));
})
})
}
}
...
...
en/application-dev/reference/apis/js-apis-app-form-formBindingData.md
浏览文件 @
1743c481
...
@@ -66,11 +66,14 @@ import fs from '@ohos.file.fs';
...
@@ -66,11 +66,14 @@ import fs from '@ohos.file.fs';
try
{
try
{
let
fd
=
fs
.
openSync
(
'
/path/to/form.png
'
);
let
fd
=
fs
.
openSync
(
'
/path/to/form.png
'
);
let
obj
=
{
'
temperature
'
:
'
21°
'
,
let
createFormBindingDataParam
=
new
Map
<
Object
,
string
|
object
>
();
'
formImages
'
:
{
'
image
'
:
fd
}
let
formImagesParam
=
new
Map
<
Object
,
object
>
();
};
formImagesParam
.
set
(
'
image
'
,
fd
);
formBindingData
.
createFormBindingData
(
obj
);
createFormBindingDataParam
.
set
(
"
name
"
,
'
21°
'
);
createFormBindingDataParam
.
set
(
'
formImages
'
,
formImagesParam
);
formBindingData
.
createFormBindingData
(
createFormBindingDataParam
);
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
`catch error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
console
.
error
(
`catch error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
}
}
...
...
en/application-dev/reference/apis/js-apis-notificationManager.md
浏览文件 @
1743c481
...
@@ -10,6 +10,7 @@ The **notificationManager** module provides notification management capabilities
...
@@ -10,6 +10,7 @@ The **notificationManager** module provides notification management capabilities
```
ts
```
ts
import
notificationManager
from
'
@ohos.notificationManager
'
;
import
notificationManager
from
'
@ohos.notificationManager
'
;
import
Base
from
'
@ohos.base
'
;
```
```
## notificationManager.publish
## notificationManager.publish
...
@@ -45,7 +46,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -45,7 +46,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```
ts
```
ts
// publish callback
// publish callback
function
publishCallback
(
err
)
{
function
publishCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`publish failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`publish failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -155,7 +156,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -155,7 +156,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```
ts
```
ts
// publish callback
// publish callback
function
publishCallback
(
err
)
{
function
publishCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`publish failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`publish failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -163,7 +164,7 @@ function publishCallback(err) {
...
@@ -163,7 +164,7 @@ function publishCallback(err) {
}
}
}
}
// User ID
// User ID
let
userId
=
1
;
let
userId
:
number
=
1
;
// NotificationRequest object
// NotificationRequest object
let
notificationRequest
:
notificationManager
.
NotificationRequest
=
{
let
notificationRequest
:
notificationManager
.
NotificationRequest
=
{
id
:
1
,
id
:
1
,
...
@@ -228,7 +229,7 @@ let notificationRequest: notificationManager.NotificationRequest = {
...
@@ -228,7 +229,7 @@ let notificationRequest: notificationManager.NotificationRequest = {
}
}
};
};
let
userId
=
1
;
let
userId
:
number
=
1
;
notificationManager
.
publish
(
notificationRequest
,
userId
).
then
(()
=>
{
notificationManager
.
publish
(
notificationRequest
,
userId
).
then
(()
=>
{
console
.
info
(
"
publish success
"
);
console
.
info
(
"
publish success
"
);
...
@@ -267,7 +268,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -267,7 +268,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```
ts
```
ts
// cancel callback
// cancel callback
function
cancelCallback
(
err
)
{
function
cancelCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`cancel failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`cancel failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -341,7 +342,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -341,7 +342,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```
ts
```
ts
// cancel callback
// cancel callback
function
cancelCallback
(
err
)
{
function
cancelCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`cancel failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`cancel failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -379,7 +380,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -379,7 +380,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```
ts
```
ts
// cancel callback
// cancel callback
function
cancelAllCallback
(
err
)
{
function
cancelAllCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`cancelAll failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`cancelAll failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -449,7 +450,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -449,7 +450,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```
ts
```
ts
// addSlot callback
// addSlot callback
function
addSlotCallBack
(
err
)
{
function
addSlotCallBack
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`addSlot failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`addSlot failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -457,7 +458,7 @@ function addSlotCallBack(err) {
...
@@ -457,7 +458,7 @@ function addSlotCallBack(err) {
}
}
}
}
// NotificationSlot object
// NotificationSlot object
let
notificationSlot
=
{
let
notificationSlot
:
notificationManager
.
NotificationSlot
=
{
type
:
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
type
:
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
};
};
notificationManager
.
addSlot
(
notificationSlot
,
addSlotCallBack
);
notificationManager
.
addSlot
(
notificationSlot
,
addSlotCallBack
);
...
@@ -496,7 +497,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -496,7 +497,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```
ts
```
ts
// NotificationSlot object
// NotificationSlot object
let
notificationSlot
=
{
let
notificationSlot
:
notificationManager
.
NotificationSlot
=
{
type
:
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
type
:
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
};
};
notificationManager
.
addSlot
(
notificationSlot
).
then
(()
=>
{
notificationManager
.
addSlot
(
notificationSlot
).
then
(()
=>
{
...
@@ -534,7 +535,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -534,7 +535,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```
ts
```
ts
// addSlot callback
// addSlot callback
function
addSlotCallBack
(
err
)
{
function
addSlotCallBack
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`addSlot failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`addSlot failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -611,7 +612,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -611,7 +612,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```
ts
```
ts
// addSlots callback
// addSlots callback
function
addSlotsCallBack
(
err
)
{
function
addSlotsCallBack
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`addSlots failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`addSlots failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -619,11 +620,11 @@ function addSlotsCallBack(err) {
...
@@ -619,11 +620,11 @@ function addSlotsCallBack(err) {
}
}
}
}
// NotificationSlot object
// NotificationSlot object
let
notificationSlot
=
{
let
notificationSlot
:
notificationManager
.
NotificationSlot
=
{
type
:
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
type
:
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
};
};
// NotificationSlotArray object
// NotificationSlotArray object
let
notificationSlotArray
=
new
Array
();
let
notificationSlotArray
:
notificationManager
.
NotificationSlot
[]
=
new
Array
();
notificationSlotArray
[
0
]
=
notificationSlot
;
notificationSlotArray
[
0
]
=
notificationSlot
;
notificationManager
.
addSlots
(
notificationSlotArray
,
addSlotsCallBack
);
notificationManager
.
addSlots
(
notificationSlotArray
,
addSlotsCallBack
);
...
@@ -662,11 +663,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -662,11 +663,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```
ts
```
ts
// NotificationSlot object
// NotificationSlot object
let
notificationSlot
=
{
let
notificationSlot
:
notificationManager
.
NotificationSlot
=
{
type
:
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
type
:
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
};
};
// NotificationSlotArray object
// NotificationSlotArray object
let
notificationSlotArray
=
new
Array
();
let
notificationSlotArray
:
notificationManager
.
NotificationSlot
[]
=
new
Array
();
notificationSlotArray
[
0
]
=
notificationSlot
;
notificationSlotArray
[
0
]
=
notificationSlot
;
notificationManager
.
addSlots
(
notificationSlotArray
).
then
(()
=>
{
notificationManager
.
addSlots
(
notificationSlotArray
).
then
(()
=>
{
...
@@ -703,14 +704,14 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -703,14 +704,14 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```
ts
```
ts
// getSlot callback
// getSlot callback
function
getSlotCallback
(
err
,
data
)
{
function
getSlotCallback
(
err
:
Base
.
BusinessError
,
data
:
notificationManager
.
NotificationSlot
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`getSlot failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`getSlot failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
console
.
info
(
"
getSlot success
"
);
console
.
info
(
`getSlot success, data is
${
JSON
.
stringify
(
data
)}
`
);
}
}
}
}
let
slotType
=
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
;
let
slotType
:
notificationManager
.
SlotType
=
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
;
notificationManager
.
getSlot
(
slotType
,
getSlotCallback
);
notificationManager
.
getSlot
(
slotType
,
getSlotCallback
);
```
```
...
@@ -747,8 +748,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -747,8 +748,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
let
slotType
=
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
;
let
slotType
:
notificationManager
.
SlotType
=
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
;
notificationManager
.
getSlot
(
slotType
).
then
((
data
)
=>
{
notificationManager
.
getSlot
(
slotType
).
then
((
data
:
notificationManager
.
NotificationSlot
)
=>
{
console
.
info
(
"
getSlot success, data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
getSlot success, data:
"
+
JSON
.
stringify
(
data
));
});
});
```
```
...
@@ -781,11 +783,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -781,11 +783,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```
ts
```
ts
// getSlots callback
// getSlots callback
function
getSlotsCallback
(
err
,
data
)
{
function
getSlotsCallback
(
err
:
Base
.
BusinessError
,
data
:
Array
<
notificationManager
.
NotificationSlot
>
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`getSlots failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`getSlots failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
console
.
info
(
"
getSlots success
"
);
console
.
info
(
`getSlots success, data is
${
JSON
.
stringify
(
data
)}
`
);
}
}
}
}
notificationManager
.
getSlots
(
getSlotsCallback
);
notificationManager
.
getSlots
(
getSlotsCallback
);
...
@@ -818,7 +820,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -818,7 +820,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
notificationManager
.
getSlots
().
then
((
data
)
=>
{
notificationManager
.
getSlots
().
then
((
data
:
Array
<
notificationManager
.
NotificationSlot
>
)
=>
{
console
.
info
(
"
getSlots success, data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
getSlots success, data:
"
+
JSON
.
stringify
(
data
));
});
});
```
```
...
@@ -852,7 +854,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -852,7 +854,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```
ts
```
ts
// removeSlot callback
// removeSlot callback
function
removeSlotCallback
(
err
)
{
function
removeSlotCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`removeSlot failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`removeSlot failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -860,7 +862,7 @@ function removeSlotCallback(err) {
...
@@ -860,7 +862,7 @@ function removeSlotCallback(err) {
}
}
}
}
let
slotType
=
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
;
let
slotType
=
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
;
notificationManager
.
removeSlot
(
slotType
,
removeSlotCallback
);
notificationManager
.
removeSlot
(
slotType
,
removeSlotCallback
);
```
```
## notificationManager.removeSlot
## notificationManager.removeSlot
...
@@ -890,7 +892,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -890,7 +892,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
let
slotType
=
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
;
let
slotType
:
notificationManager
.
SlotType
=
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
;
notificationManager
.
removeSlot
(
slotType
).
then
(()
=>
{
notificationManager
.
removeSlot
(
slotType
).
then
(()
=>
{
console
.
info
(
"
removeSlot success
"
);
console
.
info
(
"
removeSlot success
"
);
});
});
...
@@ -923,7 +925,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -923,7 +925,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
function
removeAllCallBack
(
err
)
{
function
removeAllCallBack
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`removeAllSlots failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`removeAllSlots failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -993,17 +995,17 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -993,17 +995,17 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
function
setNotificationEnable
nCallback
(
er
r
)
{
function
setNotificationEnable
Callback
(
err
:
Base
.
BusinessErro
r
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`setNotificationEnable
n
Callback failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`setNotificationEnableCallback failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
console
.
info
(
"
setNotificationEnable
n
Callback success
"
);
console
.
info
(
"
setNotificationEnableCallback success
"
);
}
}
}
}
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
bundle
:
"
bundleName1
"
,
};
};
notificationManager
.
setNotificationEnable
(
bundle
,
false
,
setNotificationEnable
n
Callback
);
notificationManager
.
setNotificationEnable
(
bundle
,
false
,
setNotificationEnableCallback
);
```
```
## notificationManager.setNotificationEnable
## notificationManager.setNotificationEnable
...
@@ -1039,7 +1041,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -1039,7 +1041,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
bundle
:
"
bundleName1
"
,
};
};
notificationManager
.
setNotificationEnable
(
bundle
,
false
).
then
(()
=>
{
notificationManager
.
setNotificationEnable
(
bundle
,
false
).
then
(()
=>
{
...
@@ -1080,16 +1082,18 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -1080,16 +1082,18 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
function
isNotificationEnabledCallback
(
err
,
data
)
{
function
isNotificationEnabledCallback
(
err
:
Base
.
BusinessError
,
data
:
boolean
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`isNotificationEnabled failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`isNotificationEnabled failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
console
.
info
(
"
isNotificationEnabled success
"
);
console
.
info
(
`isNotificationEnabled success, data is
${
JSON
.
stringify
(
data
)}
`
);
}
}
}
}
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
bundle
:
"
bundleName1
"
,
};
};
notificationManager
.
isNotificationEnabled
(
bundle
,
isNotificationEnabledCallback
);
notificationManager
.
isNotificationEnabled
(
bundle
,
isNotificationEnabledCallback
);
```
```
...
@@ -1131,10 +1135,10 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -1131,10 +1135,10 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
bundle
:
"
bundleName1
"
,
};
};
notificationManager
.
isNotificationEnabled
(
bundle
).
then
((
data
)
=>
{
notificationManager
.
isNotificationEnabled
(
bundle
).
then
((
data
:
boolean
)
=>
{
console
.
info
(
"
isNotificationEnabled success, data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
isNotificationEnabled success, data:
"
+
JSON
.
stringify
(
data
));
});
});
```
```
...
@@ -1170,11 +1174,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -1170,11 +1174,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
function
isNotificationEnabledCallback
(
err
,
data
)
{
function
isNotificationEnabledCallback
(
err
:
Base
.
BusinessError
,
data
:
boolean
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`isNotificationEnabled failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`isNotificationEnabled failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
console
.
info
(
"
isNotificationEnabled success
"
);
console
.
info
(
`isNotificationEnabled success, data is
${
JSON
.
stringify
(
data
)}
`
);
}
}
}
}
...
@@ -1212,7 +1216,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -1212,7 +1216,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
notificationManager
.
isNotificationEnabled
().
then
((
data
)
=>
{
notificationManager
.
isNotificationEnabled
().
then
((
data
:
boolean
)
=>
{
console
.
info
(
"
isNotificationEnabled success, data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
isNotificationEnabled success, data:
"
+
JSON
.
stringify
(
data
));
});
});
```
```
...
@@ -1250,15 +1254,15 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -1250,15 +1254,15 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
function
isNotificationEnabledCallback
(
err
,
data
)
{
function
isNotificationEnabledCallback
(
err
:
Base
.
BusinessError
,
data
:
boolean
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`isNotificationEnabled failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`isNotificationEnabled failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
console
.
info
(
"
isNotificationEnabled success
"
);
console
.
info
(
`isNotificationEnabled success, data is
${
JSON
.
stringify
(
data
)}
`
);
}
}
}
}
let
userId
=
1
;
let
userId
:
number
=
1
;
notificationManager
.
isNotificationEnabled
(
userId
,
isNotificationEnabledCallback
);
notificationManager
.
isNotificationEnabled
(
userId
,
isNotificationEnabledCallback
);
```
```
...
@@ -1301,9 +1305,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -1301,9 +1305,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
let
userId
=
1
;
let
userId
:
number
=
1
;
notificationManager
.
isNotificationEnabled
(
userId
).
then
((
data
)
=>
{
notificationManager
.
isNotificationEnabled
(
userId
).
then
((
data
:
boolean
)
=>
{
console
.
info
(
"
isNotificationEnabled success, data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
isNotificationEnabled success, data:
"
+
JSON
.
stringify
(
data
));
});
});
```
```
...
@@ -1342,14 +1346,14 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -1342,14 +1346,14 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
function
displayBadgeCallback
(
err
)
{
function
displayBadgeCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`displayBadge failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`displayBadge failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
console
.
info
(
"
displayBadge success
"
);
console
.
info
(
"
displayBadge success
"
);
}
}
}
}
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
bundle
:
"
bundleName1
"
,
};
};
notificationManager
.
displayBadge
(
bundle
,
false
,
displayBadgeCallback
);
notificationManager
.
displayBadge
(
bundle
,
false
,
displayBadgeCallback
);
...
@@ -1388,7 +1392,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -1388,7 +1392,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
bundle
:
"
bundleName1
"
,
};
};
notificationManager
.
displayBadge
(
bundle
,
false
).
then
(()
=>
{
notificationManager
.
displayBadge
(
bundle
,
false
).
then
(()
=>
{
...
@@ -1413,7 +1417,7 @@ Checks whether the notification badge is enabled for a specified application. Th
...
@@ -1413,7 +1417,7 @@ Checks whether the notification badge is enabled for a specified application. Th
| Name | Type | Mandatory| Description |
| Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | ------------------------ |
| -------- | --------------------- | ---- | ------------------------ |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-notificationCommonDef.md#bundleoption
)
| Yes | Bundle of the application. |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-notificationCommonDef.md#bundleoption
)
| Yes | Bundle of the application. |
| callback | AsyncCallback
\<
void
\>
| Yes | Callback used to return the result.|
| callback | AsyncCallback
\<
boolean
\>
| Yes | Callback used to return the result.|
**Error codes**
**Error codes**
...
@@ -1429,14 +1433,14 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -1429,14 +1433,14 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
function
isBadgeDisplayedCallback
(
err
,
data
)
{
function
isBadgeDisplayedCallback
(
err
:
Base
.
BusinessError
,
data
:
boolean
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`isBadgeDisplayed failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`isBadgeDisplayed failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
console
.
info
(
"
isBadgeDisplayed success
"
);
console
.
info
(
`isBadgeDisplayed success, data is
${
JSON
.
stringify
(
data
)}
`
);
}
}
}
}
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
bundle
:
"
bundleName1
"
,
};
};
notificationManager
.
isBadgeDisplayed
(
bundle
,
isBadgeDisplayedCallback
);
notificationManager
.
isBadgeDisplayed
(
bundle
,
isBadgeDisplayedCallback
);
...
@@ -1480,10 +1484,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -1480,10 +1484,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
bundle
:
"
bundleName1
"
,
};
};
notificationManager
.
isBadgeDisplayed
(
bundle
).
then
((
data
)
=>
{
notificationManager
.
isBadgeDisplayed
(
bundle
).
then
((
data
:
boolean
)
=>
{
console
.
info
(
"
isBadgeDisplayed success, data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
isBadgeDisplayed success, data:
"
+
JSON
.
stringify
(
data
));
});
});
```
```
...
@@ -1514,7 +1519,8 @@ Sets the notification badge number. This API uses a promise to return the result
...
@@ -1514,7 +1519,8 @@ Sets the notification badge number. This API uses a promise to return the result
**Example**
**Example**
```
ts
```
ts
let
badgeNumber
=
10
let
badgeNumber
:
number
=
10
;
notificationManager
.
setBadgeNumber
(
badgeNumber
).
then
(()
=>
{
notificationManager
.
setBadgeNumber
(
badgeNumber
).
then
(()
=>
{
console
.
info
(
"
displayBadge success
"
);
console
.
info
(
"
displayBadge success
"
);
});
});
...
@@ -1549,7 +1555,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -1549,7 +1555,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
function
setBadgeNumberCallback
(
err
)
{
function
setBadgeNumberCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
info
(
`displayBadge failed code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
info
(
`displayBadge failed code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -1557,7 +1563,7 @@ function setBadgeNumberCallback(err) {
...
@@ -1557,7 +1563,7 @@ function setBadgeNumberCallback(err) {
}
}
}
}
let
badgeNumber
=
10
let
badgeNumber
:
number
=
10
;
notificationManager
.
setBadgeNumber
(
badgeNumber
,
setBadgeNumberCallback
);
notificationManager
.
setBadgeNumber
(
badgeNumber
,
setBadgeNumberCallback
);
```
```
...
@@ -1595,17 +1601,17 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -1595,17 +1601,17 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
function
setSlotByBundleCallback
(
err
)
{
function
setSlotByBundleCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`setSlotByBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`setSlotByBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
console
.
info
(
"
setSlotByBundle success
"
);
console
.
info
(
"
setSlotByBundle success
"
);
}
}
}
}
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
bundle
:
"
bundleName1
"
,
};
};
let
notificationSlot
=
{
let
notificationSlot
:
notificationManager
.
NotificationSlot
=
{
type
:
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
type
:
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
};
};
notificationManager
.
setSlotByBundle
(
bundle
,
notificationSlot
,
setSlotByBundleCallback
);
notificationManager
.
setSlotByBundle
(
bundle
,
notificationSlot
,
setSlotByBundleCallback
);
...
@@ -1644,12 +1650,14 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -1644,12 +1650,14 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
bundle
:
"
bundleName1
"
,
};
};
let
notificationSlot
=
{
let
notificationSlot
:
notificationManager
.
NotificationSlot
=
{
type
:
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
type
:
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
};
};
notificationManager
.
setSlotByBundle
(
bundle
,
notificationSlot
).
then
(()
=>
{
notificationManager
.
setSlotByBundle
(
bundle
,
notificationSlot
).
then
(()
=>
{
console
.
info
(
"
setSlotByBundle success
"
);
console
.
info
(
"
setSlotByBundle success
"
);
});
});
...
@@ -1688,14 +1696,14 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -1688,14 +1696,14 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
function
getSlotsByBundleCallback
(
err
,
data
)
{
function
getSlotsByBundleCallback
(
err
:
Base
.
BusinessError
,
data
:
Array
<
notificationManager
.
NotificationSlot
>
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`getSlotByBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`getSlotByBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
console
.
info
(
"
getSlotsByBundle success
"
);
console
.
info
(
`getSlotsByBundle success, data is
${
JSON
.
stringify
(
data
)}
`
);
}
}
}
}
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
bundle
:
"
bundleName1
"
,
};
};
notificationManager
.
getSlotsByBundle
(
bundle
,
getSlotsByBundleCallback
);
notificationManager
.
getSlotsByBundle
(
bundle
,
getSlotsByBundleCallback
);
...
@@ -1739,10 +1747,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -1739,10 +1747,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
bundle
:
"
bundleName1
"
,
};
};
notificationManager
.
getSlotsByBundle
(
bundle
).
then
((
data
)
=>
{
notificationManager
.
getSlotsByBundle
(
bundle
).
then
((
data
:
Array
<
notificationManager
.
NotificationSlot
>
)
=>
{
console
.
info
(
"
getSlotsByBundle success, data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
getSlotsByBundle success, data:
"
+
JSON
.
stringify
(
data
));
});
});
```
```
...
@@ -1780,16 +1789,18 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -1780,16 +1789,18 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
function
getSlotNumByBundleCallback
(
err
,
data
)
{
function
getSlotNumByBundleCallback
(
err
:
Base
.
BusinessError
,
data
:
number
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`getSlotByBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`getSlotByBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
console
.
info
(
"
getSlotNumByBundle success
"
);
console
.
info
(
`getSlotNumByBundle success data is
${
JSON
.
stringify
(
data
)}
`
);
}
}
}
}
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
bundle
:
"
bundleName1
"
,
};
};
notificationManager
.
getSlotNumByBundle
(
bundle
,
getSlotNumByBundleCallback
);
notificationManager
.
getSlotNumByBundle
(
bundle
,
getSlotNumByBundleCallback
);
```
```
...
@@ -1831,10 +1842,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -1831,10 +1842,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
bundle
:
"
bundleName1
"
,
};
};
notificationManager
.
getSlotNumByBundle
(
bundle
).
then
((
data
)
=>
{
notificationManager
.
getSlotNumByBundle
(
bundle
).
then
((
data
:
number
)
=>
{
console
.
info
(
"
getSlotNumByBundle success, data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
getSlotNumByBundle success, data:
"
+
JSON
.
stringify
(
data
));
});
});
```
```
...
@@ -1869,11 +1881,11 @@ Obtains all active notifications. This API uses an asynchronous callback to retu
...
@@ -1869,11 +1881,11 @@ Obtains all active notifications. This API uses an asynchronous callback to retu
**Example**
**Example**
```
ts
```
ts
function
getAllActiveNotificationsCallback
(
err
,
data
)
{
function
getAllActiveNotificationsCallback
(
err
:
Base
.
BusinessError
,
data
:
Array
<
notificationManager
.
NotificationRequest
>
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`getAllActiveNotifications failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`getAllActiveNotifications failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
console
.
info
(
"
getAllActiveNotifications success
"
);
console
.
info
(
`getAllActiveNotifications success, data is
${
JSON
.
stringify
(
data
)}
`
);
}
}
}
}
...
@@ -1911,7 +1923,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -1911,7 +1923,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
notificationManager
.
getAllActiveNotifications
().
then
((
data
)
=>
{
notificationManager
.
getAllActiveNotifications
().
then
((
data
:
Array
<
notificationManager
.
NotificationRequest
>
)
=>
{
console
.
info
(
"
getAllActiveNotifications success, data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
getAllActiveNotifications success, data:
"
+
JSON
.
stringify
(
data
));
});
});
```
```
...
@@ -1943,11 +1955,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -1943,11 +1955,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
function
getActiveNotificationCountCallback
(
err
,
data
)
{
function
getActiveNotificationCountCallback
(
err
:
Base
.
BusinessError
,
data
:
number
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`getActiveNotificationCount failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`getActiveNotificationCount failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
console
.
info
(
"
getActiveNotificationCount success
"
);
console
.
info
(
`getActiveNotificationCount success, data is
${
JSON
.
stringify
(
data
)}
`
);
}
}
}
}
...
@@ -1981,7 +1993,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -1981,7 +1993,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
notificationManager
.
getActiveNotificationCount
().
then
((
data
)
=>
{
notificationManager
.
getActiveNotificationCount
().
then
((
data
:
number
)
=>
{
console
.
info
(
"
getActiveNotificationCount success, data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
getActiveNotificationCount success, data:
"
+
JSON
.
stringify
(
data
));
});
});
```
```
...
@@ -2013,7 +2025,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -2013,7 +2025,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
function
getActiveNotificationsCallback
(
err
,
data
)
{
function
getActiveNotificationsCallback
(
err
:
Base
.
BusinessError
,
data
:
Array
<
notificationManager
.
NotificationRequest
>
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`getActiveNotifications failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`getActiveNotifications failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -2051,7 +2063,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -2051,7 +2063,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
notificationManager
.
getActiveNotifications
().
then
((
data
)
=>
{
notificationManager
.
getActiveNotifications
().
then
((
data
:
Array
<
notificationManager
.
NotificationRequest
>
)
=>
{
console
.
info
(
"
removeGroupByBundle success, data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
removeGroupByBundle success, data:
"
+
JSON
.
stringify
(
data
));
});
});
```
```
...
@@ -2084,7 +2096,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -2084,7 +2096,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
function
cancelGroupCallback
(
err
)
{
function
cancelGroupCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`cancelGroup failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`cancelGroup failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -2092,7 +2104,7 @@ function cancelGroupCallback(err) {
...
@@ -2092,7 +2104,7 @@ function cancelGroupCallback(err) {
}
}
}
}
let
groupName
=
"
GroupName
"
;
let
groupName
:
string
=
"
GroupName
"
;
notificationManager
.
cancelGroup
(
groupName
,
cancelGroupCallback
);
notificationManager
.
cancelGroup
(
groupName
,
cancelGroupCallback
);
```
```
...
@@ -2124,7 +2136,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -2124,7 +2136,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
let
groupName
=
"
GroupName
"
;
let
groupName
:
string
=
"
GroupName
"
;
notificationManager
.
cancelGroup
(
groupName
).
then
(()
=>
{
notificationManager
.
cancelGroup
(
groupName
).
then
(()
=>
{
console
.
info
(
"
cancelGroup success
"
);
console
.
info
(
"
cancelGroup success
"
);
});
});
...
@@ -2164,7 +2176,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -2164,7 +2176,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
function
removeGroupByBundleCallback
(
err
)
{
function
removeGroupByBundleCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`removeGroupByBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`removeGroupByBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -2172,8 +2184,8 @@ function removeGroupByBundleCallback(err) {
...
@@ -2172,8 +2184,8 @@ function removeGroupByBundleCallback(err) {
}
}
}
}
let
bundleOption
=
{
bundle
:
"
Bundle
"
};
let
bundleOption
:
notificationManager
.
BundleOption
=
{
bundle
:
"
Bundle
"
};
let
groupName
=
"
GroupName
"
;
let
groupName
:
string
=
"
GroupName
"
;
notificationManager
.
removeGroupByBundle
(
bundleOption
,
groupName
,
removeGroupByBundleCallback
);
notificationManager
.
removeGroupByBundle
(
bundleOption
,
groupName
,
removeGroupByBundleCallback
);
```
```
...
@@ -2211,8 +2223,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -2211,8 +2223,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
let
bundleOption
=
{
bundle
:
"
Bundle
"
};
let
bundleOption
:
notificationManager
.
BundleOption
=
{
bundle
:
"
Bundle
"
};
let
groupName
=
"
GroupName
"
;
let
groupName
:
string
=
"
GroupName
"
;
notificationManager
.
removeGroupByBundle
(
bundleOption
,
groupName
).
then
(()
=>
{
notificationManager
.
removeGroupByBundle
(
bundleOption
,
groupName
).
then
(()
=>
{
console
.
info
(
"
removeGroupByBundle success
"
);
console
.
info
(
"
removeGroupByBundle success
"
);
});
});
...
@@ -2251,7 +2264,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -2251,7 +2264,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
function
setDoNotDisturbDateCallback
(
err
)
{
function
setDoNotDisturbDateCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`setDoNotDisturbDate failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`setDoNotDisturbDate failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -2259,7 +2272,7 @@ function setDoNotDisturbDateCallback(err) {
...
@@ -2259,7 +2272,7 @@ function setDoNotDisturbDateCallback(err) {
}
}
}
}
let
doNotDisturbDate
=
{
let
doNotDisturbDate
:
notificationManager
.
DoNotDisturbDate
=
{
type
:
notificationManager
.
DoNotDisturbType
.
TYPE_ONCE
,
type
:
notificationManager
.
DoNotDisturbType
.
TYPE_ONCE
,
begin
:
new
Date
(),
begin
:
new
Date
(),
end
:
new
Date
(
2021
,
11
,
15
,
18
,
0
)
end
:
new
Date
(
2021
,
11
,
15
,
18
,
0
)
...
@@ -2300,7 +2313,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -2300,7 +2313,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
let
doNotDisturbDate
=
{
let
doNotDisturbDate
:
notificationManager
.
DoNotDisturbDate
=
{
type
:
notificationManager
.
DoNotDisturbType
.
TYPE_ONCE
,
type
:
notificationManager
.
DoNotDisturbType
.
TYPE_ONCE
,
begin
:
new
Date
(),
begin
:
new
Date
(),
end
:
new
Date
(
2021
,
11
,
15
,
18
,
0
)
end
:
new
Date
(
2021
,
11
,
15
,
18
,
0
)
...
@@ -2346,7 +2359,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -2346,7 +2359,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
function
setDoNotDisturbDateCallback
(
err
)
{
function
setDoNotDisturbDateCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`setDoNotDisturbDate failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`setDoNotDisturbDate failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -2354,13 +2367,13 @@ function setDoNotDisturbDateCallback(err) {
...
@@ -2354,13 +2367,13 @@ function setDoNotDisturbDateCallback(err) {
}
}
}
}
let
doNotDisturbDate
=
{
let
doNotDisturbDate
:
notificationManager
.
DoNotDisturbDate
=
{
type
:
notificationManager
.
DoNotDisturbType
.
TYPE_ONCE
,
type
:
notificationManager
.
DoNotDisturbType
.
TYPE_ONCE
,
begin
:
new
Date
(),
begin
:
new
Date
(),
end
:
new
Date
(
2021
,
11
,
15
,
18
,
0
)
end
:
new
Date
(
2021
,
11
,
15
,
18
,
0
)
};
};
let
userId
=
1
;
let
userId
:
number
=
1
;
notificationManager
.
setDoNotDisturbDate
(
doNotDisturbDate
,
userId
,
setDoNotDisturbDateCallback
);
notificationManager
.
setDoNotDisturbDate
(
doNotDisturbDate
,
userId
,
setDoNotDisturbDateCallback
);
```
```
...
@@ -2399,13 +2412,13 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -2399,13 +2412,13 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
let
doNotDisturbDate
=
{
let
doNotDisturbDate
:
notificationManager
.
DoNotDisturbDate
=
{
type
:
notificationManager
.
DoNotDisturbType
.
TYPE_ONCE
,
type
:
notificationManager
.
DoNotDisturbType
.
TYPE_ONCE
,
begin
:
new
Date
(),
begin
:
new
Date
(),
end
:
new
Date
(
2021
,
11
,
15
,
18
,
0
)
end
:
new
Date
(
2021
,
11
,
15
,
18
,
0
)
};
};
let
userId
=
1
;
let
userId
:
number
=
1
;
notificationManager
.
setDoNotDisturbDate
(
doNotDisturbDate
,
userId
).
then
(()
=>
{
notificationManager
.
setDoNotDisturbDate
(
doNotDisturbDate
,
userId
).
then
(()
=>
{
console
.
info
(
"
setDoNotDisturbDate success
"
);
console
.
info
(
"
setDoNotDisturbDate success
"
);
...
@@ -2445,11 +2458,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -2445,11 +2458,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
function
getDoNotDisturbDateCallback
(
err
,
data
)
{
function
getDoNotDisturbDateCallback
(
err
:
Base
.
BusinessError
,
data
:
notificationManager
.
DoNotDisturbDate
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`getDoNotDisturbDate failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`getDoNotDisturbDate failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
console
.
info
(
"
getDoNotDisturbDate success
"
);
console
.
info
(
`getDoNotDisturbDate success, data is
${
JSON
.
stringify
(
data
)}
`
);
}
}
}
}
...
@@ -2488,7 +2501,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -2488,7 +2501,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
notificationManager
.
getDoNotDisturbDate
().
then
((
data
)
=>
{
notificationManager
.
getDoNotDisturbDate
().
then
((
data
:
notificationManager
.
DoNotDisturbDate
)
=>
{
console
.
info
(
"
getDoNotDisturbDate success, data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
getDoNotDisturbDate success, data:
"
+
JSON
.
stringify
(
data
));
});
});
```
```
...
@@ -2528,15 +2541,15 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -2528,15 +2541,15 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
function
getDoNotDisturbDateCallback
(
err
,
data
)
{
function
getDoNotDisturbDateCallback
(
err
:
Base
.
BusinessError
,
data
:
notificationManager
.
DoNotDisturbDate
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`getDoNotDisturbDate failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`getDoNotDisturbDate failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
console
.
info
(
"
getDoNotDisturbDate success
"
);
console
.
info
(
`getDoNotDisturbDate success, data is
${
JSON
.
stringify
(
data
)}
`
);
}
}
}
}
let
userId
=
1
;
let
userId
:
number
=
1
;
notificationManager
.
getDoNotDisturbDate
(
userId
,
getDoNotDisturbDateCallback
);
notificationManager
.
getDoNotDisturbDate
(
userId
,
getDoNotDisturbDateCallback
);
```
```
...
@@ -2580,9 +2593,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -2580,9 +2593,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
let
userId
=
1
;
let
userId
:
number
=
1
;
notificationManager
.
getDoNotDisturbDate
(
userId
).
then
((
data
)
=>
{
notificationManager
.
getDoNotDisturbDate
(
userId
).
then
((
data
:
notificationManager
.
DoNotDisturbDate
)
=>
{
console
.
info
(
"
getDoNotDisturbDate success, data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
getDoNotDisturbDate success, data:
"
+
JSON
.
stringify
(
data
));
});
});
```
```
...
@@ -2617,7 +2630,7 @@ Checks whether DND mode is supported. This API uses an asynchronous callback to
...
@@ -2617,7 +2630,7 @@ Checks whether DND mode is supported. This API uses an asynchronous callback to
**Example**
**Example**
```
ts
```
ts
function
isSupportDoNotDisturbModeCallback
(
err
,
data
)
{
function
isSupportDoNotDisturbModeCallback
(
err
:
Base
.
BusinessError
,
data
:
boolean
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`isSupportDoNotDisturbMode failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`isSupportDoNotDisturbMode failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -2659,7 +2672,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -2659,7 +2672,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
notificationManager
.
isSupportDoNotDisturbMode
().
then
((
data
)
=>
{
notificationManager
.
isSupportDoNotDisturbMode
().
then
((
data
:
boolean
)
=>
{
console
.
info
(
"
supportDoNotDisturbMode success, data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
supportDoNotDisturbMode success, data:
"
+
JSON
.
stringify
(
data
));
});
});
```
```
...
@@ -2692,8 +2705,8 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -2692,8 +2705,8 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
javascript
```
javascript
let
templateName
=
'
process
'
;
let
templateName
:
string
=
'
process
'
;
function
isSupportTemplateCallback
(
err
,
data
)
{
function
isSupportTemplateCallback
(
err
:
Base
.
BusinessError
,
data
:
boolean
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`isSupportTemplate failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`isSupportTemplate failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -2737,9 +2750,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -2737,9 +2750,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
javascript
```
javascript
let
templateName
=
'
process
'
;
let
templateName
:
string
=
'
process
'
;
notificationManager
.
isSupportTemplate
(
templateName
).
then
((
data
)
=>
{
notificationManager
.
isSupportTemplate
(
templateName
).
then
((
data
:
boolean
)
=>
{
console
.
info
(
"
isSupportTemplate success, data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
isSupportTemplate success, data:
"
+
JSON
.
stringify
(
data
));
});
});
```
```
...
@@ -2771,7 +2784,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -2771,7 +2784,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
javascript
```
javascript
function
requestEnableNotificationCallback
(
err
)
{
function
requestEnableNotificationCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`requestEnableNotification failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`requestEnableNotification failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -2808,7 +2821,76 @@ notificationManager.requestEnableNotification().then(() => {
...
@@ -2808,7 +2821,76 @@ notificationManager.requestEnableNotification().then(() => {
});
});
```
```
## notificationManager.requestEnableNotification<sup>10+<sup>
requestEnableNotification(context: UIAbilityContext, callback: AsyncCallback
\<
void
\>
): void
Requests notification to be enabled for this application in a modal. This API uses an asynchronous callback to return the result.
**System capability**
: SystemCapability.Notification.Notification
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------ | ---- |--------------------|
| context | UIAbilityContext | Yes | Ability context bound to the notification dialog box.|
| callback | AsyncCallback
\<
void
\>
| Yes | Callback used to return the result. |
**Error codes**
For details about the error codes, see
[
Notification Error Codes
](
../errorcodes/errorcode-notification.md
)
.
| ID| Error Message |
| -------- | ----------------------------------- |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
**Example**
```
javascript
function
requestEnableNotificationCallback
(
err
)
{
if
(
err
)
{
console
.
error
(
`requestEnableNotification failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
info
(
"
requestEnableNotification success
"
);
}
};
notificationManager
.
requestEnableNotification
(
globalThis
.
uicontext
,
requestEnableNotificationCallback
);
```
## notificationManager.requestEnableNotification<sup>10+<sup>
requestEnableNotification(context: UIAbilityContext): Promise
\<
void
\>
Requests notification to be enabled for this application in a modal. This API uses a promise to return the result.
**System capability**
: SystemCapability.Notification.Notification
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------ | ---- |--------------------|
| context | UIAbilityContext | Yes | Ability context bound to the notification dialog box.|
**Error codes**
For details about the error codes, see
[
Notification Error Codes
](
../errorcodes/errorcode-notification.md
)
.
| ID| Error Message |
| -------- | ----------------------------------- |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
**Example**
```
javascript
notificationManager
.
requestEnableNotification
(
globalThis
.
uicontext
).
then
(()
=>
{
console
.
info
(
"
requestEnableNotification success
"
);
});
```
## notificationManager.setDistributedEnable
## notificationManager.setDistributedEnable
...
@@ -2843,7 +2925,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -2843,7 +2925,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
javascript
```
javascript
function
setDistributedEnableCallback
(
err
)
{
function
setDistributedEnableCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`setDistributedEnable failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`setDistributedEnable failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -2851,7 +2933,7 @@ function setDistributedEnableCallback(err) {
...
@@ -2851,7 +2933,7 @@ function setDistributedEnableCallback(err) {
}
}
};
};
let
enable
=
true
;
let
enable
:
boolean
=
true
;
notificationManager
.
setDistributedEnable
(
enable
,
setDistributedEnableCallback
);
notificationManager
.
setDistributedEnable
(
enable
,
setDistributedEnableCallback
);
```
```
...
@@ -2888,11 +2970,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -2888,11 +2970,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
javascript
```
javascript
let
enable
=
true
;
let
enable
:
boolean
=
true
;
notificationManager
.
setDistributedEnable
(
enable
).
then
(()
=>
{
notificationManager
.
setDistributedEnable
(
enable
).
then
(()
=>
{
console
.
info
(
"
setDistributedEnable success
"
);
console
.
info
(
"
setDistributedEnable success
"
);
});
});
```
```
...
@@ -2924,7 +3006,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -2924,7 +3006,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
javascript
```
javascript
function
isDistributedEnabledCallback
(
err
,
data
)
{
function
isDistributedEnabledCallback
(
err
:
Base
.
BusinessError
,
data
:
boolean
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`isDistributedEnabled failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`isDistributedEnabled failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -2966,7 +3048,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -2966,7 +3048,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```
javascript
```
javascript
notificationManager
.
isDistributedEnabled
()
notificationManager
.
isDistributedEnabled
()
.
then
((
data
)
=>
{
.
then
((
data
:
boolean
)
=>
{
console
.
info
(
"
isDistributedEnabled success, data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
isDistributedEnabled success, data:
"
+
JSON
.
stringify
(
data
));
});
});
```
```
...
@@ -3007,7 +3089,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -3007,7 +3089,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
javascript
```
javascript
function
setDistributedEnableByBundleCallback
(
err
)
{
function
setDistributedEnableByBundleCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`setDistributedEnableByBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`setDistributedEnableByBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -3015,11 +3097,11 @@ function setDistributedEnableByBundleCallback(err) {
...
@@ -3015,11 +3097,11 @@ function setDistributedEnableByBundleCallback(err) {
}
}
};
};
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
bundle
:
"
bundleName1
"
,
};
};
let
enable
=
true
let
enable
:
boolean
=
true
;
notificationManager
.
setDistributedEnableByBundle
(
bundle
,
enable
,
setDistributedEnableByBundleCallback
);
notificationManager
.
setDistributedEnableByBundle
(
bundle
,
enable
,
setDistributedEnableByBundleCallback
);
```
```
...
@@ -3060,11 +3142,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -3060,11 +3142,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
javascript
```
javascript
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
bundle
:
"
bundleName1
"
,
};
};
let
enable
=
true
let
enable
:
boolean
=
true
;
notificationManager
.
setDistributedEnableByBundle
(
bundle
,
enable
).
then
(()
=>
{
notificationManager
.
setDistributedEnableByBundle
(
bundle
,
enable
).
then
(()
=>
{
console
.
info
(
"
setDistributedEnableByBundle success
"
);
console
.
info
(
"
setDistributedEnableByBundle success
"
);
...
@@ -3105,7 +3187,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -3105,7 +3187,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
javascript
```
javascript
function
isDistributedEnabledByBundleCallback
(
err
,
data
)
{
function
isDistributedEnabledByBundleCallback
(
err
:
Base
.
BusinessError
,
data
:
boolean
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`isDistributedEnabledByBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`isDistributedEnabledByBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -3113,7 +3195,7 @@ function isDistributedEnabledByBundleCallback(err, data) {
...
@@ -3113,7 +3195,7 @@ function isDistributedEnabledByBundleCallback(err, data) {
}
}
};
};
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
bundle
:
"
bundleName1
"
,
};
};
...
@@ -3159,11 +3241,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -3159,11 +3241,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
javascript
```
javascript
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
bundle
:
"
bundleName1
"
,
};
};
notificationManager
.
isDistributedEnabledByBundle
(
bundle
).
then
((
data
)
=>
{
notificationManager
.
isDistributedEnabledByBundle
(
bundle
).
then
((
data
:
boolean
)
=>
{
console
.
info
(
"
isDistributedEnabledByBundle success, data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
isDistributedEnabledByBundle success, data:
"
+
JSON
.
stringify
(
data
));
});
});
```
```
...
@@ -3200,11 +3282,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -3200,11 +3282,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
javascript
```
javascript
function
getDeviceRemindTypeCallback
(
err
,
data
)
{
function
getDeviceRemindTypeCallback
(
err
:
Base
.
BusinessError
,
data
:
notificationManager
.
DeviceRemindType
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`getDeviceRemindType failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`getDeviceRemindType failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
console
.
info
(
"
getDeviceRemindType success
"
);
console
.
info
(
`getDeviceRemindType success, data is
${
JSON
.
stringify
(
data
)}
`
);
}
}
};
};
...
@@ -3242,7 +3324,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -3242,7 +3324,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
javascript
```
javascript
notificationManager
.
getDeviceRemindType
().
then
((
data
)
=>
{
notificationManager
.
getDeviceRemindType
().
then
((
data
:
notificationManager
.
DeviceRemindType
)
=>
{
console
.
info
(
"
getDeviceRemindType success, data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
getDeviceRemindType success, data:
"
+
JSON
.
stringify
(
data
));
});
});
```
```
...
@@ -3288,7 +3370,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -3288,7 +3370,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```
ts
```
ts
// publishAsBundle callback
// publishAsBundle callback
function
callback
(
err
)
{
function
callback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`publishAsBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`publishAsBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -3296,11 +3378,11 @@ function callback(err) {
...
@@ -3296,11 +3378,11 @@ function callback(err) {
}
}
}
}
// Bundle name of the application whose notification function is taken over by the reminder agent
// Bundle name of the application whose notification function is taken over by the reminder agent
let
representativeBundle
=
"
com.example.demo
"
;
let
representativeBundle
:
string
=
"
com.example.demo
"
;
// User ID
// User ID
let
userId
=
100
;
let
userId
:
number
=
100
;
// NotificationRequest object
// NotificationRequest object
let
request
=
{
let
request
:
notificationManager
.
NotificationRequest
=
{
id
:
1
,
id
:
1
,
content
:
{
content
:
{
contentType
:
notificationManager
.
ContentType
.
NOTIFICATION_CONTENT_BASIC_TEXT
,
contentType
:
notificationManager
.
ContentType
.
NOTIFICATION_CONTENT_BASIC_TEXT
,
...
@@ -3355,11 +3437,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -3355,11 +3437,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```
ts
```
ts
// Bundle name of the application whose notification function is taken over by the reminder agent
// Bundle name of the application whose notification function is taken over by the reminder agent
let
representativeBundle
=
"
com.example.demo
"
;
let
representativeBundle
:
string
=
"
com.example.demo
"
;
// User ID
// User ID
let
userId
=
100
;
let
userId
:
number
=
100
;
// NotificationRequest object
// NotificationRequest object
let
request
=
{
let
request
:
notificationManager
.
NotificationRequest
=
{
id
:
1
,
id
:
1
,
content
:
{
content
:
{
contentType
:
notificationManager
.
ContentType
.
NOTIFICATION_CONTENT_BASIC_TEXT
,
contentType
:
notificationManager
.
ContentType
.
NOTIFICATION_CONTENT_BASIC_TEXT
,
...
@@ -3415,7 +3497,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -3415,7 +3497,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```
ts
```
ts
// cancelAsBundle
// cancelAsBundle
function
cancelAsBundleCallback
(
err
)
{
function
cancelAsBundleCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`cancelAsBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`cancelAsBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -3423,9 +3505,9 @@ function cancelAsBundleCallback(err) {
...
@@ -3423,9 +3505,9 @@ function cancelAsBundleCallback(err) {
}
}
}
}
// Bundle name of the application whose notification function is taken over by the reminder agent
// Bundle name of the application whose notification function is taken over by the reminder agent
let
representativeBundle
=
"
com.example.demo
"
;
let
representativeBundle
:
string
=
"
com.example.demo
"
;
// User ID
// User ID
let
userId
=
100
;
let
userId
:
number
=
100
;
notificationManager
.
cancelAsBundle
(
0
,
representativeBundle
,
userId
,
cancelAsBundleCallback
);
notificationManager
.
cancelAsBundle
(
0
,
representativeBundle
,
userId
,
cancelAsBundleCallback
);
```
```
...
@@ -3468,9 +3550,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -3468,9 +3550,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```
ts
```
ts
// Bundle name of the application whose notification function is taken over by the reminder agent
// Bundle name of the application whose notification function is taken over by the reminder agent
let
representativeBundle
=
"
com.example.demo
"
;
let
representativeBundle
:
string
=
"
com.example.demo
"
;
// User ID
// User ID
let
userId
=
100
;
let
userId
:
number
=
100
;
notificationManager
.
cancelAsBundle
(
0
,
representativeBundle
,
userId
).
then
(()
=>
{
notificationManager
.
cancelAsBundle
(
0
,
representativeBundle
,
userId
).
then
(()
=>
{
console
.
info
(
"
cancelAsBundle success
"
);
console
.
info
(
"
cancelAsBundle success
"
);
...
@@ -3513,7 +3595,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -3513,7 +3595,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```
ts
```
ts
// setNotificationEnableSlot
// setNotificationEnableSlot
function
setNotificationEnableSlotCallback
(
err
)
{
function
setNotificationEnableSlotCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`setNotificationEnableSlot failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`setNotificationEnableSlot failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -3606,11 +3688,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -3606,11 +3688,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```
ts
```
ts
// isNotificationSlotEnabled
// isNotificationSlotEnabled
function
getEnableSlotCallback
(
err
,
data
)
{
function
getEnableSlotCallback
(
err
:
Base
.
BusinessError
,
data
:
boolean
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`isNotificationSlotEnabled failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`isNotificationSlotEnabled failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
console
.
info
(
"
isNotificationSlotEnabled success
"
);
console
.
info
(
`isNotificationSlotEnabled success, data is
${
JSON
.
stringify
(
data
)}
`
);
}
}
};
};
...
@@ -3661,7 +3743,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -3661,7 +3743,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```
ts
```
ts
// isNotificationSlotEnabled
// isNotificationSlotEnabled
notificationManager
.
isNotificationSlotEnabled
({
bundle
:
"
ohos.samples.notification
"
,
},
notificationManager
.
isNotificationSlotEnabled
({
bundle
:
"
ohos.samples.notification
"
,
},
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
).
then
((
data
)
=>
{
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
).
then
((
data
:
boolean
)
=>
{
console
.
info
(
"
isNotificationSlotEnabled success, data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
isNotificationSlotEnabled success, data:
"
+
JSON
.
stringify
(
data
));
});
});
```
```
...
@@ -3701,10 +3783,10 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -3701,10 +3783,10 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
let
userId
=
100
;
let
userId
:
number
=
100
;
let
enable
=
true
;
let
enable
:
boolean
=
true
;
function
callback
(
err
)
{
function
callback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`setSyncNotificationEnabledWithoutApp failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`setSyncNotificationEnabledWithoutApp failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -3755,13 +3837,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -3755,13 +3837,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
let
userId
=
100
;
let
userId
:
number
=
100
;
let
enable
=
true
;
let
enable
:
boolean
=
true
;
notificationManager
.
setSyncNotificationEnabledWithoutApp
(
userId
,
enable
).
then
(()
=>
{
notificationManager
.
setSyncNotificationEnabledWithoutApp
(
userId
,
enable
).
then
(()
=>
{
console
.
info
(
'
setSyncNotificationEnabledWithoutApp success
'
);
console
.
info
(
'
setSyncNotificationEnabledWithoutApp success
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
`setSyncNotificationEnabledWithoutApp failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
});
});
```
```
...
@@ -3799,9 +3879,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -3799,9 +3879,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
let
userId
=
100
;
let
userId
:
number
=
100
;
function
getSyncNotificationEnabledWithoutAppCallback
(
err
,
data
)
{
function
getSyncNotificationEnabledWithoutAppCallback
(
err
:
Base
.
BusinessError
,
data
:
boolean
)
{
if
(
err
)
{
if
(
err
)
{
console
.
info
(
'
getSyncNotificationEnabledWithoutAppCallback, err:
'
+
err
);
console
.
info
(
'
getSyncNotificationEnabledWithoutAppCallback, err:
'
+
err
);
}
else
{
}
else
{
...
@@ -3851,11 +3931,10 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
...
@@ -3851,11 +3931,10 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
**Example**
```
ts
```
ts
let
userId
=
100
;
let
userId
:
number
=
100
;
notificationManager
.
getSyncNotificationEnabledWithoutApp
(
userId
).
then
((
data
)
=>
{
notificationManager
.
getSyncNotificationEnabledWithoutApp
(
userId
).
then
((
data
:
boolean
)
=>
{
console
.
info
(
'
getSyncNotificationEnabledWithoutApp, data:
'
+
data
);
console
.
info
(
'
getSyncNotificationEnabledWithoutApp, data:
'
+
data
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
getSyncNotificationEnabledWithoutApp, err:
'
+
err
);
});
});
```
```
...
@@ -3897,9 +3976,11 @@ try{
...
@@ -3897,9 +3976,11 @@ try{
function
OnCheckNotification
(
info
:
notificationManager
.
NotificationCheckInfo
)
{
function
OnCheckNotification
(
info
:
notificationManager
.
NotificationCheckInfo
)
{
console
.
info
(
`====>OnCheckNotification info:
${
JSON
.
stringify
(
info
)}
`
);
console
.
info
(
`====>OnCheckNotification info:
${
JSON
.
stringify
(
info
)}
`
);
if
(
info
.
notificationId
==
1
){
if
(
info
.
notificationId
==
1
){
return
{
code
:
1
,
message
:
"
testMsg1
"
}
let
result
:
notificationManager
.
NotificationCheckResult
=
{
code
:
1
,
message
:
"
testMsg1
"
};
return
result
;
}
else
{
}
else
{
return
{
code
:
0
,
message
:
"
testMsg0
"
}
let
result
:
notificationManager
.
NotificationCheckResult
=
{
code
:
0
,
message
:
"
testMsg0
"
};
return
result
;
}
}
}
}
```
```
...
...
en/application-dev/reference/apis/js-apis-system-notification.md
浏览文件 @
1743c481
...
@@ -50,8 +50,12 @@ Displays a notification.
...
@@ -50,8 +50,12 @@ Displays a notification.
| options | ShowNotificationOptions | No| Notification title.|
| options | ShowNotificationOptions | No| Notification title.|
**Example**
**Example**
```
javascript
```
ts
export
default
{
class
NotificationClass
{
show
:
Function
}
let
notificationObj
:
NotificationClass
=
{
show
()
{
show
()
{
notification
.
show
({
notification
.
show
({
contentTitle
:
'
title info
'
,
contentTitle
:
'
title info
'
,
...
@@ -64,4 +68,6 @@ export default {
...
@@ -64,4 +68,6 @@ export default {
});
});
}
}
}
}
export
default
notificationObj
```
```
zh-cn/application-dev/application-models/arkts-ui-widget-event-formextensionability.md
浏览文件 @
1743c481
...
@@ -46,18 +46,15 @@
...
@@ -46,18 +46,15 @@
import
formProvider
from
'
@ohos.app.form.formProvider
'
;
import
formProvider
from
'
@ohos.app.form.formProvider
'
;
export
default
class
EntryFormAbility
extends
FormExtensionAbility
{
export
default
class
EntryFormAbility
extends
FormExtensionAbility
{
onFormEvent
(
formId
,
message
)
{
onFormEvent
(
formId
:
string
,
message
:
string
)
{
// Called when a specified message event defined by the form provider is triggered.
// Called when a specified message event defined by the form provider is triggered.
console
.
info
(
`FormAbility onEvent, formId =
${
formId
}
, message:
${
JSON
.
stringify
(
message
)}
`
);
console
.
info
(
`FormAbility onEvent, formId =
${
formId
}
, message:
${
JSON
.
stringify
(
message
)}
`
);
let
formData
=
{
let
formData
=
new
Map
<
Object
,
string
>
();
'
title
'
:
'
Title Update.
'
,
// 和卡片布局中对应
formData
.
set
(
'
title
'
,
'
Title Update.
'
);
// 和卡片布局中对应
'
detail
'
:
'
Description update success.
'
,
// 和卡片布局中对应
formData
.
set
(
'
detail
'
,
'
Description update success.
'
);
// 和卡片布局中对应
};
let
formInfo
=
formBindingData
.
createFormBindingData
(
formData
)
let
formInfo
=
formBindingData
.
createFormBindingData
(
formData
)
formProvider
.
updateForm
(
formId
,
formInfo
).
then
((
data
)
=>
{
formProvider
.
updateForm
(
formId
,
formInfo
).
then
((
data
)
=>
{
console
.
info
(
'
FormAbility updateForm success.
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
FormAbility updateForm success.
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
console
.
error
(
'
FormAbility updateForm failed:
'
+
JSON
.
stringify
(
error
));
})
})
}
}
...
...
zh-cn/application-dev/reference/apis/js-apis-app-form-formBindingData.md
浏览文件 @
1743c481
...
@@ -66,12 +66,17 @@ import fs from '@ohos.file.fs';
...
@@ -66,12 +66,17 @@ import fs from '@ohos.file.fs';
try
{
try
{
let
fd
=
fs
.
openSync
(
'
/path/to/form.png
'
);
let
fd
=
fs
.
openSync
(
'
/path/to/form.png
'
);
let
obj
=
{
'
temperature
'
:
'
21°
'
,
let
createFormBindingDataParam
=
new
Map
<
Object
,
string
|
object
>
();
'
formImages
'
:
{
'
image
'
:
fd
}
let
formImagesParam
=
new
Map
<
Object
,
object
>
();
};
formImagesParam
.
set
(
'
image
'
,
fd
);
formBindingData
.
createFormBindingData
(
obj
);
createFormBindingDataParam
.
set
(
"
name
"
,
'
21°
'
);
createFormBindingDataParam
.
set
(
'
formImages
'
,
formImagesParam
);
formBindingData
.
createFormBindingData
(
createFormBindingDataParam
);
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
`catch error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
let
code
=
(
error
as
Base
.
BusinessError
).
code
;
let
message
=
(
error
as
Base
.
BusinessError
).
message
;
console
.
error
(
`catch error, code:
${
code
}
, message:
${
message
}
`
);
}
}
```
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-app-form-formExtensionAbility.md
浏览文件 @
1743c481
...
@@ -46,18 +46,19 @@ onAddForm(want: Want): formBindingData.FormBindingData
...
@@ -46,18 +46,19 @@ onAddForm(want: Want): formBindingData.FormBindingData
```
ts
```
ts
import
FormExtensionAbility
from
'
@ohos.app.form.FormExtensionAbility
'
;
import
FormExtensionAbility
from
'
@ohos.app.form.FormExtensionAbility
'
;
import
formBindingData
from
'
@ohos.app.form.formBindingData
'
;
import
formBindingData
from
'
@ohos.app.form.formBindingData
'
;
import
Want
from
'
@ohos.app.ability.Want
'
;
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
onAddForm
(
want
)
{
onAddForm
(
want
:
Want
)
{
console
.
log
(
`FormExtensionAbility onAddForm, want:
${
want
.
abilityName
}
`
);
console
.
log
(
`FormExtensionAbility onAddForm, want:
${
want
.
abilityName
}
`
);
let
dataObj1
=
{
let
dataObj1
=
new
Map
<
Object
,
string
>
();
temperature
:
'
11c
'
,
dataObj1
.
set
(
'
temperature
'
,
'
11c
'
);
'
time
'
:
'
11:00
'
dataObj1
.
set
(
'
time
'
,
'
11:00
'
);
};
let
obj1
=
formBindingData
.
createFormBindingData
(
dataObj1
);
let
obj1
=
formBindingData
.
createFormBindingData
(
dataObj1
);
return
obj1
;
return
obj1
;
}
}
}
;
}
```
```
## onCastToNormalForm
## onCastToNormalForm
...
@@ -80,7 +81,7 @@ onCastToNormalForm(formId: string): void
...
@@ -80,7 +81,7 @@ onCastToNormalForm(formId: string): void
import
FormExtensionAbility
from
'
@ohos.app.form.FormExtensionAbility
'
;
import
FormExtensionAbility
from
'
@ohos.app.form.FormExtensionAbility
'
;
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
onCastToNormalForm
(
formId
)
{
onCastToNormalForm
(
formId
:
string
)
{
console
.
log
(
`FormExtensionAbility onCastToNormalForm, formId:
${
formId
}
`
);
console
.
log
(
`FormExtensionAbility onCastToNormalForm, formId:
${
formId
}
`
);
}
}
};
};
...
@@ -108,16 +109,18 @@ import formBindingData from '@ohos.app.form.formBindingData';
...
@@ -108,16 +109,18 @@ import formBindingData from '@ohos.app.form.formBindingData';
import
formProvider
from
'
@ohos.app.form.formProvider
'
;
import
formProvider
from
'
@ohos.app.form.formProvider
'
;
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
onUpdateForm
(
formId
)
{
onUpdateForm
(
formId
:
string
)
{
console
.
log
(
`FormExtensionAbility onUpdateForm, formId:
${
formId
}
`
);
console
.
log
(
`FormExtensionAbility onUpdateForm, formId:
${
formId
}
`
);
class
createFormBindingDataParam
{
temperature
:
string
time
:
string
}
let
obj2
=
formBindingData
.
createFormBindingData
({
let
obj2
=
formBindingData
.
createFormBindingData
({
temperature
:
'
22c
'
,
temperature
:
'
22c
'
,
time
:
'
22:00
'
time
:
'
22:00
'
});
}
as
createFormBindingDataParam
);
formProvider
.
updateForm
(
formId
,
obj2
).
then
((
data
)
=>
{
formProvider
.
updateForm
(
formId
,
obj2
).
then
((
data
)
=>
{
console
.
log
(
`FormExtensionAbility context updateForm, data:
${
data
}
`
);
console
.
log
(
`FormExtensionAbility context updateForm, data:
${
data
}
`
);
}).
catch
((
error
)
=>
{
console
.
error
(
`Operation updateForm failed. Cause:
${
error
}
`
);
});
});
}
}
};
};
...
@@ -144,13 +147,24 @@ import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
...
@@ -144,13 +147,24 @@ import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
import
formBindingData
from
'
@ohos.app.form.formBindingData
'
;
import
formBindingData
from
'
@ohos.app.form.formBindingData
'
;
import
formProvider
from
'
@ohos.app.form.formProvider
'
;
import
formProvider
from
'
@ohos.app.form.formProvider
'
;
// 由于arkTs中无Object.keys,且无法使用for..in...
// 若报arkTs问题,请将此方法单独抽离至一个ts文件中并暴露,在需要用到的ets文件中引入使用
function
getObjKeys
(
obj
:
Object
):
string
[]
{
let
keys
=
Object
.
keys
(
obj
);
return
keys
;
}
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
onChangeFormVisibility
(
newStatus
)
{
onChangeFormVisibility
(
newStatus
)
{
console
.
log
(
`FormExtensionAbility onChangeFormVisibility, newStatus:
${
newStatus
}
`
);
console
.
log
(
`FormExtensionAbility onChangeFormVisibility, newStatus:
${
newStatus
}
`
);
class
createFormBindingDataParam
{
temperature
:
string
time
:
string
}
let
obj2
=
formBindingData
.
createFormBindingData
({
let
obj2
=
formBindingData
.
createFormBindingData
({
temperature
:
'
22c
'
,
temperature
:
'
22c
'
,
time
:
'
22:00
'
time
:
'
22:00
'
});
}
as
createFormBindingDataParam
);
for
(
let
key
in
newStatus
)
{
for
(
let
key
in
newStatus
)
{
console
.
log
(
`FormExtensionAbility onChangeFormVisibility, key:
${
key
}
, value=
${
newStatus
[
key
]}
`
);
console
.
log
(
`FormExtensionAbility onChangeFormVisibility, key:
${
key
}
, value=
${
newStatus
[
key
]}
`
);
...
@@ -185,7 +199,7 @@ onFormEvent(formId: string, message: string): void
...
@@ -185,7 +199,7 @@ onFormEvent(formId: string, message: string): void
import
FormExtensionAbility
from
'
@ohos.app.form.FormExtensionAbility
'
;
import
FormExtensionAbility
from
'
@ohos.app.form.FormExtensionAbility
'
;
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
onFormEvent
(
formId
,
message
)
{
onFormEvent
(
formId
:
string
,
message
:
string
)
{
console
.
log
(
`FormExtensionAbility onFormEvent, formId:
${
formId
}
, message:
${
message
}
`
);
console
.
log
(
`FormExtensionAbility onFormEvent, formId:
${
formId
}
, message:
${
message
}
`
);
}
}
};
};
...
@@ -211,7 +225,7 @@ onRemoveForm(formId: string): void
...
@@ -211,7 +225,7 @@ onRemoveForm(formId: string): void
import
FormExtensionAbility
from
'
@ohos.app.form.FormExtensionAbility
'
;
import
FormExtensionAbility
from
'
@ohos.app.form.FormExtensionAbility
'
;
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
onRemoveForm
(
formId
)
{
onRemoveForm
(
formId
:
string
)
{
console
.
log
(
`FormExtensionAbility onRemoveForm, formId:
${
formId
}
`
);
console
.
log
(
`FormExtensionAbility onRemoveForm, formId:
${
formId
}
`
);
}
}
};
};
...
@@ -235,9 +249,10 @@ onConfigurationUpdate(newConfig: Configuration): void;
...
@@ -235,9 +249,10 @@ onConfigurationUpdate(newConfig: Configuration): void;
```
ts
```
ts
import
FormExtensionAbility
from
'
@ohos.app.form.FormExtensionAbility
'
;
import
FormExtensionAbility
from
'
@ohos.app.form.FormExtensionAbility
'
;
import
{
Configuration
}
from
'
@ohos.app.ability.Configuration
'
;
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
onConfigurationUpdate
(
config
)
{
onConfigurationUpdate
(
config
:
Configuration
)
{
console
.
log
(
`onConfigurationUpdate, config:
${
JSON
.
stringify
(
config
)}
`
);
console
.
log
(
`onConfigurationUpdate, config:
${
JSON
.
stringify
(
config
)}
`
);
}
}
};
};
...
@@ -262,9 +277,10 @@ onAcquireFormState?(want: Want): formInfo.FormState;
...
@@ -262,9 +277,10 @@ onAcquireFormState?(want: Want): formInfo.FormState;
```
ts
```
ts
import
FormExtensionAbility
from
'
@ohos.app.form.FormExtensionAbility
'
;
import
FormExtensionAbility
from
'
@ohos.app.form.FormExtensionAbility
'
;
import
formInfo
from
'
@ohos.app.form.formInfo
'
;
import
formInfo
from
'
@ohos.app.form.formInfo
'
;
import
Want
from
'
@ohos.app.ability.Want
'
;
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
onAcquireFormState
(
want
)
{
onAcquireFormState
(
want
:
Want
)
{
console
.
log
(
`FormExtensionAbility onAcquireFormState, want:
${
want
}
`
);
console
.
log
(
`FormExtensionAbility onAcquireFormState, want:
${
want
}
`
);
return
formInfo
.
FormState
.
UNKNOWN
;
return
formInfo
.
FormState
.
UNKNOWN
;
}
}
...
@@ -299,11 +315,11 @@ onShareForm?(formId: string): { [key: string]: Object }
...
@@ -299,11 +315,11 @@ onShareForm?(formId: string): { [key: string]: Object }
import
FormExtensionAbility
from
'
@ohos.app.form.FormExtensionAbility
'
;
import
FormExtensionAbility
from
'
@ohos.app.form.FormExtensionAbility
'
;
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
onShareForm
(
formId
)
{
onShareForm
(
formId
:
string
)
{
console
.
log
(
`FormExtensionAbility onShareForm, formId:
${
formId
}
`
);
console
.
log
(
`FormExtensionAbility onShareForm, formId:
${
formId
}
`
);
let
wantParams
=
{
let
wantParams
=
{
'
temperature
'
:
'
20
'
,
'
temperature
'
:
'
20
'
,
'
time
'
:
'
2022-8-8 09:59
'
,
'
time
'
:
'
2022-8-8 09:59
'
,
s
};
};
return
wantParams
;
return
wantParams
;
}
}
...
@@ -338,7 +354,7 @@ onAcquireFormData?(formId: string): { [key: string]: Object }
...
@@ -338,7 +354,7 @@ onAcquireFormData?(formId: string): { [key: string]: Object }
import
FormExtensionAbility
from
'
@ohos.app.form.FormExtensionAbility
'
;
import
FormExtensionAbility
from
'
@ohos.app.form.FormExtensionAbility
'
;
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
onAcquireFormData
(
formId
)
{
onAcquireFormData
(
formId
:
string
)
{
console
.
log
(
'
FormExtensionAbility onAcquireFormData, formId: ${formId}
'
);
console
.
log
(
'
FormExtensionAbility onAcquireFormData, formId: ${formId}
'
);
let
wantParams
=
{
let
wantParams
=
{
'
temperature
'
:
'
20
'
,
'
temperature
'
:
'
20
'
,
...
...
zh-cn/application-dev/reference/apis/js-apis-app-form-formHost.md
浏览文件 @
1743c481
...
@@ -11,6 +11,7 @@ formHost模块提供了卡片使用方相关接口的能力,包括对使用方
...
@@ -11,6 +11,7 @@ formHost模块提供了卡片使用方相关接口的能力,包括对使用方
```
ts
```
ts
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
Base
from
'
@ohos.base
'
;
```
```
## deleteForm
## deleteForm
...
@@ -51,8 +52,8 @@ deleteForm(formId: string, callback: AsyncCallback<void>): void
...
@@ -51,8 +52,8 @@ deleteForm(formId: string, callback: AsyncCallback<void>): void
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formHost
from
'
@ohos.app.form.formHost
'
;
try
{
try
{
let
formId
=
'
12400633174999288
'
;
let
formId
:
string
=
'
12400633174999288
'
;
formHost
.
deleteForm
(
formId
,
(
error
)
=>
{
formHost
.
deleteForm
(
formId
,
(
error
:
Base
.
BusinessError
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
}
else
{
}
else
{
...
@@ -108,11 +109,11 @@ deleteForm(formId: string): Promise<void>
...
@@ -108,11 +109,11 @@ deleteForm(formId: string): Promise<void>
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formHost
from
'
@ohos.app.form.formHost
'
;
try
{
try
{
let
formId
=
'
12400633174999288
'
;
let
formId
:
string
=
'
12400633174999288
'
;
formHost
.
deleteForm
(
formId
).
then
(()
=>
{
formHost
.
deleteForm
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost deleteForm success
'
);
console
.
log
(
'
formHost deleteForm success
'
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Base
.
BusinessError
)
=>
{
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
console
.
error
(
'
formHost deleteForm, error: ${JSON.stringify(error)}
'
);
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
`catch error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
console
.
error
(
`catch error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
...
@@ -157,8 +158,8 @@ releaseForm(formId: string, callback: AsyncCallback<void>): void
...
@@ -157,8 +158,8 @@ releaseForm(formId: string, callback: AsyncCallback<void>): void
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formHost
from
'
@ohos.app.form.formHost
'
;
try
{
try
{
let
formId
=
'
12400633174999288
'
;
let
formId
:
string
=
'
12400633174999288
'
;
formHost
.
releaseForm
(
formId
,
(
error
)
=>
{
formHost
.
releaseForm
(
formId
,
(
error
:
Base
.
BusinessError
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
}
}
...
@@ -207,8 +208,8 @@ releaseForm(formId: string, isReleaseCache: boolean, callback: AsyncCallback<
...
@@ -207,8 +208,8 @@ releaseForm(formId: string, isReleaseCache: boolean, callback: AsyncCallback<
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formHost
from
'
@ohos.app.form.formHost
'
;
try
{
try
{
let
formId
=
'
12400633174999288
'
;
let
formId
:
string
=
'
12400633174999288
'
;
formHost
.
releaseForm
(
formId
,
true
,
(
error
)
=>
{
formHost
.
releaseForm
(
formId
,
true
,
(
error
:
Base
.
BusinessError
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
}
}
...
@@ -262,10 +263,10 @@ releaseForm(formId: string, isReleaseCache?: boolean): Promise<void>
...
@@ -262,10 +263,10 @@ releaseForm(formId: string, isReleaseCache?: boolean): Promise<void>
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formHost
from
'
@ohos.app.form.formHost
'
;
try
{
try
{
let
formId
=
'
12400633174999288
'
;
let
formId
:
string
=
'
12400633174999288
'
;
formHost
.
releaseForm
(
formId
,
true
).
then
(()
=>
{
formHost
.
releaseForm
(
formId
,
true
).
then
(()
=>
{
console
.
log
(
'
formHost releaseForm success
'
);
console
.
log
(
'
formHost releaseForm success
'
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Base
.
BusinessError
)
=>
{
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -311,8 +312,8 @@ requestForm(formId: string, callback: AsyncCallback<void>): void
...
@@ -311,8 +312,8 @@ requestForm(formId: string, callback: AsyncCallback<void>): void
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formHost
from
'
@ohos.app.form.formHost
'
;
try
{
try
{
let
formId
=
'
12400633174999288
'
;
let
formId
:
string
=
'
12400633174999288
'
;
formHost
.
requestForm
(
formId
,
(
error
)
=>
{
formHost
.
requestForm
(
formId
,
(
error
:
Base
.
BusinessError
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
}
}
...
@@ -365,10 +366,10 @@ requestForm(formId: string): Promise<void>
...
@@ -365,10 +366,10 @@ requestForm(formId: string): Promise<void>
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formHost
from
'
@ohos.app.form.formHost
'
;
try
{
try
{
let
formId
=
'
12400633174999288
'
;
let
formId
:
string
=
'
12400633174999288
'
;
formHost
.
requestForm
(
formId
).
then
(()
=>
{
formHost
.
requestForm
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost requestForm success
'
);
console
.
log
(
'
formHost requestForm success
'
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Base
.
BusinessError
)
=>
{
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -415,8 +416,8 @@ castToNormalForm(formId: string, callback: AsyncCallback<void>): void
...
@@ -415,8 +416,8 @@ castToNormalForm(formId: string, callback: AsyncCallback<void>): void
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formHost
from
'
@ohos.app.form.formHost
'
;
try
{
try
{
let
formId
=
'
12400633174999288
'
;
let
formId
:
string
=
'
12400633174999288
'
;
formHost
.
castToNormalForm
(
formId
,
(
error
)
=>
{
formHost
.
castToNormalForm
(
formId
,
(
error
:
Base
.
BusinessError
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
}
}
...
@@ -469,10 +470,10 @@ castToNormalForm(formId: string): Promise<void>
...
@@ -469,10 +470,10 @@ castToNormalForm(formId: string): Promise<void>
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formHost
from
'
@ohos.app.form.formHost
'
;
try
{
try
{
let
formId
=
'
12400633174999288
'
;
let
formId
:
string
=
'
12400633174999288
'
;
formHost
.
castToNormalForm
(
formId
).
then
(()
=>
{
formHost
.
castToNormalForm
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost castTempForm success
'
);
console
.
log
(
'
formHost castTempForm success
'
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Base
.
BusinessError
)
=>
{
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -516,8 +517,8 @@ notifyVisibleForms(formIds: Array<string>, callback: AsyncCallback<void
...
@@ -516,8 +517,8 @@ notifyVisibleForms(formIds: Array<string>, callback: AsyncCallback<void
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formHost
from
'
@ohos.app.form.formHost
'
;
try
{
try
{
let
formId
=
[
'
12400633174999288
'
];
let
formId
:
string
[]
=
[
'
12400633174999288
'
];
formHost
.
notifyVisibleForms
(
formId
,
(
error
)
=>
{
formHost
.
notifyVisibleForms
(
formId
,
(
error
:
Base
.
BusinessError
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
}
}
...
@@ -568,10 +569,10 @@ notifyVisibleForms(formIds: Array<string>): Promise<void>
...
@@ -568,10 +569,10 @@ notifyVisibleForms(formIds: Array<string>): Promise<void>
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formHost
from
'
@ohos.app.form.formHost
'
;
try
{
try
{
let
formId
=
[
'
12400633174999288
'
];
let
formId
:
string
[]
=
[
'
12400633174999288
'
];
formHost
.
notifyVisibleForms
(
formId
).
then
(()
=>
{
formHost
.
notifyVisibleForms
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost notifyVisibleForms success
'
);
console
.
log
(
'
formHost notifyVisibleForms success
'
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Base
.
BusinessError
)
=>
{
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -615,8 +616,8 @@ notifyInvisibleForms(formIds: Array<string>, callback: AsyncCallback<vo
...
@@ -615,8 +616,8 @@ notifyInvisibleForms(formIds: Array<string>, callback: AsyncCallback<vo
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formHost
from
'
@ohos.app.form.formHost
'
;
try
{
try
{
let
formId
=
[
'
12400633174999288
'
];
let
formId
:
string
[]
=
[
'
12400633174999288
'
];
formHost
.
notifyInvisibleForms
(
formId
,
(
error
)
=>
{
formHost
.
notifyInvisibleForms
(
formId
,
(
error
:
Base
.
BusinessError
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
}
}
...
@@ -667,10 +668,10 @@ notifyInvisibleForms(formIds: Array<string>): Promise<void>
...
@@ -667,10 +668,10 @@ notifyInvisibleForms(formIds: Array<string>): Promise<void>
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formHost
from
'
@ohos.app.form.formHost
'
;
try
{
try
{
let
formId
=
[
'
12400633174999288
'
];
let
formId
:
string
[]
=
[
'
12400633174999288
'
];
formHost
.
notifyInvisibleForms
(
formId
).
then
(()
=>
{
formHost
.
notifyInvisibleForms
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost notifyInvisibleForms success
'
);
console
.
log
(
'
formHost notifyInvisibleForms success
'
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Base
.
BusinessError
)
=>
{
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -715,8 +716,8 @@ enableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void&
...
@@ -715,8 +716,8 @@ enableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void&
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formHost
from
'
@ohos.app.form.formHost
'
;
try
{
try
{
let
formId
=
[
'
12400633174999288
'
];
let
formId
:
string
[]
=
[
'
12400633174999288
'
];
formHost
.
enableFormsUpdate
(
formId
,
(
error
)
=>
{
formHost
.
enableFormsUpdate
(
formId
,
(
error
:
Base
.
BusinessError
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
}
}
...
@@ -768,10 +769,10 @@ enableFormsUpdate(formIds: Array<string>): Promise<void>
...
@@ -768,10 +769,10 @@ enableFormsUpdate(formIds: Array<string>): Promise<void>
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formHost
from
'
@ohos.app.form.formHost
'
;
try
{
try
{
let
formId
=
[
'
12400633174999288
'
];
let
formId
:
string
[]
=
[
'
12400633174999288
'
];
formHost
.
enableFormsUpdate
(
formId
).
then
(()
=>
{
formHost
.
enableFormsUpdate
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost enableFormsUpdate success
'
);
console
.
log
(
'
formHost enableFormsUpdate success
'
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Base
.
BusinessError
)
=>
{
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -817,8 +818,8 @@ disableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void
...
@@ -817,8 +818,8 @@ disableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formHost
from
'
@ohos.app.form.formHost
'
;
try
{
try
{
let
formId
=
[
'
12400633174999288
'
];
let
formId
:
string
[]
=
[
'
12400633174999288
'
];
formHost
.
disableFormsUpdate
(
formId
,
(
error
)
=>
{
formHost
.
disableFormsUpdate
(
formId
,
(
error
:
Base
.
BusinessError
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
}
}
...
@@ -871,10 +872,10 @@ disableFormsUpdate(formIds: Array<string>): Promise<void>
...
@@ -871,10 +872,10 @@ disableFormsUpdate(formIds: Array<string>): Promise<void>
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formHost
from
'
@ohos.app.form.formHost
'
;
try
{
try
{
let
formId
=
[
'
12400633174999288
'
];
let
formId
:
string
[]
=
[
'
12400633174999288
'
];
formHost
.
disableFormsUpdate
(
formId
).
then
(()
=>
{
formHost
.
disableFormsUpdate
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost disableFormsUpdate success
'
);
console
.
log
(
'
formHost disableFormsUpdate success
'
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Base
.
BusinessError
)
=>
{
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -911,7 +912,7 @@ isSystemReady(callback: AsyncCallback<void>): void
...
@@ -911,7 +912,7 @@ isSystemReady(callback: AsyncCallback<void>): void
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formHost
from
'
@ohos.app.form.formHost
'
;
try
{
try
{
formHost
.
isSystemReady
((
error
,
data
)
=>
{
formHost
.
isSystemReady
((
error
:
Base
.
BusinessError
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
}
}
...
@@ -951,7 +952,7 @@ import formHost from '@ohos.app.form.formHost';
...
@@ -951,7 +952,7 @@ import formHost from '@ohos.app.form.formHost';
try
{
try
{
formHost
.
isSystemReady
().
then
(()
=>
{
formHost
.
isSystemReady
().
then
(()
=>
{
console
.
log
(
'
formHost isSystemReady success
'
);
console
.
log
(
'
formHost isSystemReady success
'
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Base
.
BusinessError
)
=>
{
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -992,13 +993,14 @@ getAllFormsInfo(callback: AsyncCallback<Array<formInfo.FormInfo>>):
...
@@ -992,13 +993,14 @@ getAllFormsInfo(callback: AsyncCallback<Array<formInfo.FormInfo>>):
```
ts
```
ts
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formInfo
from
'
@ohos.app.form.formInfo
'
;
try
{
try
{
formHost
.
getAllFormsInfo
((
error
,
data
)
=>
{
formHost
.
getAllFormsInfo
((
error
:
Base
.
BusinessError
,
data
:
formInfo
.
FormInfo
[]
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
}
else
{
}
else
{
console
.
log
(
'
formHost getAllFormsInfo, data: ${JSON.stringify(data)}
'
);
console
.
log
(
`formHost getAllFormsInfo, data:
${
JSON
.
stringify
(
data
)}
`
);
}
}
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -1038,11 +1040,12 @@ getAllFormsInfo(): Promise<Array<formInfo.FormInfo>>
...
@@ -1038,11 +1040,12 @@ getAllFormsInfo(): Promise<Array<formInfo.FormInfo>>
```
ts
```
ts
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formInfo
from
'
@ohos.app.form.formInfo
'
;
try
{
try
{
formHost
.
getAllFormsInfo
().
then
((
data
)
=>
{
formHost
.
getAllFormsInfo
().
then
((
data
:
formInfo
.
FormInfo
[]
)
=>
{
console
.
log
(
'
formHost getAllFormsInfo data: ${JSON.stringify(data)}
'
);
console
.
log
(
`formHost getAllFormsInfo data:
${
JSON
.
stringify
(
data
)}
`
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Base
.
BusinessError
)
=>
{
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -1085,13 +1088,14 @@ getFormsInfo(bundleName: string, callback: AsyncCallback<Array<formInfo.Fo
...
@@ -1085,13 +1088,14 @@ getFormsInfo(bundleName: string, callback: AsyncCallback<Array<formInfo.Fo
```
ts
```
ts
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formInfo
from
'
@ohos.app.form.formInfo
'
;
try
{
try
{
formHost
.
getFormsInfo
(
'
com.example.ohos.formjsdemo
'
,
(
error
,
data
)
=>
{
formHost
.
getFormsInfo
(
'
com.example.ohos.formjsdemo
'
,
(
error
:
Base
.
BusinessError
,
data
:
formInfo
.
FormInfo
[]
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
}
else
{
}
else
{
console
.
log
(
'
formHost getFormsInfo, data: ${JSON.stringify(data)}
'
);
console
.
log
(
`formHost getFormsInfo, data:
${
JSON
.
stringify
(
data
)}
`
);
}
}
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -1135,9 +1139,10 @@ getFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback<
...
@@ -1135,9 +1139,10 @@ getFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback<
```
ts
```
ts
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formInfo
from
'
@ohos.app.form.formInfo
'
;
try
{
try
{
formHost
.
getFormsInfo
(
'
com.example.ohos.formjsdemo
'
,
'
entry
'
,
(
error
,
data
)
=>
{
formHost
.
getFormsInfo
(
'
com.example.ohos.formjsdemo
'
,
'
entry
'
,
(
error
:
Base
.
BusinessError
,
data
:
formInfo
.
FormInfo
[]
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
}
else
{
}
else
{
...
@@ -1190,11 +1195,12 @@ getFormsInfo(bundleName: string, moduleName?: string): Promise<Array<formI
...
@@ -1190,11 +1195,12 @@ getFormsInfo(bundleName: string, moduleName?: string): Promise<Array<formI
```
ts
```
ts
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formInfo
from
'
@ohos.app.form.formInfo
'
;
try
{
try
{
formHost
.
getFormsInfo
(
'
com.example.ohos.formjsdemo
'
,
'
entry
'
).
then
((
data
)
=>
{
formHost
.
getFormsInfo
(
'
com.example.ohos.formjsdemo
'
,
'
entry
'
).
then
((
data
:
formInfo
.
FormInfo
[]
)
=>
{
console
.
log
(
'
formHost getFormsInfo, data: ${JSON.stringify(data)}
'
);
console
.
log
(
`formHost getFormsInfo, data:
${
JSON
.
stringify
(
data
)}
`
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Base
.
BusinessError
)
=>
{
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -1238,12 +1244,12 @@ deleteInvalidForms(formIds: Array<string>, callback: AsyncCallback<numb
...
@@ -1238,12 +1244,12 @@ deleteInvalidForms(formIds: Array<string>, callback: AsyncCallback<numb
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formHost
from
'
@ohos.app.form.formHost
'
;
try
{
try
{
let
formIds
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
let
formIds
:
string
[]
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
formHost
.
deleteInvalidForms
(
formIds
,
(
error
,
data
)
=>
{
formHost
.
deleteInvalidForms
(
formIds
,
(
error
:
Base
.
BusinessError
,
data
:
number
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
}
else
{
}
else
{
console
.
log
(
'
formHost deleteInvalidForms, data: ${JSON.stringify(data)}
'
);
console
.
log
(
`formHost deleteInvalidForms, data:
${
JSON
.
stringify
(
data
)}
`
);
}
}
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -1292,10 +1298,10 @@ deleteInvalidForms(formIds: Array<string>): Promise<number>
...
@@ -1292,10 +1298,10 @@ deleteInvalidForms(formIds: Array<string>): Promise<number>
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formHost
from
'
@ohos.app.form.formHost
'
;
try
{
try
{
let
formIds
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
let
formIds
:
string
[]
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
formHost
.
deleteInvalidForms
(
formIds
).
then
((
data
)
=>
{
formHost
.
deleteInvalidForms
(
formIds
).
then
((
data
:
number
)
=>
{
console
.
log
(
'
formHost deleteInvalidForms, data: ${JSON.stringify(data)}
'
);
console
.
log
(
`formHost deleteInvalidForms, data:
${
JSON
.
stringify
(
data
)}
`
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Base
.
BusinessError
)
=>
{
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -1338,8 +1344,10 @@ acquireFormState(want: Want, callback: AsyncCallback<formInfo.FormStateInfo&g
...
@@ -1338,8 +1344,10 @@ acquireFormState(want: Want, callback: AsyncCallback<formInfo.FormStateInfo&g
```
ts
```
ts
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
Want
from
'
@ohos.app.ability.Want
'
;
import
formInfo
from
'
@ohos.app.form.formInfo
'
;
let
want
=
{
let
want
:
Want
=
{
'
deviceId
'
:
''
,
'
deviceId
'
:
''
,
'
bundleName
'
:
'
ohos.samples.FormApplication
'
,
'
bundleName
'
:
'
ohos.samples.FormApplication
'
,
'
abilityName
'
:
'
FormAbility
'
,
'
abilityName
'
:
'
FormAbility
'
,
...
@@ -1350,11 +1358,11 @@ let want = {
...
@@ -1350,11 +1358,11 @@ let want = {
}
}
};
};
try
{
try
{
formHost
.
acquireFormState
(
want
,
(
error
,
data
)
=>
{
formHost
.
acquireFormState
(
want
,
(
error
:
Base
.
BusinessError
,
data
:
formInfo
.
FormStateInfo
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
}
else
{
}
else
{
console
.
log
(
'
formHost acquireFormState, data: ${JSON.stringify(data)}
'
);
console
.
log
(
`formHost acquireFormState, data:
${
JSON
.
stringify
(
data
)}
`
);
}
}
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -1402,8 +1410,10 @@ acquireFormState(want: Want): Promise<formInfo.FormStateInfo>
...
@@ -1402,8 +1410,10 @@ acquireFormState(want: Want): Promise<formInfo.FormStateInfo>
```
ts
```
ts
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
Want
from
'
@ohos.app.ability.Want
'
;
import
formInfo
from
'
@ohos.app.form.formInfo
'
;
let
want
=
{
let
want
:
Want
=
{
'
deviceId
'
:
''
,
'
deviceId
'
:
''
,
'
bundleName
'
:
'
ohos.samples.FormApplication
'
,
'
bundleName
'
:
'
ohos.samples.FormApplication
'
,
'
abilityName
'
:
'
FormAbility
'
,
'
abilityName
'
:
'
FormAbility
'
,
...
@@ -1414,9 +1424,9 @@ let want = {
...
@@ -1414,9 +1424,9 @@ let want = {
}
}
};
};
try
{
try
{
formHost
.
acquireFormState
(
want
).
then
((
data
)
=>
{
formHost
.
acquireFormState
(
want
).
then
((
data
:
formInfo
.
FormStateInfo
)
=>
{
console
.
log
(
'
formHost acquireFormState, data: ${JSON.stringify(data)}
'
);
console
.
log
(
`formHost acquireFormState, data:
${
JSON
.
stringify
(
data
)}
`
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Base
.
BusinessError
)
=>
{
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -1453,10 +1463,9 @@ on(type: 'formUninstall', callback: Callback<string>): void
...
@@ -1453,10 +1463,9 @@ on(type: 'formUninstall', callback: Callback<string>): void
```
ts
```
ts
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formHost
from
'
@ohos.app.form.formHost
'
;
let
callback
=
function
(
formId
)
{
formHost
.
on
(
'
formUninstall
'
,
(
formId
:
string
)
=>
{
console
.
log
(
'
formHost on formUninstall, formId: ${formId}
'
);
console
.
log
(
`formHost on formUninstall, formId:
${
formId
}
`
);
}
});
formHost
.
on
(
'
formUninstall
'
,
callback
);
```
```
## off('formUninstall')
## off('formUninstall')
...
@@ -1488,10 +1497,9 @@ off(type: 'formUninstall', callback?: Callback<string>): void
...
@@ -1488,10 +1497,9 @@ off(type: 'formUninstall', callback?: Callback<string>): void
```
ts
```
ts
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formHost
from
'
@ohos.app.form.formHost
'
;
let
callback
=
function
(
formId
)
{
formHost
.
off
(
'
formUninstall
'
,
(
formId
:
string
)
=>
{
console
.
log
(
'
formHost on formUninstall, formId: ${formId}
'
);
console
.
log
(
`formHost on formUninstall, formId:
${
formId
}
`
);
}
});
formHost
.
off
(
'
formUninstall
'
,
callback
);
```
```
## notifyFormsVisible
## notifyFormsVisible
...
@@ -1531,9 +1539,9 @@ notifyFormsVisible(formIds: Array<string>, isVisible: boolean, callback: A
...
@@ -1531,9 +1539,9 @@ notifyFormsVisible(formIds: Array<string>, isVisible: boolean, callback: A
```
ts
```
ts
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formHost
from
'
@ohos.app.form.formHost
'
;
let
formIds
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
let
formIds
:
string
[]
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
try
{
try
{
formHost
.
notifyFormsVisible
(
formIds
,
true
,
(
error
)
=>
{
formHost
.
notifyFormsVisible
(
formIds
,
true
,
(
error
:
Base
.
BusinessError
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
}
}
...
@@ -1585,11 +1593,11 @@ notifyFormsVisible(formIds: Array<string>, isVisible: boolean): Promise<
...
@@ -1585,11 +1593,11 @@ notifyFormsVisible(formIds: Array<string>, isVisible: boolean): Promise<
```
ts
```
ts
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formHost
from
'
@ohos.app.form.formHost
'
;
let
formIds
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
let
formIds
:
string
[]
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
try
{
try
{
formHost
.
notifyFormsVisible
(
formIds
,
true
).
then
(()
=>
{
formHost
.
notifyFormsVisible
(
formIds
,
true
).
then
(()
=>
{
console
.
log
(
'
formHost notifyFormsVisible success
'
);
console
.
log
(
'
formHost notifyFormsVisible success
'
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Base
.
BusinessError
)
=>
{
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -1634,9 +1642,9 @@ notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean, c
...
@@ -1634,9 +1642,9 @@ notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean, c
```
ts
```
ts
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formHost
from
'
@ohos.app.form.formHost
'
;
let
formIds
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
let
formIds
:
string
[]
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
try
{
try
{
formHost
.
notifyFormsEnableUpdate
(
formIds
,
true
,
(
error
)
=>
{
formHost
.
notifyFormsEnableUpdate
(
formIds
,
true
,
(
error
:
Base
.
BusinessError
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
}
}
...
@@ -1688,11 +1696,11 @@ notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean):
...
@@ -1688,11 +1696,11 @@ notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean):
```
ts
```
ts
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formHost
from
'
@ohos.app.form.formHost
'
;
let
formIds
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
let
formIds
:
string
[]
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
try
{
try
{
formHost
.
notifyFormsEnableUpdate
(
formIds
,
true
).
then
(()
=>
{
formHost
.
notifyFormsEnableUpdate
(
formIds
,
true
).
then
(()
=>
{
console
.
log
(
'
formHost notifyFormsEnableUpdate success
'
);
console
.
log
(
'
formHost notifyFormsEnableUpdate success
'
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Base
.
BusinessError
)
=>
{
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -1736,10 +1744,10 @@ shareForm(formId: string, deviceId: string, callback: AsyncCallback<void>)
...
@@ -1736,10 +1744,10 @@ shareForm(formId: string, deviceId: string, callback: AsyncCallback<void>)
```
ts
```
ts
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formHost
from
'
@ohos.app.form.formHost
'
;
let
formId
=
'
12400633174999288
'
;
let
formId
:
string
=
'
12400633174999288
'
;
let
deviceId
=
'
EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2
'
;
let
deviceId
:
string
=
'
EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2
'
;
try
{
try
{
formHost
.
shareForm
(
formId
,
deviceId
,
(
error
)
=>
{
formHost
.
shareForm
(
formId
,
deviceId
,
(
error
:
Base
.
BusinessError
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
}
}
...
@@ -1791,12 +1799,12 @@ shareForm(formId: string, deviceId: string): Promise<void>
...
@@ -1791,12 +1799,12 @@ shareForm(formId: string, deviceId: string): Promise<void>
```
ts
```
ts
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formHost
from
'
@ohos.app.form.formHost
'
;
let
formId
=
'
12400633174999288
'
;
let
formId
:
string
=
'
12400633174999288
'
;
let
deviceId
=
'
EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2
'
;
let
deviceId
:
string
=
'
EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2
'
;
try
{
try
{
formHost
.
shareForm
(
formId
,
deviceId
).
then
(()
=>
{
formHost
.
shareForm
(
formId
,
deviceId
).
then
(()
=>
{
console
.
log
(
'
formHost shareForm success
'
);
console
.
log
(
'
formHost shareForm success
'
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Base
.
BusinessError
)
=>
{
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -1840,9 +1848,9 @@ notifyFormsPrivacyProtected(formIds: Array\<string>, isProtected: boolean, callb
...
@@ -1840,9 +1848,9 @@ notifyFormsPrivacyProtected(formIds: Array\<string>, isProtected: boolean, callb
```
ts
```
ts
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formHost
from
'
@ohos.app.form.formHost
'
;
let
formIds
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
let
formIds
:
string
[]
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
try
{
try
{
formHost
.
notifyFormsPrivacyProtected
(
formIds
,
true
,
(
error
)
=>
{
formHost
.
notifyFormsPrivacyProtected
(
formIds
,
true
,
(
error
:
Base
.
BusinessError
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
}
}
...
@@ -1891,11 +1899,11 @@ notifyFormsPrivacyProtected(formIds: Array\<string\>, isProtected: boolean): Pro
...
@@ -1891,11 +1899,11 @@ notifyFormsPrivacyProtected(formIds: Array\<string\>, isProtected: boolean): Pro
```
ts
```
ts
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formHost
from
'
@ohos.app.form.formHost
'
;
let
formIds
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
let
formIds
:
string
[]
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
try
{
try
{
formHost
.
notifyFormsPrivacyProtected
(
formIds
,
true
).
then
(()
=>
{
formHost
.
notifyFormsPrivacyProtected
(
formIds
,
true
).
then
(()
=>
{
console
.
log
(
'
formHost notifyFormsPrivacyProtected success
'
);
console
.
log
(
'
formHost notifyFormsPrivacyProtected success
'
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Base
.
BusinessError
)
=>
{
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -1937,13 +1945,13 @@ acquireFormData(formId: string, callback: AsyncCallback<{[key: string]: Object}>
...
@@ -1937,13 +1945,13 @@ acquireFormData(formId: string, callback: AsyncCallback<{[key: string]: Object}>
```
ts
```
ts
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formHost
from
'
@ohos.app.form.formHost
'
;
let
formId
=
'
12400633174999288
'
;
let
formId
:
string
=
'
12400633174999288
'
;
try
{
try
{
formHost
.
acquireFormData
(
formId
,
(
error
,
data
)
=>
{
formHost
.
acquireFormData
(
formId
,
(
error
,
data
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
}
else
{
}
else
{
console
.
log
(
'
formHost acquireFormData, data: ${JSON.stringify(data)}
'
);
console
.
log
(
`formHost acquireFormData, data:
${
JSON
.
stringify
(
data
)}
`
);
}
}
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -1989,11 +1997,11 @@ acquireFormData(formId: string): Promise<{[key: string]: Object}>;
...
@@ -1989,11 +1997,11 @@ acquireFormData(formId: string): Promise<{[key: string]: Object}>;
```
ts
```
ts
import
formHost
from
'
@ohos.app.form.formHost
'
;
import
formHost
from
'
@ohos.app.form.formHost
'
;
let
formId
=
'
12400633174999288
'
;
let
formId
:
string
=
'
12400633174999288
'
;
try
{
try
{
formHost
.
acquireFormData
(
formId
).
then
((
data
)
=>
{
formHost
.
acquireFormData
(
formId
).
then
((
data
)
=>
{
console
.
log
(
'
formHost acquireFormData success
'
+
data
);
console
.
log
(
'
formHost acquireFormData success
'
+
data
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Base
.
BusinessError
)
=>
{
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
console
.
error
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
...
...
zh-cn/application-dev/reference/apis/js-apis-app-form-formProvider.md
浏览文件 @
1743c481
...
@@ -9,6 +9,7 @@ FormProvider模块提供了卡片提供方相关接口的能力,开发者在
...
@@ -9,6 +9,7 @@ FormProvider模块提供了卡片提供方相关接口的能力,开发者在
```
ts
```
ts
import
formProvider
from
'
@ohos.app.form.formProvider
'
;
import
formProvider
from
'
@ohos.app.form.formProvider
'
;
import
Base
from
'
@ohos.base
'
;
```
```
## setFormNextRefreshTime
## setFormNextRefreshTime
...
@@ -45,9 +46,9 @@ setFormNextRefreshTime(formId: string, minute: number, callback: AsyncCallback&l
...
@@ -45,9 +46,9 @@ setFormNextRefreshTime(formId: string, minute: number, callback: AsyncCallback&l
**示例:**
**示例:**
```
ts
```
ts
let
formId
=
'
12400633174999288
'
;
let
formId
:
string
=
'
12400633174999288
'
;
try
{
try
{
formProvider
.
setFormNextRefreshTime
(
formId
,
5
,
(
error
)
=>
{
formProvider
.
setFormNextRefreshTime
(
formId
,
5
,
(
error
:
Base
.
BusinessError
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
error
(
`callback error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
console
.
error
(
`callback error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
return
;
return
;
...
@@ -98,11 +99,11 @@ setFormNextRefreshTime(formId: string, minute: number): Promise<void>
...
@@ -98,11 +99,11 @@ setFormNextRefreshTime(formId: string, minute: number): Promise<void>
**示例:**
**示例:**
```
ts
```
ts
let
formId
=
'
12400633174999288
'
;
let
formId
:
string
=
'
12400633174999288
'
;
try
{
try
{
formProvider
.
setFormNextRefreshTime
(
formId
,
5
).
then
(()
=>
{
formProvider
.
setFormNextRefreshTime
(
formId
,
5
).
then
(()
=>
{
console
.
log
(
`formProvider setFormNextRefreshTime success`
);
console
.
log
(
`formProvider setFormNextRefreshTime success`
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Base
.
BusinessError
)
=>
{
console
.
error
(
`promise error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
console
.
error
(
`promise error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -145,10 +146,17 @@ updateForm(formId: string, formBindingData: formBindingData.FormBindingData,call
...
@@ -145,10 +146,17 @@ updateForm(formId: string, formBindingData: formBindingData.FormBindingData,call
```
ts
```
ts
import
formBindingData
from
'
@ohos.app.form.formBindingData
'
;
import
formBindingData
from
'
@ohos.app.form.formBindingData
'
;
let
formId
=
'
12400633174999288
'
;
let
formId
:
string
=
'
12400633174999288
'
;
try
{
try
{
let
obj
=
formBindingData
.
createFormBindingData
({
temperature
:
'
22c
'
,
time
:
'
22:00
'
});
class
createFormBindingDataParamType
{
formProvider
.
updateForm
(
formId
,
obj
,
(
error
)
=>
{
temperature
:
string
time
:
string
}
let
obj
=
formBindingData
.
createFormBindingData
({
temperature
:
'
22c
'
,
time
:
'
22:00
'
}
as
createFormBindingDataParamType
);
formProvider
.
updateForm
(
formId
,
obj
,
(
error
:
Base
.
BusinessError
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
error
(
`callback error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
console
.
error
(
`callback error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
return
;
return
;
...
@@ -200,12 +208,19 @@ updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Pr
...
@@ -200,12 +208,19 @@ updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Pr
```
ts
```
ts
import
formBindingData
from
'
@ohos.app.form.formBindingData
'
;
import
formBindingData
from
'
@ohos.app.form.formBindingData
'
;
let
formId
=
'
12400633174999288
'
;
let
formId
:
string
=
'
12400633174999288
'
;
let
obj
=
formBindingData
.
createFormBindingData
({
temperature
:
'
22c
'
,
time
:
'
22:00
'
});
class
createFormBindingDataParamType
{
temperature
:
string
time
:
string
}
let
obj
=
formBindingData
.
createFormBindingData
({
temperature
:
'
22c
'
,
time
:
'
22:00
'
}
as
createFormBindingDataParamType
);
try
{
try
{
formProvider
.
updateForm
(
formId
,
obj
).
then
(()
=>
{
formProvider
.
updateForm
(
formId
,
obj
).
then
(()
=>
{
console
.
log
(
`formProvider updateForm success`
);
console
.
log
(
`formProvider updateForm success`
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Base
.
BusinessError
)
=>
{
console
.
error
(
`promise error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
console
.
error
(
`promise error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -247,7 +262,7 @@ try {
...
@@ -247,7 +262,7 @@ try {
console
.
error
(
`callback error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
console
.
error
(
`callback error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
return
;
return
;
}
}
console
.
log
(
'
formProvider getFormsInfo, data: ${JSON.stringify(data)}
'
);
console
.
log
(
`formProvider getFormsInfo, data:
${
JSON
.
stringify
(
data
)}
`
);
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
`catch error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
console
.
error
(
`catch error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
...
@@ -294,7 +309,7 @@ try {
...
@@ -294,7 +309,7 @@ try {
console
.
error
(
`callback error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
console
.
error
(
`callback error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
return
;
return
;
}
}
console
.
log
(
'
formProvider getFormsInfo, data: ${JSON.stringify(data)}
'
);
console
.
log
(
`formProvider getFormsInfo, data:
${
JSON
.
stringify
(
data
)}
`
);
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
`catch error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
console
.
error
(
`catch error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
...
@@ -342,9 +357,9 @@ const filter: formInfo.FormInfoFilter = {
...
@@ -342,9 +357,9 @@ const filter: formInfo.FormInfoFilter = {
moduleName
:
'
entry
'
moduleName
:
'
entry
'
};
};
try
{
try
{
formProvider
.
getFormsInfo
(
filter
).
then
((
data
)
=>
{
formProvider
.
getFormsInfo
(
filter
).
then
((
data
:
formInfo
.
FormInfo
[]
)
=>
{
console
.
log
(
'
formProvider getFormsInfo, data: ${JSON.stringify(data)}
'
);
console
.
log
(
`formProvider getFormsInfo, data:
${
JSON
.
stringify
(
data
)}
`
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Base
.
BusinessError
)
=>
{
console
.
error
(
`promise error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
console
.
error
(
`promise error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -386,8 +401,9 @@ requestPublishForm(want: Want, formBindingData: formBindingData.FormBindingData,
...
@@ -386,8 +401,9 @@ requestPublishForm(want: Want, formBindingData: formBindingData.FormBindingData,
```
ts
```
ts
import
formBindingData
from
'
@ohos.app.form.formBindingData
'
;
import
formBindingData
from
'
@ohos.app.form.formBindingData
'
;
import
Want
from
'
@ohos.app.ability.Want
'
;
let
want
=
{
let
want
:
Want
=
{
abilityName
:
'
FormAbility
'
,
abilityName
:
'
FormAbility
'
,
parameters
:
{
parameters
:
{
'
ohos.extra.param.key.form_dimension
'
:
2
,
'
ohos.extra.param.key.form_dimension
'
:
2
,
...
@@ -396,8 +412,15 @@ let want = {
...
@@ -396,8 +412,15 @@ let want = {
}
}
};
};
try
{
try
{
let
obj
=
formBindingData
.
createFormBindingData
({
temperature
:
'
22c
'
,
time
:
'
22:00
'
});
class
createFormBindingDataParamType
{
formProvider
.
requestPublishForm
(
want
,
obj
,
(
error
,
data
)
=>
{
temperature
:
string
time
:
string
}
let
obj
=
formBindingData
.
createFormBindingData
({
temperature
:
'
22c
'
,
time
:
'
22:00
'
}
as
createFormBindingDataParamType
);
formProvider
.
requestPublishForm
(
want
,
obj
,
(
error
:
Base
.
BusinessError
,
data
:
string
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
error
(
`callback error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
console
.
error
(
`callback error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
return
;
return
;
...
@@ -441,7 +464,9 @@ requestPublishForm(want: Want, callback: AsyncCallback<string>): void
...
@@ -441,7 +464,9 @@ requestPublishForm(want: Want, callback: AsyncCallback<string>): void
**示例:**
**示例:**
```
ts
```
ts
let
want
=
{
import
Want
from
'
@ohos.app.ability.Want
'
;
let
want
:
Want
=
{
abilityName
:
'
FormAbility
'
,
abilityName
:
'
FormAbility
'
,
parameters
:
{
parameters
:
{
'
ohos.extra.param.key.form_dimension
'
:
2
,
'
ohos.extra.param.key.form_dimension
'
:
2
,
...
@@ -450,12 +475,12 @@ let want = {
...
@@ -450,12 +475,12 @@ let want = {
}
}
};
};
try
{
try
{
formProvider
.
requestPublishForm
(
want
,
(
error
,
data
)
=>
{
formProvider
.
requestPublishForm
(
want
,
(
error
:
Base
.
BusinessError
,
data
:
string
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
error
(
`callback error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
console
.
error
(
`callback error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
return
;
return
;
}
}
console
.
log
(
'
formProvider requestPublishForm, form ID is: ${JSON.stringify(data)}
'
);
console
.
log
(
`formProvider requestPublishForm, form ID is:
${
JSON
.
stringify
(
data
)}
`
);
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
`catch error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
console
.
error
(
`catch error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
...
@@ -500,7 +525,9 @@ requestPublishForm(want: Want, formBindingData?: formBindingData.FormBindingData
...
@@ -500,7 +525,9 @@ requestPublishForm(want: Want, formBindingData?: formBindingData.FormBindingData
**示例:**
**示例:**
```
ts
```
ts
let
want
=
{
import
Want
from
'
@ohos.app.ability.Want
'
;
let
want
:
Want
=
{
abilityName
:
'
FormAbility
'
,
abilityName
:
'
FormAbility
'
,
parameters
:
{
parameters
:
{
'
ohos.extra.param.key.form_dimension
'
:
2
,
'
ohos.extra.param.key.form_dimension
'
:
2
,
...
@@ -509,9 +536,9 @@ let want = {
...
@@ -509,9 +536,9 @@ let want = {
}
}
};
};
try
{
try
{
formProvider
.
requestPublishForm
(
want
).
then
((
data
)
=>
{
formProvider
.
requestPublishForm
(
want
).
then
((
data
:
string
)
=>
{
console
.
log
(
'
formProvider requestPublishForm success, form ID is : ${JSON.stringify(data)}
'
);
console
.
log
(
`formProvider requestPublishForm success, form ID is :
${
JSON
.
stringify
(
data
)}
`
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Base
.
BusinessError
)
=>
{
console
.
error
(
`promise error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
console
.
error
(
`promise error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -549,13 +576,15 @@ isRequestPublishFormSupported(callback: AsyncCallback<boolean>): void
...
@@ -549,13 +576,15 @@ isRequestPublishFormSupported(callback: AsyncCallback<boolean>): void
**示例:**
**示例:**
```
ts
```
ts
import
Want
from
'
@ohos.app.ability.Want
'
;
try
{
try
{
formProvider
.
isRequestPublishFormSupported
((
error
,
isSupported
)
=>
{
formProvider
.
isRequestPublishFormSupported
((
error
:
Base
.
BusinessError
,
isSupported
:
boolean
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
error
(
`callback error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
console
.
error
(
`callback error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
}
else
{
}
else
{
if
(
isSupported
)
{
if
(
isSupported
)
{
var
w
ant
=
{
let
want
:
W
ant
=
{
abilityName
:
'
FormAbility
'
,
abilityName
:
'
FormAbility
'
,
parameters
:
{
parameters
:
{
'
ohos.extra.param.key.form_dimension
'
:
2
,
'
ohos.extra.param.key.form_dimension
'
:
2
,
...
@@ -564,12 +593,12 @@ try {
...
@@ -564,12 +593,12 @@ try {
}
}
};
};
try
{
try
{
formProvider
.
requestPublishForm
(
want
,
(
error
,
data
)
=>
{
formProvider
.
requestPublishForm
(
want
,
(
error
:
Base
.
BusinessError
,
data
:
string
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
error
(
`callback error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
console
.
error
(
`callback error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
return
;
return
;
}
}
console
.
log
(
'
formProvider requestPublishForm, form ID is: ${JSON.stringify(data)}
'
);
console
.
log
(
`formProvider requestPublishForm, form ID is:
${
JSON
.
stringify
(
data
)}
`
);
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
`catch error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
console
.
error
(
`catch error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
...
@@ -611,10 +640,12 @@ isRequestPublishFormSupported(): Promise<boolean>
...
@@ -611,10 +640,12 @@ isRequestPublishFormSupported(): Promise<boolean>
**示例:**
**示例:**
```
ts
```
ts
import
Want
from
'
@ohos.app.ability.Want
'
;
try
{
try
{
formProvider
.
isRequestPublishFormSupported
().
then
((
isSupported
)
=>
{
formProvider
.
isRequestPublishFormSupported
().
then
((
isSupported
:
boolean
)
=>
{
if
(
isSupported
)
{
if
(
isSupported
)
{
var
w
ant
=
{
let
want
:
W
ant
=
{
abilityName
:
'
FormAbility
'
,
abilityName
:
'
FormAbility
'
,
parameters
:
{
parameters
:
{
'
ohos.extra.param.key.form_dimension
'
:
2
,
'
ohos.extra.param.key.form_dimension
'
:
2
,
...
@@ -623,16 +654,16 @@ try {
...
@@ -623,16 +654,16 @@ try {
}
}
};
};
try
{
try
{
formProvider
.
requestPublishForm
(
want
).
then
((
data
)
=>
{
formProvider
.
requestPublishForm
(
want
).
then
((
data
:
string
)
=>
{
console
.
log
(
'
formProvider requestPublishForm success, form ID is : ${JSON.stringify(data)}
'
);
console
.
log
(
`formProvider requestPublishForm success, form ID is :
${
JSON
.
stringify
(
data
)}
`
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Base
.
BusinessError
)
=>
{
console
.
error
(
`promise error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
console
.
error
(
`promise error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
`catch error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
console
.
error
(
`catch error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
}
}
}
}
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Base
.
BusinessError
)
=>
{
console
.
error
(
`promise error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
console
.
error
(
`promise error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
...
...
zh-cn/application-dev/reference/apis/js-apis-application-formBindingData.md
浏览文件 @
1743c481
...
@@ -53,11 +53,13 @@ import fs from '@ohos.file.fs';
...
@@ -53,11 +53,13 @@ import fs from '@ohos.file.fs';
try
{
try
{
let
fd
=
fs
.
openSync
(
'
/path/to/form.png
'
);
let
fd
=
fs
.
openSync
(
'
/path/to/form.png
'
);
let
obj
=
{
let
createFormBindingDataParam
=
new
Map
<
Object
,
string
|
object
>
();
'
temperature
'
:
'
21°
'
,
let
formImagesParam
=
new
Map
<
Object
,
object
>
();
'
formImages
'
:
{
'
image
'
:
fd
}
formImagesParam
.
set
(
'
image
'
,
fd
);
};
createFormBindingDataParam
.
set
(
"
name
"
,
'
21°
'
);
formBindingData
.
createFormBindingData
(
obj
);
createFormBindingDataParam
.
set
(
'
formImages
'
,
formImagesParam
);
formBindingData
.
createFormBindingData
(
createFormBindingDataParam
);
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
'
catch error, error: ${JSON.stringify(error)}
'
);
console
.
error
(
'
catch error, error: ${JSON.stringify(error)}
'
);
}
}
...
...
zh-cn/application-dev/reference/apis/js-apis-application-formHost.md
浏览文件 @
1743c481
...
@@ -12,6 +12,7 @@ formHost模块提供了卡片使用方相关接口的能力,包括对使用方
...
@@ -12,6 +12,7 @@ formHost模块提供了卡片使用方相关接口的能力,包括对使用方
```
ts
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
import
formHost
from
'
@ohos.application.formHost
'
;
import
Base
from
'
@ohos.base
'
;
```
```
## deleteForm
## deleteForm
...
@@ -36,7 +37,7 @@ deleteForm(formId: string, callback: AsyncCallback<void>): void
...
@@ -36,7 +37,7 @@ deleteForm(formId: string, callback: AsyncCallback<void>): void
```
ts
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
import
formHost
from
'
@ohos.application.formHost
'
;
let
formId
=
'
12400633174999288
'
;
let
formId
:
string
=
'
12400633174999288
'
;
formHost
.
deleteForm
(
formId
,
(
error
,
data
)
=>
{
formHost
.
deleteForm
(
formId
,
(
error
,
data
)
=>
{
if
(
error
.
code
)
{
if
(
error
.
code
)
{
console
.
error
(
'
formHost deleteForm, error: ${JSON.stringify(error)}
'
);
console
.
error
(
'
formHost deleteForm, error: ${JSON.stringify(error)}
'
);
...
@@ -71,10 +72,10 @@ deleteForm(formId: string): Promise<void>
...
@@ -71,10 +72,10 @@ deleteForm(formId: string): Promise<void>
```
ts
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
import
formHost
from
'
@ohos.application.formHost
'
;
let
formId
=
'
12400633174999288
'
;
let
formId
:
string
=
'
12400633174999288
'
;
formHost
.
deleteForm
(
formId
).
then
(()
=>
{
formHost
.
deleteForm
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost deleteForm success
'
);
console
.
log
(
'
formHost deleteForm success
'
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Base
.
BusinessError
)
=>
{
console
.
error
(
'
formHost deleteForm, error: ${JSON.stringify(error)}
'
);
console
.
error
(
'
formHost deleteForm, error: ${JSON.stringify(error)}
'
);
});
});
```
```
...
@@ -101,8 +102,8 @@ releaseForm(formId: string, callback: AsyncCallback<void>): void
...
@@ -101,8 +102,8 @@ releaseForm(formId: string, callback: AsyncCallback<void>): void
```
ts
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
import
formHost
from
'
@ohos.application.formHost
'
;
let
formId
=
'
12400633174999288
'
;
let
formId
:
string
=
'
12400633174999288
'
;
formHost
.
releaseForm
(
formId
,
(
error
,
data
)
=>
{
formHost
.
releaseForm
(
formId
,
(
error
:
Base
.
BusinessError
)
=>
{
if
(
error
.
code
)
{
if
(
error
.
code
)
{
console
.
error
(
'
formHost releaseForm, error: ${JSON.stringify(error)}
'
);
console
.
error
(
'
formHost releaseForm, error: ${JSON.stringify(error)}
'
);
}
else
{
}
else
{
...
@@ -134,8 +135,8 @@ releaseForm(formId: string, isReleaseCache: boolean, callback: AsyncCallback<
...
@@ -134,8 +135,8 @@ releaseForm(formId: string, isReleaseCache: boolean, callback: AsyncCallback<
```
ts
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
import
formHost
from
'
@ohos.application.formHost
'
;
let
formId
=
'
12400633174999288
'
;
let
formId
:
string
=
'
12400633174999288
'
;
formHost
.
releaseForm
(
formId
,
true
,
(
error
,
data
)
=>
{
formHost
.
releaseForm
(
formId
,
true
,
(
error
:
Base
.
BusinessError
)
=>
{
if
(
error
.
code
)
{
if
(
error
.
code
)
{
console
.
error
(
'
formHost releaseForm, error: ${JSON.stringify(error)}
'
);
console
.
error
(
'
formHost releaseForm, error: ${JSON.stringify(error)}
'
);
}
else
{
}
else
{
...
@@ -172,10 +173,10 @@ releaseForm(formId: string, isReleaseCache?: boolean): Promise<void>
...
@@ -172,10 +173,10 @@ releaseForm(formId: string, isReleaseCache?: boolean): Promise<void>
```
ts
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
import
formHost
from
'
@ohos.application.formHost
'
;
let
formId
=
'
12400633174999288
'
;
let
formId
:
string
=
'
12400633174999288
'
;
formHost
.
releaseForm
(
formId
,
true
).
then
(()
=>
{
formHost
.
releaseForm
(
formId
,
true
).
then
(()
=>
{
console
.
log
(
'
formHost releaseForm success
'
);
console
.
log
(
'
formHost releaseForm success
'
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Base
.
BusinessError
)
=>
{
console
.
error
(
'
formHost releaseForm, error: ${JSON.stringify(error)}
'
);
console
.
error
(
'
formHost releaseForm, error: ${JSON.stringify(error)}
'
);
});
});
```
```
...
@@ -202,8 +203,8 @@ requestForm(formId: string, callback: AsyncCallback<void>): void
...
@@ -202,8 +203,8 @@ requestForm(formId: string, callback: AsyncCallback<void>): void
```
ts
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
import
formHost
from
'
@ohos.application.formHost
'
;
let
formId
=
'
12400633174999288
'
;
let
formId
:
string
=
'
12400633174999288
'
;
formHost
.
requestForm
(
formId
,
(
error
,
data
)
=>
{
formHost
.
requestForm
(
formId
,
(
error
:
Base
.
BusinessError
)
=>
{
if
(
error
.
code
)
{
if
(
error
.
code
)
{
console
.
error
(
'
formHost requestForm, error: ${JSON.stringify(error)}
'
);
console
.
error
(
'
formHost requestForm, error: ${JSON.stringify(error)}
'
);
}
}
...
@@ -237,10 +238,10 @@ requestForm(formId: string): Promise<void>
...
@@ -237,10 +238,10 @@ requestForm(formId: string): Promise<void>
```
ts
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
import
formHost
from
'
@ohos.application.formHost
'
;
let
formId
=
'
12400633174999288
'
;
let
formId
:
string
=
'
12400633174999288
'
;
formHost
.
requestForm
(
formId
).
then
(()
=>
{
formHost
.
requestForm
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost requestForm success
'
);
console
.
log
(
'
formHost requestForm success
'
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Base
.
BusinessError
)
=>
{
console
.
error
(
'
formHost requestForm, error: ${JSON.stringify(error)}
'
);
console
.
error
(
'
formHost requestForm, error: ${JSON.stringify(error)}
'
);
});
});
```
```
...
@@ -267,8 +268,8 @@ castTempForm(formId: string, callback: AsyncCallback<void>): void
...
@@ -267,8 +268,8 @@ castTempForm(formId: string, callback: AsyncCallback<void>): void
```
ts
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
import
formHost
from
'
@ohos.application.formHost
'
;
let
formId
=
'
12400633174999288
'
;
let
formId
:
string
=
'
12400633174999288
'
;
formHost
.
castTempForm
(
formId
,
(
error
,
data
)
=>
{
formHost
.
castTempForm
(
formId
,
(
error
:
Base
.
BusinessError
)
=>
{
if
(
error
.
code
)
{
if
(
error
.
code
)
{
console
.
error
(
'
formHost castTempForm, error: ${JSON.stringify(error)}
'
);
console
.
error
(
'
formHost castTempForm, error: ${JSON.stringify(error)}
'
);
}
}
...
@@ -302,10 +303,10 @@ castTempForm(formId: string): Promise<void>
...
@@ -302,10 +303,10 @@ castTempForm(formId: string): Promise<void>
```
ts
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
import
formHost
from
'
@ohos.application.formHost
'
;
let
formId
=
'
12400633174999288
'
;
let
formId
:
string
=
'
12400633174999288
'
;
formHost
.
castTempForm
(
formId
).
then
(()
=>
{
formHost
.
castTempForm
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost castTempForm success
'
);
console
.
log
(
'
formHost castTempForm success
'
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Base
.
BusinessError
)
=>
{
console
.
error
(
'
formHost castTempForm, error: ${JSON.stringify(error)}
'
);
console
.
error
(
'
formHost castTempForm, error: ${JSON.stringify(error)}
'
);
});
});
```
```
...
@@ -332,8 +333,8 @@ notifyVisibleForms(formIds: Array<string>, callback: AsyncCallback<void
...
@@ -332,8 +333,8 @@ notifyVisibleForms(formIds: Array<string>, callback: AsyncCallback<void
```
ts
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
import
formHost
from
'
@ohos.application.formHost
'
;
let
formId
=
[
'
12400633174999288
'
];
let
formId
:
string
[]
=
[
'
12400633174999288
'
];
formHost
.
notifyVisibleForms
(
formId
,
(
error
,
data
)
=>
{
formHost
.
notifyVisibleForms
(
formId
,
(
error
:
Base
.
BusinessError
)
=>
{
if
(
error
.
code
)
{
if
(
error
.
code
)
{
console
.
error
(
'
formHost notifyVisibleForms, error: ${JSON.stringify(error)}
'
);
console
.
error
(
'
formHost notifyVisibleForms, error: ${JSON.stringify(error)}
'
);
}
}
...
@@ -367,10 +368,10 @@ notifyVisibleForms(formIds: Array<string>): Promise<void>
...
@@ -367,10 +368,10 @@ notifyVisibleForms(formIds: Array<string>): Promise<void>
```
ts
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
import
formHost
from
'
@ohos.application.formHost
'
;
let
formId
=
[
'
12400633174999288
'
];
let
formId
:
string
[]
=
[
'
12400633174999288
'
];
formHost
.
notifyVisibleForms
(
formId
).
then
(()
=>
{
formHost
.
notifyVisibleForms
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost notifyVisibleForms success
'
);
console
.
log
(
'
formHost notifyVisibleForms success
'
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Base
.
BusinessError
)
=>
{
console
.
error
(
'
formHost notifyVisibleForms, error: ${JSON.stringify(error)}
'
);
console
.
error
(
'
formHost notifyVisibleForms, error: ${JSON.stringify(error)}
'
);
});
});
```
```
...
@@ -397,8 +398,8 @@ notifyInvisibleForms(formIds: Array<string>, callback: AsyncCallback<vo
...
@@ -397,8 +398,8 @@ notifyInvisibleForms(formIds: Array<string>, callback: AsyncCallback<vo
```
ts
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
import
formHost
from
'
@ohos.application.formHost
'
;
let
formId
=
[
'
12400633174999288
'
];
let
formId
:
string
[]
=
[
'
12400633174999288
'
];
formHost
.
notifyInvisibleForms
(
formId
,
(
error
,
data
)
=>
{
formHost
.
notifyInvisibleForms
(
formId
,
(
error
:
Base
.
BusinessError
)
=>
{
if
(
error
.
code
)
{
if
(
error
.
code
)
{
console
.
error
(
'
formHost notifyInvisibleForms, error: ${JSON.stringify(error)}
'
);
console
.
error
(
'
formHost notifyInvisibleForms, error: ${JSON.stringify(error)}
'
);
}
}
...
@@ -432,10 +433,10 @@ notifyInvisibleForms(formIds: Array<string>): Promise<void>
...
@@ -432,10 +433,10 @@ notifyInvisibleForms(formIds: Array<string>): Promise<void>
```
ts
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
import
formHost
from
'
@ohos.application.formHost
'
;
let
formId
=
[
'
12400633174999288
'
];
let
formId
:
string
[]
=
[
'
12400633174999288
'
];
formHost
.
notifyInvisibleForms
(
formId
).
then
(()
=>
{
formHost
.
notifyInvisibleForms
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost notifyInvisibleForms success
'
);
console
.
log
(
'
formHost notifyInvisibleForms success
'
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Base
.
BusinessError
)
=>
{
console
.
error
(
'
formHost notifyInvisibleForms, error: ${JSON.stringify(error)}
'
);
console
.
error
(
'
formHost notifyInvisibleForms, error: ${JSON.stringify(error)}
'
);
});
});
```
```
...
@@ -462,8 +463,8 @@ enableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void&
...
@@ -462,8 +463,8 @@ enableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void&
```
ts
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
import
formHost
from
'
@ohos.application.formHost
'
;
let
formId
=
[
'
12400633174999288
'
];
let
formId
:
string
[]
=
[
'
12400633174999288
'
];
formHost
.
enableFormsUpdate
(
formId
,
(
error
,
data
)
=>
{
formHost
.
enableFormsUpdate
(
formId
,
(
error
:
Base
.
BusinessError
)
=>
{
if
(
error
.
code
)
{
if
(
error
.
code
)
{
console
.
error
(
'
formHost enableFormsUpdate, error: ${JSON.stringify(error)}
'
);
console
.
error
(
'
formHost enableFormsUpdate, error: ${JSON.stringify(error)}
'
);
}
}
...
@@ -497,10 +498,10 @@ enableFormsUpdate(formIds: Array<string>): Promise<void>
...
@@ -497,10 +498,10 @@ enableFormsUpdate(formIds: Array<string>): Promise<void>
```
ts
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
import
formHost
from
'
@ohos.application.formHost
'
;
let
formId
=
[
'
12400633174999288
'
];
let
formId
:
string
[]
=
[
'
12400633174999288
'
];
formHost
.
enableFormsUpdate
(
formId
).
then
(()
=>
{
formHost
.
enableFormsUpdate
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost enableFormsUpdate success
'
);
console
.
log
(
'
formHost enableFormsUpdate success
'
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Base
.
BusinessError
)
=>
{
console
.
error
(
'
formHost enableFormsUpdate, error: ${JSON.stringify(error)}
'
);
console
.
error
(
'
formHost enableFormsUpdate, error: ${JSON.stringify(error)}
'
);
});
});
```
```
...
@@ -527,8 +528,8 @@ disableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void
...
@@ -527,8 +528,8 @@ disableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void
```
ts
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
import
formHost
from
'
@ohos.application.formHost
'
;
let
formId
=
[
'
12400633174999288
'
];
let
formId
:
string
[]
=
[
'
12400633174999288
'
];
formHost
.
disableFormsUpdate
(
formId
,
(
error
,
data
)
=>
{
formHost
.
disableFormsUpdate
(
formId
,
(
error
:
Base
.
BusinessError
)
=>
{
if
(
error
.
code
)
{
if
(
error
.
code
)
{
console
.
error
(
'
formHost disableFormsUpdate, error: ${JSON.stringify(error)}
'
);
console
.
error
(
'
formHost disableFormsUpdate, error: ${JSON.stringify(error)}
'
);
}
}
...
@@ -562,10 +563,10 @@ disableFormsUpdate(formIds: Array<string>): Promise<void>
...
@@ -562,10 +563,10 @@ disableFormsUpdate(formIds: Array<string>): Promise<void>
```
ts
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
import
formHost
from
'
@ohos.application.formHost
'
;
let
formId
=
[
'
12400633174999288
'
];
let
formId
:
string
[]
=
[
'
12400633174999288
'
];
formHost
.
disableFormsUpdate
(
formId
).
then
(()
=>
{
formHost
.
disableFormsUpdate
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost disableFormsUpdate success
'
);
console
.
log
(
'
formHost disableFormsUpdate success
'
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Base
.
BusinessError
)
=>
{
console
.
error
(
'
formHost disableFormsUpdate, error: ${JSON.stringify(error)}
'
);
console
.
error
(
'
formHost disableFormsUpdate, error: ${JSON.stringify(error)}
'
);
});
});
```
```
...
@@ -589,8 +590,8 @@ isSystemReady(callback: AsyncCallback<void>): void
...
@@ -589,8 +590,8 @@ isSystemReady(callback: AsyncCallback<void>): void
```
ts
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
import
formHost
from
'
@ohos.application.formHost
'
;
let
formId
=
'
12400633174999288
'
;
let
formId
:
string
=
'
12400633174999288
'
;
formHost
.
isSystemReady
((
error
,
data
)
=>
{
formHost
.
isSystemReady
((
error
:
Base
.
BusinessError
)
=>
{
if
(
error
.
code
)
{
if
(
error
.
code
)
{
console
.
error
(
'
formHost isSystemReady, error: ${JSON.stringify(error)}
'
);
console
.
error
(
'
formHost isSystemReady, error: ${JSON.stringify(error)}
'
);
}
}
...
@@ -616,10 +617,10 @@ isSystemReady(): Promise<void>
...
@@ -616,10 +617,10 @@ isSystemReady(): Promise<void>
```
ts
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
import
formHost
from
'
@ohos.application.formHost
'
;
let
formId
=
'
12400633174999288
'
;
let
formId
:
string
=
'
12400633174999288
'
;
formHost
.
isSystemReady
().
then
(()
=>
{
formHost
.
isSystemReady
().
then
(()
=>
{
console
.
log
(
'
formHost isSystemReady success
'
);
console
.
log
(
'
formHost isSystemReady success
'
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Base
.
BusinessError
)
=>
{
console
.
error
(
'
formHost isSystemReady, error: ${JSON.stringify(error)}
'
);
console
.
error
(
'
formHost isSystemReady, error: ${JSON.stringify(error)}
'
);
});
});
```
```
...
@@ -644,8 +645,9 @@ getAllFormsInfo(callback: AsyncCallback<Array<formInfo.FormInfo>>):
...
@@ -644,8 +645,9 @@ getAllFormsInfo(callback: AsyncCallback<Array<formInfo.FormInfo>>):
```
ts
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
import
formHost
from
'
@ohos.application.formHost
'
;
import
formInfo
from
'
@ohos.app.form.formInfo
'
;
formHost
.
getAllFormsInfo
((
error
,
data
)
=>
{
formHost
.
getAllFormsInfo
((
error
:
Base
.
BusinessError
,
data
:
formInfo
.
FormInfo
[]
)
=>
{
if
(
error
.
code
)
{
if
(
error
.
code
)
{
console
.
error
(
'
formHost getAllFormsInfo, error: ${JSON.stringify(error)}
'
);
console
.
error
(
'
formHost getAllFormsInfo, error: ${JSON.stringify(error)}
'
);
}
else
{
}
else
{
...
@@ -674,10 +676,11 @@ getAllFormsInfo(): Promise<Array<formInfo.FormInfo>>
...
@@ -674,10 +676,11 @@ getAllFormsInfo(): Promise<Array<formInfo.FormInfo>>
```
ts
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
import
formHost
from
'
@ohos.application.formHost
'
;
import
formInfo
from
'
@ohos.app.form.formInfo
'
;
formHost
.
getAllFormsInfo
().
then
((
data
)
=>
{
formHost
.
getAllFormsInfo
().
then
((
data
:
formInfo
.
FormInfo
[]
)
=>
{
console
.
log
(
'
formHost getAllFormsInfo data: ${JSON.stringify(data)}
'
);
console
.
log
(
'
formHost getAllFormsInfo data: ${JSON.stringify(data)}
'
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Base
.
BusinessError
)
=>
{
console
.
error
(
'
formHost getAllFormsInfo, error: ${JSON.stringify(error)}
'
);
console
.
error
(
'
formHost getAllFormsInfo, error: ${JSON.stringify(error)}
'
);
});
});
```
```
...
@@ -703,12 +706,13 @@ getFormsInfo(bundleName: string, callback: AsyncCallback<Array<formInfo.Fo
...
@@ -703,12 +706,13 @@ getFormsInfo(bundleName: string, callback: AsyncCallback<Array<formInfo.Fo
```
ts
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
import
formHost
from
'
@ohos.application.formHost
'
;
import
formInfo
from
'
@ohos.app.form.formInfo
'
;
formHost
.
getFormsInfo
(
'
com.example.ohos.formjsdemo
'
,
(
error
,
data
)
=>
{
formHost
.
getFormsInfo
(
'
com.example.ohos.formjsdemo
'
,
(
error
:
Base
.
BusinessError
,
data
:
formInfo
.
FormInfo
[]
)
=>
{
if
(
error
.
code
)
{
if
(
error
.
code
)
{
console
.
error
(
'
formHost getFormsInfo, error: ${JSON.stringify(error)}
'
);
console
.
error
(
`formHost getFormsInfo, error:
${
JSON
.
stringify
(
error
)}
`
);
}
else
{
}
else
{
console
.
log
(
'
formHost getFormsInfo, data: ${JSON.stringify(data)}
'
);
console
.
log
(
`formHost getFormsInfo, data:
${
JSON
.
stringify
(
data
)}
`
);
}
}
});
});
```
```
...
@@ -735,8 +739,9 @@ getFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback<
...
@@ -735,8 +739,9 @@ getFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback<
```
ts
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
import
formHost
from
'
@ohos.application.formHost
'
;
import
formInfo
from
'
@ohos.app.form.formInfo
'
;
formHost
.
getFormsInfo
(
'
com.example.ohos.formjsdemo
'
,
'
entry
'
,
(
error
,
data
)
=>
{
formHost
.
getFormsInfo
(
'
com.example.ohos.formjsdemo
'
,
'
entry
'
,
(
error
:
Base
.
BusinessError
,
data
:
formInfo
.
FormInfo
[]
)
=>
{
if
(
error
.
code
)
{
if
(
error
.
code
)
{
console
.
error
(
'
formHost getFormsInfo, error: ${JSON.stringify(error)}
'
);
console
.
error
(
'
formHost getFormsInfo, error: ${JSON.stringify(error)}
'
);
}
else
{
}
else
{
...
@@ -773,10 +778,10 @@ getFormsInfo(bundleName: string, moduleName?: string): Promise<Array<formI
...
@@ -773,10 +778,10 @@ getFormsInfo(bundleName: string, moduleName?: string): Promise<Array<formI
```
ts
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
import
formHost
from
'
@ohos.application.formHost
'
;
formHost
.
getFormsInfo
(
'
com.example.ohos.formjsdemo
'
,
'
entry
'
).
then
((
data
)
=>
{
formHost
.
getFormsInfo
(
'
com.example.ohos.formjsdemo
'
,
'
entry
'
).
then
((
data
:
formInfo
.
FormInfo
[]
)
=>
{
console
.
log
(
'
formHost getFormsInfo, data: ${JSON.stringify(data)}
'
);
console
.
log
(
`formHost getFormsInfo, data:
${
JSON
.
stringify
(
data
)}
`
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Base
.
BusinessError
)
=>
{
console
.
error
(
'
formHost getFormsInfo, error: ${JSON.stringify(error)}
'
);
console
.
error
(
`formHost getFormsInfo, error:
${
JSON
.
stringify
(
error
)}
`
);
});
});
```
```
...
@@ -802,12 +807,12 @@ deleteInvalidForms(formIds: Array<string>, callback: AsyncCallback<numb
...
@@ -802,12 +807,12 @@ deleteInvalidForms(formIds: Array<string>, callback: AsyncCallback<numb
```
ts
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
import
formHost
from
'
@ohos.application.formHost
'
;
let
formIds
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
let
formIds
:
string
[]
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
formHost
.
deleteInvalidForms
(
formIds
,
(
error
,
data
)
=>
{
formHost
.
deleteInvalidForms
(
formIds
,
(
error
:
Base
.
BusinessError
,
data
:
number
)
=>
{
if
(
error
.
code
)
{
if
(
error
.
code
)
{
console
.
error
(
'
formHost deleteInvalidForms, error: ${JSON.stringify(error)}
'
);
console
.
error
(
`formHost deleteInvalidForms, error:
${
JSON
.
stringify
(
error
)}
`
);
}
else
{
}
else
{
console
.
log
(
'
formHost deleteInvalidForms, data: ${JSON.stringify(data)}
'
);
console
.
log
(
`formHost deleteInvalidForms, data:
${
JSON
.
stringify
(
data
)}
`
);
}
}
});
});
```
```
...
@@ -839,11 +844,11 @@ deleteInvalidForms(formIds: Array<string>): Promise<number>
...
@@ -839,11 +844,11 @@ deleteInvalidForms(formIds: Array<string>): Promise<number>
```
ts
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
import
formHost
from
'
@ohos.application.formHost
'
;
let
formIds
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
let
formIds
:
string
[]
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
formHost
.
deleteInvalidForms
(
formIds
).
then
((
data
)
=>
{
formHost
.
deleteInvalidForms
(
formIds
).
then
((
data
:
number
)
=>
{
console
.
log
(
'
formHost deleteInvalidForms, data: ${JSON.stringify(data)}
'
);
console
.
log
(
`formHost deleteInvalidForms, data:
${
JSON
.
stringify
(
data
)}
`
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Base
.
BusinessError
)
=>
{
console
.
error
(
'
formHost deleteInvalidForms, error: ${JSON.stringify(error)}
'
);
console
.
error
(
`formHost deleteInvalidForms, error:
${
JSON
.
stringify
(
error
)}
`
);
});
});
```
```
...
@@ -868,8 +873,10 @@ acquireFormState(want: Want, callback: AsyncCallback<formInfo.FormStateInfo&g
...
@@ -868,8 +873,10 @@ acquireFormState(want: Want, callback: AsyncCallback<formInfo.FormStateInfo&g
```
ts
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
import
formHost
from
'
@ohos.application.formHost
'
;
import
Want
from
'
@ohos.app.ability.Want
'
;
import
formInfo
from
'
@ohos.app.form.formInfo
'
;
let
want
=
{
let
want
:
Want
=
{
'
deviceId
'
:
''
,
'
deviceId
'
:
''
,
'
bundleName
'
:
'
ohos.samples.FormApplication
'
,
'
bundleName
'
:
'
ohos.samples.FormApplication
'
,
'
abilityName
'
:
'
FormAbility
'
,
'
abilityName
'
:
'
FormAbility
'
,
...
@@ -879,11 +886,11 @@ let want = {
...
@@ -879,11 +886,11 @@ let want = {
'
ohos.extra.param.key.form_dimension
'
:
2
'
ohos.extra.param.key.form_dimension
'
:
2
}
}
};
};
formHost
.
acquireFormState
(
want
,
(
error
,
data
)
=>
{
formHost
.
acquireFormState
(
want
,
(
error
:
Base
.
BusinessError
,
data
:
formInfo
.
FormStateInfo
)
=>
{
if
(
error
.
code
)
{
if
(
error
.
code
)
{
console
.
error
(
'
formHost acquireFormState, error: ${JSON.stringify(error)}
'
);
console
.
error
(
`formHost acquireFormState, error:
${
JSON
.
stringify
(
error
)}
`
);
}
else
{
}
else
{
console
.
log
(
'
formHost acquireFormState, data: ${JSON.stringify(data)}
'
);
console
.
log
(
`formHost acquireFormState, data:
${
JSON
.
stringify
(
data
)}
`
);
}
}
});
});
```
```
...
@@ -914,8 +921,10 @@ acquireFormState(want: Want): Promise<formInfo.FormStateInfo>
...
@@ -914,8 +921,10 @@ acquireFormState(want: Want): Promise<formInfo.FormStateInfo>
```
ts
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
import
formHost
from
'
@ohos.application.formHost
'
;
import
Want
from
'
@ohos.app.ability.Want
'
;
import
formInfo
from
'
@ohos.app.form.formInfo
'
;
let
want
=
{
let
want
:
Want
=
{
'
deviceId
'
:
''
,
'
deviceId
'
:
''
,
'
bundleName
'
:
'
ohos.samples.FormApplication
'
,
'
bundleName
'
:
'
ohos.samples.FormApplication
'
,
'
abilityName
'
:
'
FormAbility
'
,
'
abilityName
'
:
'
FormAbility
'
,
...
@@ -925,10 +934,10 @@ let want = {
...
@@ -925,10 +934,10 @@ let want = {
'
ohos.extra.param.key.form_dimension
'
:
2
'
ohos.extra.param.key.form_dimension
'
:
2
}
}
};
};
formHost
.
acquireFormState
(
want
).
then
((
data
)
=>
{
formHost
.
acquireFormState
(
want
).
then
((
data
:
formInfo
.
FormStateInfo
)
=>
{
console
.
log
(
'
formHost acquireFormState, data: ${JSON.stringify(data)}
'
);
console
.
log
(
`formHost acquireFormState, data:
${
JSON
.
stringify
(
data
)}
`
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Base
.
BusinessError
)
=>
{
console
.
error
(
'
formHost acquireFormState, error: ${JSON.stringify(error)}
'
);
console
.
error
(
`formHost acquireFormState, error:
${
JSON
.
stringify
(
error
)}
`
);
});
});
```
```
...
@@ -952,10 +961,9 @@ on(type: 'formUninstall', callback: Callback<string>): void
...
@@ -952,10 +961,9 @@ on(type: 'formUninstall', callback: Callback<string>): void
```
ts
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
import
formHost
from
'
@ohos.application.formHost
'
;
let
callback
=
function
(
formId
)
{
formHost
.
on
(
'
formUninstall
'
,
(
formId
:
string
)
=>
{
console
.
log
(
'
formHost on formUninstall, formId: ${formId}
'
);
console
.
log
(
`formHost on formUninstall, formId:
${
formId
}
`
);
};
});
formHost
.
on
(
'
formUninstall
'
,
callback
);
```
```
## off('formUninstall')
## off('formUninstall')
...
@@ -978,10 +986,9 @@ off(type: 'formUninstall', callback?: Callback<string>): void
...
@@ -978,10 +986,9 @@ off(type: 'formUninstall', callback?: Callback<string>): void
```
ts
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
import
formHost
from
'
@ohos.application.formHost
'
;
let
callback
=
function
(
formId
)
{
formHost
.
off
(
'
formUninstall
'
,
(
formId
:
string
)
=>
{
console
.
log
(
'
formHost on formUninstall, formId: ${formId}
'
);
console
.
log
(
`formHost on formUninstall, formId:
${
formId
}
`
);
};
});
formHost
.
off
(
'
formUninstall
'
,
callback
);
```
```
## notifyFormsVisible
## notifyFormsVisible
...
@@ -1007,10 +1014,10 @@ notifyFormsVisible(formIds: Array<string>, isVisible: boolean, callback: A
...
@@ -1007,10 +1014,10 @@ notifyFormsVisible(formIds: Array<string>, isVisible: boolean, callback: A
```
ts
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
import
formHost
from
'
@ohos.application.formHost
'
;
let
formIds
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
let
formIds
:
string
[]
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
formHost
.
notifyFormsVisible
(
formIds
,
true
,
(
error
,
data
)
=>
{
formHost
.
notifyFormsVisible
(
formIds
,
true
,
(
error
:
Base
.
BusinessError
)
=>
{
if
(
error
.
code
)
{
if
(
error
.
code
)
{
console
.
error
(
'
formHost notifyFormsVisible, error: ${JSON.stringify(error)}
'
);
console
.
error
(
`formHost notifyFormsVisible, error:
${
JSON
.
stringify
(
error
)}
`
);
}
}
});
});
```
```
...
@@ -1043,11 +1050,11 @@ notifyFormsVisible(formIds: Array<string>, isVisible: boolean): Promise<
...
@@ -1043,11 +1050,11 @@ notifyFormsVisible(formIds: Array<string>, isVisible: boolean): Promise<
```
ts
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
import
formHost
from
'
@ohos.application.formHost
'
;
let
formIds
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
let
formIds
:
string
[]
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
formHost
.
notifyFormsVisible
(
formIds
,
true
).
then
(()
=>
{
formHost
.
notifyFormsVisible
(
formIds
,
true
).
then
(()
=>
{
console
.
log
(
'
formHost notifyFormsVisible success
'
);
console
.
log
(
'
formHost notifyFormsVisible success
'
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Base
.
BusinessError
)
=>
{
console
.
error
(
'
formHost notifyFormsVisible, error: ${JSON.stringify(error)}
'
);
console
.
error
(
`formHost notifyFormsVisible, error:
${
JSON
.
stringify
(
error
)}
`
);
});
});
```
```
...
@@ -1074,8 +1081,8 @@ notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean, c
...
@@ -1074,8 +1081,8 @@ notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean, c
```
ts
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
import
formHost
from
'
@ohos.application.formHost
'
;
let
formIds
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
let
formIds
:
string
[]
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
formHost
.
notifyFormsEnableUpdate
(
formIds
,
true
,
(
error
,
data
)
=>
{
formHost
.
notifyFormsEnableUpdate
(
formIds
,
true
,
(
error
:
Base
.
BusinessError
)
=>
{
if
(
error
.
code
)
{
if
(
error
.
code
)
{
console
.
error
(
'
formHost notifyFormsEnableUpdate, error: ${JSON.stringify(error)}
'
);
console
.
error
(
'
formHost notifyFormsEnableUpdate, error: ${JSON.stringify(error)}
'
);
}
}
...
@@ -1110,10 +1117,10 @@ notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean):
...
@@ -1110,10 +1117,10 @@ notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean):
```
ts
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
import
formHost
from
'
@ohos.application.formHost
'
;
let
formIds
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
let
formIds
:
string
[]
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
formHost
.
notifyFormsEnableUpdate
(
formIds
,
true
).
then
(()
=>
{
formHost
.
notifyFormsEnableUpdate
(
formIds
,
true
).
then
(()
=>
{
console
.
log
(
'
formHost notifyFormsEnableUpdate success
'
);
console
.
log
(
'
formHost notifyFormsEnableUpdate success
'
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Base
.
BusinessError
)
=>
{
console
.
error
(
'
formHost notifyFormsEnableUpdate, error: ${JSON.stringify(error)}
'
);
console
.
error
(
`formHost notifyFormsEnableUpdate, error:
${
JSON
.
stringify
(
error
)}
`
);
});
});
```
```
zh-cn/application-dev/reference/apis/js-apis-application-formProvider.md
浏览文件 @
1743c481
...
@@ -10,6 +10,7 @@ FormProvider模块提供了卡片提供方相关接口的能力,开发者在
...
@@ -10,6 +10,7 @@ FormProvider模块提供了卡片提供方相关接口的能力,开发者在
```
ts
```
ts
import
formProvider
from
'
@ohos.application.formProvider
'
;
import
formProvider
from
'
@ohos.application.formProvider
'
;
import
Base
from
'
@ohos.base
'
```
```
## setFormNextRefreshTime
## setFormNextRefreshTime
...
@@ -31,8 +32,8 @@ setFormNextRefreshTime(formId: string, minute: number, callback: AsyncCallback&l
...
@@ -31,8 +32,8 @@ setFormNextRefreshTime(formId: string, minute: number, callback: AsyncCallback&l
**示例:**
**示例:**
```
ts
```
ts
let
formId
=
'
12400633174999288
'
;
let
formId
:
string
=
'
12400633174999288
'
;
formProvider
.
setFormNextRefreshTime
(
formId
,
5
,
(
error
,
data
)
=>
{
formProvider
.
setFormNextRefreshTime
(
formId
,
5
,
(
error
:
Base
.
BusinessError
)
=>
{
if
(
error
.
code
)
{
if
(
error
.
code
)
{
console
.
error
(
'
formProvider setFormNextRefreshTime, error: ${JSON.stringify(error)}
'
);
console
.
error
(
'
formProvider setFormNextRefreshTime, error: ${JSON.stringify(error)}
'
);
}
}
...
@@ -63,11 +64,11 @@ setFormNextRefreshTime(formId: string, minute: number): Promise<void>
...
@@ -63,11 +64,11 @@ setFormNextRefreshTime(formId: string, minute: number): Promise<void>
**示例:**
**示例:**
```
ts
```
ts
let
formId
=
'
12400633174999288
'
;
let
formId
:
string
=
'
12400633174999288
'
;
formProvider
.
setFormNextRefreshTime
(
formId
,
5
).
then
(()
=>
{
formProvider
.
setFormNextRefreshTime
(
formId
,
5
).
then
(()
=>
{
console
.
log
(
'
formProvider setFormNextRefreshTime success
'
);
console
.
log
(
'
formProvider setFormNextRefreshTime success
'
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Base
.
BusinessError
)
=>
{
console
.
error
(
'
formProvider setFormNextRefreshTime, error: ${JSON.stringify(error)}
'
);
console
.
error
(
`formProvider setFormNextRefreshTime, error:
${
JSON
.
stringify
(
error
)}
`
);
});
});
```
```
...
@@ -93,10 +94,17 @@ updateForm(formId: string, formBindingData: formBindingData.FormBindingData,call
...
@@ -93,10 +94,17 @@ updateForm(formId: string, formBindingData: formBindingData.FormBindingData,call
import
formBindingData
from
'
@ohos.app.form.formBindingData
'
;
import
formBindingData
from
'
@ohos.app.form.formBindingData
'
;
let
formId
=
'
12400633174999288
'
;
let
formId
=
'
12400633174999288
'
;
let
obj
=
formBindingData
.
createFormBindingData
({
temperature
:
'
22c
'
,
time
:
'
22:00
'
});
class
createBindingDataType
{
formProvider
.
updateForm
(
formId
,
obj
,
(
error
,
data
)
=>
{
temperature
:
string
time
:
string
};
let
obj
=
formBindingData
.
createFormBindingData
({
temperature
:
'
22c
'
,
time
:
'
22:00
'
}
as
createBindingDataType
);
formProvider
.
updateForm
(
formId
,
obj
,
(
error
:
Base
.
BusinessError
)
=>
{
if
(
error
.
code
)
{
if
(
error
.
code
)
{
console
.
error
(
'
formProvider updateForm, error: ${JSON.stringify(error)}
'
);
console
.
error
(
`formProvider updateForm, error:
${
JSON
.
stringify
(
error
)}
`
);
}
}
});
});
```
```
...
@@ -127,12 +135,19 @@ updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Pr
...
@@ -127,12 +135,19 @@ updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Pr
```
ts
```
ts
import
formBindingData
from
'
@ohos.application.formBindingData
'
;
import
formBindingData
from
'
@ohos.application.formBindingData
'
;
let
formId
=
'
12400633174999288
'
;
let
formId
:
string
=
'
12400633174999288
'
;
let
obj
=
formBindingData
.
createFormBindingData
({
temperature
:
'
22c
'
,
time
:
'
22:00
'
});
class
createBindingDataType
{
temperature
:
string
time
:
string
};
let
obj
=
formBindingData
.
createFormBindingData
({
temperature
:
'
22c
'
,
time
:
'
22:00
'
}
as
createBindingDataType
);
formProvider
.
updateForm
(
formId
,
obj
).
then
(()
=>
{
formProvider
.
updateForm
(
formId
,
obj
).
then
(()
=>
{
console
.
log
(
'
formProvider updateForm success
'
);
console
.
log
(
'
formProvider updateForm success
'
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Base
.
BusinessError
)
=>
{
console
.
error
(
'
formProvider updateForm, error: ${JSON.stringify(error)}
'
);
console
.
error
(
`formProvider updateForm, error:
${
JSON
.
stringify
(
error
)}
`
);
});
});
```
```
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-application-formExtensionContext.md
浏览文件 @
1743c481
...
@@ -13,6 +13,7 @@ FormExtensionContext模块提供FormExtensionAbility具有的接口和能力。
...
@@ -13,6 +13,7 @@ FormExtensionContext模块提供FormExtensionAbility具有的接口和能力。
```
ts
```
ts
import
common
from
'
@ohos.app.ability.common
'
;
import
common
from
'
@ohos.app.ability.common
'
;
import
Base
from
'
@ohos.base
'
;
```
```
## FormExtensionContext.startAbility
## FormExtensionContext.startAbility
...
@@ -49,12 +50,13 @@ startAbility(want: Want, callback: AsyncCallback<void>): void
...
@@ -49,12 +50,13 @@ startAbility(want: Want, callback: AsyncCallback<void>): void
```
ts
```
ts
import
FormExtensionAbility
from
'
@ohos.app.form.FormExtensionAbility
'
;
import
FormExtensionAbility
from
'
@ohos.app.form.FormExtensionAbility
'
;
import
Want
from
'
@ohos.app.ability.Want
'
;
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
onFormEvent
(
formId
,
message
)
{
onFormEvent
(
formId
:
string
,
message
:
string
)
{
// 当触发卡片message事件时,执行startAbility
// 当触发卡片message事件时,执行startAbility
console
.
log
(
'
FormExtensionAbility onFormEvent, formId: ${formId}, message:${message}
'
);
console
.
log
(
`FormExtensionAbility onFormEvent, formId:
${
formId
}
, message:
${
message
}
`
);
let
want
=
{
let
want
:
Want
=
{
deviceId
:
''
,
deviceId
:
''
,
bundleName
:
'
com.example.formstartability
'
,
bundleName
:
'
com.example.formstartability
'
,
abilityName
:
'
EntryAbility
'
,
abilityName
:
'
EntryAbility
'
,
...
@@ -62,7 +64,7 @@ export default class MyFormExtensionAbility extends FormExtensionAbility {
...
@@ -62,7 +64,7 @@ export default class MyFormExtensionAbility extends FormExtensionAbility {
'
message
'
:
message
'
message
'
:
message
}
}
};
};
this
.
context
.
startAbility
(
want
,
(
error
)
=>
{
this
.
context
.
startAbility
(
want
,
(
error
:
Base
.
BusinessError
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
error
(
'
FormExtensionContext startAbility, error:${JSON.stringify(error)}
'
);
console
.
error
(
'
FormExtensionContext startAbility, error:${JSON.stringify(error)}
'
);
}
else
{
}
else
{
...
@@ -112,12 +114,13 @@ startAbility(want: Want): Promise<void>
...
@@ -112,12 +114,13 @@ startAbility(want: Want): Promise<void>
```
ts
```
ts
import
FormExtensionAbility
from
'
@ohos.app.form.FormExtensionAbility
'
;
import
FormExtensionAbility
from
'
@ohos.app.form.FormExtensionAbility
'
;
import
Want
from
'
@ohos.app.ability.Want
'
;
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
onFormEvent
(
formId
,
message
)
{
onFormEvent
(
formId
:
string
,
message
:
string
)
{
// 当触发卡片message事件时,执行startAbility
// 当触发卡片message事件时,执行startAbility
console
.
log
(
'
FormExtensionAbility onFormEvent, formId:${formId}, message:${message}
'
);
console
.
log
(
`FormExtensionAbility onFormEvent, formId:
${
formId
}
, message:
${
message
}
`
);
let
want
=
{
let
want
:
Want
=
{
deviceId
:
''
,
deviceId
:
''
,
bundleName
:
'
com.example.formstartability
'
,
bundleName
:
'
com.example.formstartability
'
,
abilityName
:
'
EntryAbility
'
,
abilityName
:
'
EntryAbility
'
,
...
@@ -127,7 +130,7 @@ export default class MyFormExtensionAbility extends FormExtensionAbility {
...
@@ -127,7 +130,7 @@ export default class MyFormExtensionAbility extends FormExtensionAbility {
};
};
this
.
context
.
startAbility
(
want
).
then
(()
=>
{
this
.
context
.
startAbility
(
want
).
then
(()
=>
{
console
.
info
(
'
StartAbility Success
'
);
console
.
info
(
'
StartAbility Success
'
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Base
.
BusinessError
)
=>
{
console
.
error
(
'
StartAbility failed
'
);
console
.
error
(
'
StartAbility failed
'
);
});
});
}
}
...
@@ -164,7 +167,6 @@ connectServiceExtensionAbility(want: Want, options: ConnectOptions): number;
...
@@ -164,7 +167,6 @@ connectServiceExtensionAbility(want: Want, options: ConnectOptions): number;
| 16000001 | The specified ability does not exist. |
| 16000001 | The specified ability does not exist. |
| 16000002 | Incorrect ability type. |
| 16000002 | Incorrect ability type. |
| 16000004 | Can not start invisible component. |
| 16000004 | Can not start invisible component. |
| 16000005 | The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000006 | Cross-user operations are not allowed. |
| 16000008 | The crowdtesting application expires. |
| 16000008 | The crowdtesting application expires. |
| 16000053 | The ability is not on the top of the UI. |
| 16000053 | The ability is not on the top of the UI. |
...
@@ -176,15 +178,18 @@ connectServiceExtensionAbility(want: Want, options: ConnectOptions): number;
...
@@ -176,15 +178,18 @@ connectServiceExtensionAbility(want: Want, options: ConnectOptions): number;
**示例:**
**示例:**
```
ts
```
ts
import
FormExtensionAbility
from
'
@ohos.app.form.FormExtensionAbility
'
;
import
FormExtensionAbility
from
'
@ohos.app.form.FormExtensionAbility
'
;
import
Want
from
'
@ohos.app.ability.Want
'
;
import
rpc
from
'
@ohos.rpc
'
;
import
common
from
'
@ohos.app.ability.common
'
;
let
commRemote
=
null
;
let
commRemote
:
rpc
.
IRemoteObject
|
null
=
null
;
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
onFormEvent
(
formId
,
message
)
{
onFormEvent
(
formId
:
string
,
message
:
string
)
{
// 当触发卡片message事件时,执行connectServiceExtensionAbility
// 当触发卡片message事件时,执行connectServiceExtensionAbility
console
.
log
(
`FormExtensionAbility onFormEvent, formId:
${
formId
}
, message:
${
message
}
`
);
console
.
log
(
`FormExtensionAbility onFormEvent, formId:
${
formId
}
, message:
${
message
}
`
);
let
w
ant
=
{
let
want
:
W
ant
=
{
deviceId
:
''
,
deviceId
:
''
,
bundleName
:
'
com.example.formstartability
'
,
bundleName
:
'
com.example.formstartability
'
,
abilityName
:
'
EntryAbility
'
,
abilityName
:
'
EntryAbility
'
,
...
@@ -192,7 +197,7 @@ connectServiceExtensionAbility(want: Want, options: ConnectOptions): number;
...
@@ -192,7 +197,7 @@ connectServiceExtensionAbility(want: Want, options: ConnectOptions): number;
'
message
'
:
message
'
message
'
:
message
}
}
};
};
let
o
ptions
=
{
let
options
:
common
.
ConnectO
ptions
=
{
onConnect
(
elementName
,
remote
)
{
onConnect
(
elementName
,
remote
)
{
commRemote
=
remote
;
// remote 用于与ServiceExtensionAbility进行通信
commRemote
=
remote
;
// remote 用于与ServiceExtensionAbility进行通信
console
.
log
(
'
----------- onConnect -----------
'
);
console
.
log
(
'
----------- onConnect -----------
'
);
...
@@ -201,7 +206,7 @@ connectServiceExtensionAbility(want: Want, options: ConnectOptions): number;
...
@@ -201,7 +206,7 @@ connectServiceExtensionAbility(want: Want, options: ConnectOptions): number;
onFailed
(
code
)
{
console
.
error
(
'
----------- onFailed -----------
'
)
}
onFailed
(
code
)
{
console
.
error
(
'
----------- onFailed -----------
'
)
}
};
};
let
connection
=
null
;
let
connection
:
number
|
null
=
null
;
try
{
try
{
connection
=
this
.
context
.
connectServiceExtensionAbility
(
want
,
options
);
connection
=
this
.
context
.
connectServiceExtensionAbility
(
want
,
options
);
}
catch
(
paramError
)
{
}
catch
(
paramError
)
{
...
@@ -209,8 +214,8 @@ connectServiceExtensionAbility(want: Want, options: ConnectOptions): number;
...
@@ -209,8 +214,8 @@ connectServiceExtensionAbility(want: Want, options: ConnectOptions): number;
console
.
error
(
`error.code:
${
paramError
.
code
}
, error.message:
${
paramError
.
message
}
`
);
console
.
error
(
`error.code:
${
paramError
.
code
}
, error.message:
${
paramError
.
message
}
`
);
}
}
}
}
};
};
```
```
## FormExtensionContext.disconnectServiceExtensionAbility<sup>10+</sup>
## FormExtensionContext.disconnectServiceExtensionAbility<sup>10+</sup>
...
@@ -240,18 +245,20 @@ disconnectServiceExtensionAbility(connection: number, callback:AsyncCallback<
...
@@ -240,18 +245,20 @@ disconnectServiceExtensionAbility(connection: number, callback:AsyncCallback<
**示例:**
**示例:**
```
ts
```
ts
import
FormExtensionAbility
from
'
@ohos.app.form.FormExtensionAbility
'
;
import
FormExtensionAbility
from
'
@ohos.app.form.FormExtensionAbility
'
;
import
rpc
from
'
@ohos.rpc
'
;
import
common
from
'
@ohos.app.ability.common
'
;
// commRemote为onConnect回调内返回的remote对象,此处定义为null无任何实际意义,仅作示例
// commRemote为onConnect回调内返回的remote对象,此处定义为null无任何实际意义,仅作示例
let
commRemote
=
null
;
let
commRemote
:
rpc
.
IRemoteObject
|
null
=
null
;
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
onFormEvent
(
formId
,
message
)
{
onFormEvent
(
formId
:
string
,
message
:
string
)
{
// 实际使用时,connection为connectServiceExtensionAbility中的返回值,此处定义为1无任何实际意义,仅作示例
// 实际使用时,connection为connectServiceExtensionAbility中的返回值,此处定义为1无任何实际意义,仅作示例
let
connection
=
1
;
let
connection
:
number
=
1
;
try
{
try
{
this
.
context
.
disconnectServiceExtensionAbility
(
connection
,
(
e
rror
)
=>
{
this
.
context
.
disconnectServiceExtensionAbility
(
connection
,
(
error
:
Base
.
BusinessE
rror
)
=>
{
commRemote
=
null
;
commRemote
=
null
;
if
(
error
.
code
)
{
if
(
error
.
code
)
{
// 处理业务逻辑错误
// 处理业务逻辑错误
...
@@ -268,8 +275,8 @@ disconnectServiceExtensionAbility(connection: number, callback:AsyncCallback<
...
@@ -268,8 +275,8 @@ disconnectServiceExtensionAbility(connection: number, callback:AsyncCallback<
console
.
error
(
`error.code:
${
paramError
.
code
}
, error.message:
${
paramError
.
message
}
`
);
console
.
error
(
`error.code:
${
paramError
.
code
}
, error.message:
${
paramError
.
message
}
`
);
}
}
}
}
};
};
```
```
## FormExtensionContext.disconnectServiceExtensionAbility<sup>10+</sup>
## FormExtensionContext.disconnectServiceExtensionAbility<sup>10+</sup>
...
@@ -304,24 +311,26 @@ disconnectServiceExtensionAbility(connection: number): Promise<void>;
...
@@ -304,24 +311,26 @@ disconnectServiceExtensionAbility(connection: number): Promise<void>;
**示例:**
**示例:**
```
ts
```
ts
import
FormExtensionAbility
from
'
@ohos.app.form.FormExtensionAbility
'
;
import
FormExtensionAbility
from
'
@ohos.app.form.FormExtensionAbility
'
;
import
rpc
from
'
@ohos.rpc
'
;
import
common
from
'
@ohos.app.ability.common
'
;
// commRemote为onConnect回调内返回的remote对象,此处定义为null无任何实际意义,仅作示例
// commRemote为onConnect回调内返回的remote对象,此处定义为null无任何实际意义,仅作示例
let
commRemote
=
null
;
let
commRemote
:
rpc
.
IRemoteObject
|
null
=
null
;
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
onFormEvent
(
formId
,
message
)
{
onFormEvent
(
formId
:
string
,
message
:
string
)
{
// 实际使用时,connection为connectServiceExtensionAbility中的返回值,此处定义为1无任何实际意义,仅作示例
// 实际使用时,connection为connectServiceExtensionAbility中的返回值,此处定义为1无任何实际意义,仅作示例
let
connection
=
1
;
let
connection
:
number
=
1
;
try
{
try
{
this
.
context
.
disconnectServiceExtensionAbility
(
connection
)
this
.
context
.
disconnectServiceExtensionAbility
(
connection
)
.
then
((
data
)
=>
{
.
then
((
)
=>
{
commRemote
=
null
;
commRemote
=
null
;
// 执行正常业务
// 执行正常业务
console
.
log
(
'
disconnectServiceExtensionAbility succeed
'
);
console
.
log
(
'
disconnectServiceExtensionAbility succeed
'
);
})
})
.
catch
((
e
rror
)
=>
{
.
catch
((
error
:
Base
.
BusinessE
rror
)
=>
{
commRemote
=
null
;
commRemote
=
null
;
// 处理业务逻辑错误
// 处理业务逻辑错误
console
.
error
(
console
.
error
(
...
@@ -333,5 +342,5 @@ disconnectServiceExtensionAbility(connection: number): Promise<void>;
...
@@ -333,5 +342,5 @@ disconnectServiceExtensionAbility(connection: number): Promise<void>;
console
.
error
(
`error.code:
${
paramError
.
code
}
, error.message:
${
paramError
.
message
}
`
);
console
.
error
(
`error.code:
${
paramError
.
code
}
, error.message:
${
paramError
.
message
}
`
);
}
}
}
}
};
};
```
```
zh-cn/application-dev/reference/apis/js-apis-inner-application-missionSnapshot.md
浏览文件 @
1743c481
...
@@ -28,7 +28,7 @@ import missionManager from '@ohos.app.ability.missionManager';
...
@@ -28,7 +28,7 @@ import missionManager from '@ohos.app.ability.missionManager';
**示例:**
**示例:**
```
ts
```
ts
import
ElementName
from
'
@ohos.bundle
'
;
import
ElementName
from
'
@ohos.bundle
.bundleManager
'
;
import
image
from
'
@ohos.multimedia.image
'
;
import
image
from
'
@ohos.multimedia.image
'
;
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
...
...
zh-cn/application-dev/reference/apis/js-apis-notificationManager.md
浏览文件 @
1743c481
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
```
ts
```
ts
import
notificationManager
from
'
@ohos.notificationManager
'
;
import
notificationManager
from
'
@ohos.notificationManager
'
;
import
Base
from
'
@ohos.base
'
;
```
```
## notificationManager.publish
## notificationManager.publish
...
@@ -45,7 +46,7 @@ publish(request: NotificationRequest, callback: AsyncCallback\<void\>): void
...
@@ -45,7 +46,7 @@ publish(request: NotificationRequest, callback: AsyncCallback\<void\>): void
```
ts
```
ts
//publish回调
//publish回调
function
publishCallback
(
err
)
{
function
publishCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`publish failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`publish failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -155,7 +156,7 @@ publish(request: NotificationRequest, userId: number, callback: AsyncCallback\<v
...
@@ -155,7 +156,7 @@ publish(request: NotificationRequest, userId: number, callback: AsyncCallback\<v
```
ts
```
ts
// publish回调
// publish回调
function
publishCallback
(
err
)
{
function
publishCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`publish failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`publish failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -163,7 +164,7 @@ function publishCallback(err) {
...
@@ -163,7 +164,7 @@ function publishCallback(err) {
}
}
}
}
// 用户ID
// 用户ID
let
userId
=
1
;
let
userId
:
number
=
1
;
// 通知Request对象
// 通知Request对象
let
notificationRequest
:
notificationManager
.
NotificationRequest
=
{
let
notificationRequest
:
notificationManager
.
NotificationRequest
=
{
id
:
1
,
id
:
1
,
...
@@ -228,7 +229,7 @@ let notificationRequest: notificationManager.NotificationRequest = {
...
@@ -228,7 +229,7 @@ let notificationRequest: notificationManager.NotificationRequest = {
}
}
};
};
let
userId
=
1
;
let
userId
:
number
=
1
;
notificationManager
.
publish
(
notificationRequest
,
userId
).
then
(()
=>
{
notificationManager
.
publish
(
notificationRequest
,
userId
).
then
(()
=>
{
console
.
info
(
"
publish success
"
);
console
.
info
(
"
publish success
"
);
...
@@ -267,7 +268,7 @@ cancel(id: number, label: string, callback: AsyncCallback\<void\>): void
...
@@ -267,7 +268,7 @@ cancel(id: number, label: string, callback: AsyncCallback\<void\>): void
```
ts
```
ts
// cancel回调
// cancel回调
function
cancelCallback
(
err
)
{
function
cancelCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`cancel failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`cancel failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -341,7 +342,7 @@ cancel(id: number, callback: AsyncCallback\<void\>): void
...
@@ -341,7 +342,7 @@ cancel(id: number, callback: AsyncCallback\<void\>): void
```
ts
```
ts
// cancel回调
// cancel回调
function
cancelCallback
(
err
)
{
function
cancelCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`cancel failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`cancel failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -379,7 +380,7 @@ cancelAll(callback: AsyncCallback\<void\>): void
...
@@ -379,7 +380,7 @@ cancelAll(callback: AsyncCallback\<void\>): void
```
ts
```
ts
// cancel回调
// cancel回调
function
cancelAllCallback
(
err
)
{
function
cancelAllCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`cancelAll failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`cancelAll failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -449,7 +450,7 @@ addSlot(slot: NotificationSlot, callback: AsyncCallback\<void\>): void
...
@@ -449,7 +450,7 @@ addSlot(slot: NotificationSlot, callback: AsyncCallback\<void\>): void
```
ts
```
ts
// addslot回调
// addslot回调
function
addSlotCallBack
(
err
)
{
function
addSlotCallBack
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`addSlot failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`addSlot failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -457,7 +458,7 @@ function addSlotCallBack(err) {
...
@@ -457,7 +458,7 @@ function addSlotCallBack(err) {
}
}
}
}
// 通知slot对象
// 通知slot对象
let
notificationSlot
=
{
let
notificationSlot
:
notificationManager
.
NotificationSlot
=
{
type
:
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
type
:
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
};
};
notificationManager
.
addSlot
(
notificationSlot
,
addSlotCallBack
);
notificationManager
.
addSlot
(
notificationSlot
,
addSlotCallBack
);
...
@@ -496,7 +497,7 @@ addSlot(slot: NotificationSlot): Promise\<void\>
...
@@ -496,7 +497,7 @@ addSlot(slot: NotificationSlot): Promise\<void\>
```
ts
```
ts
// 通知slot对象
// 通知slot对象
let
notificationSlot
=
{
let
notificationSlot
:
notificationManager
.
NotificationSlot
=
{
type
:
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
type
:
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
};
};
notificationManager
.
addSlot
(
notificationSlot
).
then
(()
=>
{
notificationManager
.
addSlot
(
notificationSlot
).
then
(()
=>
{
...
@@ -534,7 +535,7 @@ addSlot(type: SlotType, callback: AsyncCallback\<void\>): void
...
@@ -534,7 +535,7 @@ addSlot(type: SlotType, callback: AsyncCallback\<void\>): void
```
ts
```
ts
// addslot回调
// addslot回调
function
addSlotCallBack
(
err
)
{
function
addSlotCallBack
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`addSlot failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`addSlot failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -611,7 +612,7 @@ addSlots(slots: Array\<NotificationSlot\>, callback: AsyncCallback\<void\>): voi
...
@@ -611,7 +612,7 @@ addSlots(slots: Array\<NotificationSlot\>, callback: AsyncCallback\<void\>): voi
```
ts
```
ts
// addSlots回调
// addSlots回调
function
addSlotsCallBack
(
err
)
{
function
addSlotsCallBack
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`addSlots failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`addSlots failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -619,11 +620,11 @@ function addSlotsCallBack(err) {
...
@@ -619,11 +620,11 @@ function addSlotsCallBack(err) {
}
}
}
}
// 通知slot对象
// 通知slot对象
let
notificationSlot
=
{
let
notificationSlot
:
notificationManager
.
NotificationSlot
=
{
type
:
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
type
:
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
};
};
// 通知slot array 对象
// 通知slot array 对象
let
notificationSlotArray
=
new
Array
();
let
notificationSlotArray
:
notificationManager
.
NotificationSlot
[]
=
new
Array
();
notificationSlotArray
[
0
]
=
notificationSlot
;
notificationSlotArray
[
0
]
=
notificationSlot
;
notificationManager
.
addSlots
(
notificationSlotArray
,
addSlotsCallBack
);
notificationManager
.
addSlots
(
notificationSlotArray
,
addSlotsCallBack
);
...
@@ -662,11 +663,11 @@ addSlots(slots: Array\<NotificationSlot\>): Promise\<void\>
...
@@ -662,11 +663,11 @@ addSlots(slots: Array\<NotificationSlot\>): Promise\<void\>
```
ts
```
ts
// 通知slot对象
// 通知slot对象
let
notificationSlot
=
{
let
notificationSlot
:
notificationManager
.
NotificationSlot
=
{
type
:
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
type
:
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
};
};
// 通知slot array 对象
// 通知slot array 对象
let
notificationSlotArray
=
new
Array
();
let
notificationSlotArray
:
notificationManager
.
NotificationSlot
[]
=
new
Array
();
notificationSlotArray
[
0
]
=
notificationSlot
;
notificationSlotArray
[
0
]
=
notificationSlot
;
notificationManager
.
addSlots
(
notificationSlotArray
).
then
(()
=>
{
notificationManager
.
addSlots
(
notificationSlotArray
).
then
(()
=>
{
...
@@ -703,14 +704,14 @@ getSlot(slotType: SlotType, callback: AsyncCallback\<NotificationSlot\>): void
...
@@ -703,14 +704,14 @@ getSlot(slotType: SlotType, callback: AsyncCallback\<NotificationSlot\>): void
```
ts
```
ts
// getSlot回调
// getSlot回调
function
getSlotCallback
(
err
,
data
)
{
function
getSlotCallback
(
err
:
Base
.
BusinessError
,
data
:
notificationManager
.
NotificationSlot
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`getSlot failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`getSlot failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
console
.
info
(
"
getSlot success
"
);
console
.
info
(
`getSlot success, data is
${
JSON
.
stringify
(
data
)}
`
);
}
}
}
}
let
slotType
=
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
;
let
slotType
:
notificationManager
.
SlotType
=
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
;
notificationManager
.
getSlot
(
slotType
,
getSlotCallback
);
notificationManager
.
getSlot
(
slotType
,
getSlotCallback
);
```
```
...
@@ -747,8 +748,9 @@ getSlot(slotType: SlotType): Promise\<NotificationSlot\>
...
@@ -747,8 +748,9 @@ getSlot(slotType: SlotType): Promise\<NotificationSlot\>
**示例:**
**示例:**
```
ts
```
ts
let
slotType
=
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
;
let
slotType
:
notificationManager
.
SlotType
=
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
;
notificationManager
.
getSlot
(
slotType
).
then
((
data
)
=>
{
notificationManager
.
getSlot
(
slotType
).
then
((
data
:
notificationManager
.
NotificationSlot
)
=>
{
console
.
info
(
"
getSlot success, data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
getSlot success, data:
"
+
JSON
.
stringify
(
data
));
});
});
```
```
...
@@ -781,11 +783,11 @@ getSlots(callback: AsyncCallback\<Array\<NotificationSlot>>): void
...
@@ -781,11 +783,11 @@ getSlots(callback: AsyncCallback\<Array\<NotificationSlot>>): void
```
ts
```
ts
// getSlots回调
// getSlots回调
function
getSlotsCallback
(
err
,
data
)
{
function
getSlotsCallback
(
err
:
Base
.
BusinessError
,
data
:
Array
<
notificationManager
.
NotificationSlot
>
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`getSlots failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`getSlots failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
console
.
info
(
"
getSlots success
"
);
console
.
info
(
`getSlots success, data is
${
JSON
.
stringify
(
data
)}
`
);
}
}
}
}
notificationManager
.
getSlots
(
getSlotsCallback
);
notificationManager
.
getSlots
(
getSlotsCallback
);
...
@@ -818,7 +820,7 @@ getSlots(): Promise\<Array\<NotificationSlot>>
...
@@ -818,7 +820,7 @@ getSlots(): Promise\<Array\<NotificationSlot>>
**示例:**
**示例:**
```
ts
```
ts
notificationManager
.
getSlots
().
then
((
data
)
=>
{
notificationManager
.
getSlots
().
then
((
data
:
Array
<
notificationManager
.
NotificationSlot
>
)
=>
{
console
.
info
(
"
getSlots success, data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
getSlots success, data:
"
+
JSON
.
stringify
(
data
));
});
});
```
```
...
@@ -852,7 +854,7 @@ removeSlot(slotType: SlotType, callback: AsyncCallback\<void\>): void
...
@@ -852,7 +854,7 @@ removeSlot(slotType: SlotType, callback: AsyncCallback\<void\>): void
```
ts
```
ts
// removeSlot回调
// removeSlot回调
function
removeSlotCallback
(
err
)
{
function
removeSlotCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`removeSlot failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`removeSlot failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -860,7 +862,7 @@ function removeSlotCallback(err) {
...
@@ -860,7 +862,7 @@ function removeSlotCallback(err) {
}
}
}
}
let
slotType
=
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
;
let
slotType
=
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
;
notificationManager
.
removeSlot
(
slotType
,
removeSlotCallback
);
notificationManager
.
removeSlot
(
slotType
,
removeSlotCallback
);
```
```
## notificationManager.removeSlot
## notificationManager.removeSlot
...
@@ -890,7 +892,7 @@ removeSlot(slotType: SlotType): Promise\<void\>
...
@@ -890,7 +892,7 @@ removeSlot(slotType: SlotType): Promise\<void\>
**示例:**
**示例:**
```
ts
```
ts
let
slotType
=
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
;
let
slotType
:
notificationManager
.
SlotType
=
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
;
notificationManager
.
removeSlot
(
slotType
).
then
(()
=>
{
notificationManager
.
removeSlot
(
slotType
).
then
(()
=>
{
console
.
info
(
"
removeSlot success
"
);
console
.
info
(
"
removeSlot success
"
);
});
});
...
@@ -923,7 +925,7 @@ removeAllSlots(callback: AsyncCallback\<void\>): void
...
@@ -923,7 +925,7 @@ removeAllSlots(callback: AsyncCallback\<void\>): void
**示例:**
**示例:**
```
ts
```
ts
function
removeAllCallBack
(
err
)
{
function
removeAllCallBack
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`removeAllSlots failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`removeAllSlots failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -993,17 +995,17 @@ setNotificationEnable(bundle: BundleOption, enable: boolean, callback: AsyncCall
...
@@ -993,17 +995,17 @@ setNotificationEnable(bundle: BundleOption, enable: boolean, callback: AsyncCall
**示例:**
**示例:**
```
ts
```
ts
function
setNotificationEnable
nCallback
(
er
r
)
{
function
setNotificationEnable
Callback
(
err
:
Base
.
BusinessErro
r
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`setNotificationEnable
n
Callback failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`setNotificationEnableCallback failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
console
.
info
(
"
setNotificationEnable
n
Callback success
"
);
console
.
info
(
"
setNotificationEnableCallback success
"
);
}
}
}
}
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
bundle
:
"
bundleName1
"
,
};
};
notificationManager
.
setNotificationEnable
(
bundle
,
false
,
setNotificationEnable
n
Callback
);
notificationManager
.
setNotificationEnable
(
bundle
,
false
,
setNotificationEnableCallback
);
```
```
## notificationManager.setNotificationEnable
## notificationManager.setNotificationEnable
...
@@ -1039,7 +1041,7 @@ setNotificationEnable(bundle: BundleOption, enable: boolean): Promise\<void\>
...
@@ -1039,7 +1041,7 @@ setNotificationEnable(bundle: BundleOption, enable: boolean): Promise\<void\>
**示例:**
**示例:**
```
ts
```
ts
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
bundle
:
"
bundleName1
"
,
};
};
notificationManager
.
setNotificationEnable
(
bundle
,
false
).
then
(()
=>
{
notificationManager
.
setNotificationEnable
(
bundle
,
false
).
then
(()
=>
{
...
@@ -1080,16 +1082,18 @@ isNotificationEnabled(bundle: BundleOption, callback: AsyncCallback\<boolean\>):
...
@@ -1080,16 +1082,18 @@ isNotificationEnabled(bundle: BundleOption, callback: AsyncCallback\<boolean\>):
**示例:**
**示例:**
```
ts
```
ts
function
isNotificationEnabledCallback
(
err
,
data
)
{
function
isNotificationEnabledCallback
(
err
:
Base
.
BusinessError
,
data
:
boolean
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`isNotificationEnabled failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`isNotificationEnabled failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
console
.
info
(
"
isNotificationEnabled success
"
);
console
.
info
(
`isNotificationEnabled success, data is
${
JSON
.
stringify
(
data
)}
`
);
}
}
}
}
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
bundle
:
"
bundleName1
"
,
};
};
notificationManager
.
isNotificationEnabled
(
bundle
,
isNotificationEnabledCallback
);
notificationManager
.
isNotificationEnabled
(
bundle
,
isNotificationEnabledCallback
);
```
```
...
@@ -1131,10 +1135,10 @@ isNotificationEnabled(bundle: BundleOption): Promise\<boolean\>
...
@@ -1131,10 +1135,10 @@ isNotificationEnabled(bundle: BundleOption): Promise\<boolean\>
**示例:**
**示例:**
```
ts
```
ts
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
bundle
:
"
bundleName1
"
,
};
};
notificationManager
.
isNotificationEnabled
(
bundle
).
then
((
data
)
=>
{
notificationManager
.
isNotificationEnabled
(
bundle
).
then
((
data
:
boolean
)
=>
{
console
.
info
(
"
isNotificationEnabled success, data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
isNotificationEnabled success, data:
"
+
JSON
.
stringify
(
data
));
});
});
```
```
...
@@ -1170,11 +1174,11 @@ isNotificationEnabled(callback: AsyncCallback\<boolean\>): void
...
@@ -1170,11 +1174,11 @@ isNotificationEnabled(callback: AsyncCallback\<boolean\>): void
**示例:**
**示例:**
```
ts
```
ts
function
isNotificationEnabledCallback
(
err
,
data
)
{
function
isNotificationEnabledCallback
(
err
:
Base
.
BusinessError
,
data
:
boolean
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`isNotificationEnabled failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`isNotificationEnabled failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
console
.
info
(
"
isNotificationEnabled success
"
);
console
.
info
(
`isNotificationEnabled success, data is
${
JSON
.
stringify
(
data
)}
`
);
}
}
}
}
...
@@ -1212,7 +1216,7 @@ isNotificationEnabled(): Promise\<boolean\>
...
@@ -1212,7 +1216,7 @@ isNotificationEnabled(): Promise\<boolean\>
**示例:**
**示例:**
```
ts
```
ts
notificationManager
.
isNotificationEnabled
().
then
((
data
)
=>
{
notificationManager
.
isNotificationEnabled
().
then
((
data
:
boolean
)
=>
{
console
.
info
(
"
isNotificationEnabled success, data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
isNotificationEnabled success, data:
"
+
JSON
.
stringify
(
data
));
});
});
```
```
...
@@ -1250,15 +1254,15 @@ isNotificationEnabled(userId: number, callback: AsyncCallback\<boolean\>): void
...
@@ -1250,15 +1254,15 @@ isNotificationEnabled(userId: number, callback: AsyncCallback\<boolean\>): void
**示例:**
**示例:**
```
ts
```
ts
function
isNotificationEnabledCallback
(
err
,
data
)
{
function
isNotificationEnabledCallback
(
err
:
Base
.
BusinessError
,
data
:
boolean
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`isNotificationEnabled failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`isNotificationEnabled failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
console
.
info
(
"
isNotificationEnabled success
"
);
console
.
info
(
`isNotificationEnabled success, data is
${
JSON
.
stringify
(
data
)}
`
);
}
}
}
}
let
userId
=
1
;
let
userId
:
number
=
1
;
notificationManager
.
isNotificationEnabled
(
userId
,
isNotificationEnabledCallback
);
notificationManager
.
isNotificationEnabled
(
userId
,
isNotificationEnabledCallback
);
```
```
...
@@ -1301,9 +1305,9 @@ isNotificationEnabled(userId: number): Promise\<boolean\>
...
@@ -1301,9 +1305,9 @@ isNotificationEnabled(userId: number): Promise\<boolean\>
**示例:**
**示例:**
```
ts
```
ts
let
userId
=
1
;
let
userId
:
number
=
1
;
notificationManager
.
isNotificationEnabled
(
userId
).
then
((
data
)
=>
{
notificationManager
.
isNotificationEnabled
(
userId
).
then
((
data
:
boolean
)
=>
{
console
.
info
(
"
isNotificationEnabled success, data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
isNotificationEnabled success, data:
"
+
JSON
.
stringify
(
data
));
});
});
```
```
...
@@ -1342,14 +1346,14 @@ displayBadge(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<voi
...
@@ -1342,14 +1346,14 @@ displayBadge(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<voi
**示例:**
**示例:**
```
ts
```
ts
function
displayBadgeCallback
(
err
)
{
function
displayBadgeCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`displayBadge failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`displayBadge failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
console
.
info
(
"
displayBadge success
"
);
console
.
info
(
"
displayBadge success
"
);
}
}
}
}
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
bundle
:
"
bundleName1
"
,
};
};
notificationManager
.
displayBadge
(
bundle
,
false
,
displayBadgeCallback
);
notificationManager
.
displayBadge
(
bundle
,
false
,
displayBadgeCallback
);
...
@@ -1388,7 +1392,7 @@ displayBadge(bundle: BundleOption, enable: boolean): Promise\<void\>
...
@@ -1388,7 +1392,7 @@ displayBadge(bundle: BundleOption, enable: boolean): Promise\<void\>
**示例:**
**示例:**
```
ts
```
ts
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
bundle
:
"
bundleName1
"
,
};
};
notificationManager
.
displayBadge
(
bundle
,
false
).
then
(()
=>
{
notificationManager
.
displayBadge
(
bundle
,
false
).
then
(()
=>
{
...
@@ -1413,7 +1417,7 @@ isBadgeDisplayed(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void
...
@@ -1413,7 +1417,7 @@ isBadgeDisplayed(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | ------------------------ |
| -------- | --------------------- | ---- | ------------------------ |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-notificationCommonDef.md#bundleoption
)
| 是 | 指定应用的包信息。 |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-notificationCommonDef.md#bundleoption
)
| 是 | 指定应用的包信息。 |
| callback | AsyncCallback
\<
void
\>
| 是 | 获取角标使能状态回调函数。 |
| callback | AsyncCallback
\<
boolean
\>
| 是 | 获取角标使能状态回调函数。 |
**错误码:**
**错误码:**
...
@@ -1429,14 +1433,14 @@ isBadgeDisplayed(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void
...
@@ -1429,14 +1433,14 @@ isBadgeDisplayed(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void
**示例:**
**示例:**
```
ts
```
ts
function
isBadgeDisplayedCallback
(
err
,
data
)
{
function
isBadgeDisplayedCallback
(
err
:
Base
.
BusinessError
,
data
:
boolean
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`isBadgeDisplayed failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`isBadgeDisplayed failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
console
.
info
(
"
isBadgeDisplayed success
"
);
console
.
info
(
`isBadgeDisplayed success, data is
${
JSON
.
stringify
(
data
)}
`
);
}
}
}
}
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
bundle
:
"
bundleName1
"
,
};
};
notificationManager
.
isBadgeDisplayed
(
bundle
,
isBadgeDisplayedCallback
);
notificationManager
.
isBadgeDisplayed
(
bundle
,
isBadgeDisplayedCallback
);
...
@@ -1480,10 +1484,11 @@ isBadgeDisplayed(bundle: BundleOption): Promise\<boolean\>
...
@@ -1480,10 +1484,11 @@ isBadgeDisplayed(bundle: BundleOption): Promise\<boolean\>
**示例:**
**示例:**
```
ts
```
ts
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
bundle
:
"
bundleName1
"
,
};
};
notificationManager
.
isBadgeDisplayed
(
bundle
).
then
((
data
)
=>
{
notificationManager
.
isBadgeDisplayed
(
bundle
).
then
((
data
:
boolean
)
=>
{
console
.
info
(
"
isBadgeDisplayed success, data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
isBadgeDisplayed success, data:
"
+
JSON
.
stringify
(
data
));
});
});
```
```
...
@@ -1514,7 +1519,8 @@ setBadgeNumber(badgeNumber: number): Promise\<void\>
...
@@ -1514,7 +1519,8 @@ setBadgeNumber(badgeNumber: number): Promise\<void\>
**示例:**
**示例:**
```
ts
```
ts
let
badgeNumber
=
10
let
badgeNumber
:
number
=
10
;
notificationManager
.
setBadgeNumber
(
badgeNumber
).
then
(()
=>
{
notificationManager
.
setBadgeNumber
(
badgeNumber
).
then
(()
=>
{
console
.
info
(
"
displayBadge success
"
);
console
.
info
(
"
displayBadge success
"
);
});
});
...
@@ -1549,7 +1555,7 @@ setBadgeNumber(badgeNumber: number, callback: AsyncCallback\<void\>): void
...
@@ -1549,7 +1555,7 @@ setBadgeNumber(badgeNumber: number, callback: AsyncCallback\<void\>): void
**示例:**
**示例:**
```
ts
```
ts
function
setBadgeNumberCallback
(
err
)
{
function
setBadgeNumberCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
info
(
`displayBadge failed code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
info
(
`displayBadge failed code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -1557,7 +1563,7 @@ function setBadgeNumberCallback(err) {
...
@@ -1557,7 +1563,7 @@ function setBadgeNumberCallback(err) {
}
}
}
}
let
badgeNumber
=
10
let
badgeNumber
:
number
=
10
;
notificationManager
.
setBadgeNumber
(
badgeNumber
,
setBadgeNumberCallback
);
notificationManager
.
setBadgeNumber
(
badgeNumber
,
setBadgeNumberCallback
);
```
```
...
@@ -1595,17 +1601,17 @@ setSlotByBundle(bundle: BundleOption, slot: NotificationSlot, callback: AsyncCal
...
@@ -1595,17 +1601,17 @@ setSlotByBundle(bundle: BundleOption, slot: NotificationSlot, callback: AsyncCal
**示例:**
**示例:**
```
ts
```
ts
function
setSlotByBundleCallback
(
err
)
{
function
setSlotByBundleCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`setSlotByBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`setSlotByBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
console
.
info
(
"
setSlotByBundle success
"
);
console
.
info
(
"
setSlotByBundle success
"
);
}
}
}
}
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
bundle
:
"
bundleName1
"
,
};
};
let
notificationSlot
=
{
let
notificationSlot
:
notificationManager
.
NotificationSlot
=
{
type
:
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
type
:
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
};
};
notificationManager
.
setSlotByBundle
(
bundle
,
notificationSlot
,
setSlotByBundleCallback
);
notificationManager
.
setSlotByBundle
(
bundle
,
notificationSlot
,
setSlotByBundleCallback
);
...
@@ -1644,12 +1650,14 @@ setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise\<void\>
...
@@ -1644,12 +1650,14 @@ setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise\<void\>
**示例:**
**示例:**
```
ts
```
ts
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
bundle
:
"
bundleName1
"
,
};
};
let
notificationSlot
=
{
let
notificationSlot
:
notificationManager
.
NotificationSlot
=
{
type
:
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
type
:
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
};
};
notificationManager
.
setSlotByBundle
(
bundle
,
notificationSlot
).
then
(()
=>
{
notificationManager
.
setSlotByBundle
(
bundle
,
notificationSlot
).
then
(()
=>
{
console
.
info
(
"
setSlotByBundle success
"
);
console
.
info
(
"
setSlotByBundle success
"
);
});
});
...
@@ -1688,14 +1696,14 @@ getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback\<Array\<Notificat
...
@@ -1688,14 +1696,14 @@ getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback\<Array\<Notificat
**示例:**
**示例:**
```
ts
```
ts
function
getSlotsByBundleCallback
(
err
,
data
)
{
function
getSlotsByBundleCallback
(
err
:
Base
.
BusinessError
,
data
:
Array
<
notificationManager
.
NotificationSlot
>
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`getSlotByBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`getSlotByBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
console
.
info
(
"
getSlotsByBundle success
"
);
console
.
info
(
`getSlotsByBundle success, data is
${
JSON
.
stringify
(
data
)}
`
);
}
}
}
}
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
bundle
:
"
bundleName1
"
,
};
};
notificationManager
.
getSlotsByBundle
(
bundle
,
getSlotsByBundleCallback
);
notificationManager
.
getSlotsByBundle
(
bundle
,
getSlotsByBundleCallback
);
...
@@ -1739,10 +1747,11 @@ getSlotsByBundle(bundle: BundleOption): Promise\<Array\<NotificationSlot>>
...
@@ -1739,10 +1747,11 @@ getSlotsByBundle(bundle: BundleOption): Promise\<Array\<NotificationSlot>>
**示例:**
**示例:**
```
ts
```
ts
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
bundle
:
"
bundleName1
"
,
};
};
notificationManager
.
getSlotsByBundle
(
bundle
).
then
((
data
)
=>
{
notificationManager
.
getSlotsByBundle
(
bundle
).
then
((
data
:
Array
<
notificationManager
.
NotificationSlot
>
)
=>
{
console
.
info
(
"
getSlotsByBundle success, data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
getSlotsByBundle success, data:
"
+
JSON
.
stringify
(
data
));
});
});
```
```
...
@@ -1780,16 +1789,18 @@ getSlotNumByBundle(bundle: BundleOption, callback: AsyncCallback\<number\>): voi
...
@@ -1780,16 +1789,18 @@ getSlotNumByBundle(bundle: BundleOption, callback: AsyncCallback\<number\>): voi
**示例:**
**示例:**
```
ts
```
ts
function
getSlotNumByBundleCallback
(
err
,
data
)
{
function
getSlotNumByBundleCallback
(
err
:
Base
.
BusinessError
,
data
:
number
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`getSlotByBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`getSlotByBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
console
.
info
(
"
getSlotNumByBundle success
"
);
console
.
info
(
`getSlotNumByBundle success data is
${
JSON
.
stringify
(
data
)}
`
);
}
}
}
}
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
bundle
:
"
bundleName1
"
,
};
};
notificationManager
.
getSlotNumByBundle
(
bundle
,
getSlotNumByBundleCallback
);
notificationManager
.
getSlotNumByBundle
(
bundle
,
getSlotNumByBundleCallback
);
```
```
...
@@ -1831,10 +1842,11 @@ getSlotNumByBundle(bundle: BundleOption): Promise\<number\>
...
@@ -1831,10 +1842,11 @@ getSlotNumByBundle(bundle: BundleOption): Promise\<number\>
**示例:**
**示例:**
```
ts
```
ts
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
bundle
:
"
bundleName1
"
,
};
};
notificationManager
.
getSlotNumByBundle
(
bundle
).
then
((
data
)
=>
{
notificationManager
.
getSlotNumByBundle
(
bundle
).
then
((
data
:
number
)
=>
{
console
.
info
(
"
getSlotNumByBundle success, data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
getSlotNumByBundle success, data:
"
+
JSON
.
stringify
(
data
));
});
});
```
```
...
@@ -1869,11 +1881,11 @@ getAllActiveNotifications(callback: AsyncCallback\<Array\<NotificationRequest>>)
...
@@ -1869,11 +1881,11 @@ getAllActiveNotifications(callback: AsyncCallback\<Array\<NotificationRequest>>)
**示例:**
**示例:**
```
ts
```
ts
function
getAllActiveNotificationsCallback
(
err
,
data
)
{
function
getAllActiveNotificationsCallback
(
err
:
Base
.
BusinessError
,
data
:
Array
<
notificationManager
.
NotificationRequest
>
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`getAllActiveNotifications failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`getAllActiveNotifications failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
console
.
info
(
"
getAllActiveNotifications success
"
);
console
.
info
(
`getAllActiveNotifications success, data is
${
JSON
.
stringify
(
data
)}
`
);
}
}
}
}
...
@@ -1911,7 +1923,7 @@ getAllActiveNotifications(): Promise\<Array\<[NotificationRequest](js-apis-inner
...
@@ -1911,7 +1923,7 @@ getAllActiveNotifications(): Promise\<Array\<[NotificationRequest](js-apis-inner
**示例:**
**示例:**
```
ts
```
ts
notificationManager
.
getAllActiveNotifications
().
then
((
data
)
=>
{
notificationManager
.
getAllActiveNotifications
().
then
((
data
:
Array
<
notificationManager
.
NotificationRequest
>
)
=>
{
console
.
info
(
"
getAllActiveNotifications success, data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
getAllActiveNotifications success, data:
"
+
JSON
.
stringify
(
data
));
});
});
```
```
...
@@ -1943,11 +1955,11 @@ getActiveNotificationCount(callback: AsyncCallback\<number\>): void
...
@@ -1943,11 +1955,11 @@ getActiveNotificationCount(callback: AsyncCallback\<number\>): void
**示例:**
**示例:**
```
ts
```
ts
function
getActiveNotificationCountCallback
(
err
,
data
)
{
function
getActiveNotificationCountCallback
(
err
:
Base
.
BusinessError
,
data
:
number
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`getActiveNotificationCount failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`getActiveNotificationCount failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
console
.
info
(
"
getActiveNotificationCount success
"
);
console
.
info
(
`getActiveNotificationCount success, data is
${
JSON
.
stringify
(
data
)}
`
);
}
}
}
}
...
@@ -1981,7 +1993,7 @@ getActiveNotificationCount(): Promise\<number\>
...
@@ -1981,7 +1993,7 @@ getActiveNotificationCount(): Promise\<number\>
**示例:**
**示例:**
```
ts
```
ts
notificationManager
.
getActiveNotificationCount
().
then
((
data
)
=>
{
notificationManager
.
getActiveNotificationCount
().
then
((
data
:
number
)
=>
{
console
.
info
(
"
getActiveNotificationCount success, data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
getActiveNotificationCount success, data:
"
+
JSON
.
stringify
(
data
));
});
});
```
```
...
@@ -2013,7 +2025,7 @@ getActiveNotifications(callback: AsyncCallback\<Array\<NotificationRequest>>): v
...
@@ -2013,7 +2025,7 @@ getActiveNotifications(callback: AsyncCallback\<Array\<NotificationRequest>>): v
**示例:**
**示例:**
```
ts
```
ts
function
getActiveNotificationsCallback
(
err
,
data
)
{
function
getActiveNotificationsCallback
(
err
:
Base
.
BusinessError
,
data
:
Array
<
notificationManager
.
NotificationRequest
>
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`getActiveNotifications failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`getActiveNotifications failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -2051,7 +2063,7 @@ getActiveNotifications(): Promise\<Array\<[NotificationRequest](js-apis-inner-no
...
@@ -2051,7 +2063,7 @@ getActiveNotifications(): Promise\<Array\<[NotificationRequest](js-apis-inner-no
**示例:**
**示例:**
```
ts
```
ts
notificationManager
.
getActiveNotifications
().
then
((
data
)
=>
{
notificationManager
.
getActiveNotifications
().
then
((
data
:
Array
<
notificationManager
.
NotificationRequest
>
)
=>
{
console
.
info
(
"
removeGroupByBundle success, data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
removeGroupByBundle success, data:
"
+
JSON
.
stringify
(
data
));
});
});
```
```
...
@@ -2084,7 +2096,7 @@ cancelGroup(groupName: string, callback: AsyncCallback\<void\>): void
...
@@ -2084,7 +2096,7 @@ cancelGroup(groupName: string, callback: AsyncCallback\<void\>): void
**示例:**
**示例:**
```
ts
```
ts
function
cancelGroupCallback
(
err
)
{
function
cancelGroupCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`cancelGroup failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`cancelGroup failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -2092,7 +2104,7 @@ function cancelGroupCallback(err) {
...
@@ -2092,7 +2104,7 @@ function cancelGroupCallback(err) {
}
}
}
}
let
groupName
=
"
GroupName
"
;
let
groupName
:
string
=
"
GroupName
"
;
notificationManager
.
cancelGroup
(
groupName
,
cancelGroupCallback
);
notificationManager
.
cancelGroup
(
groupName
,
cancelGroupCallback
);
```
```
...
@@ -2124,7 +2136,7 @@ cancelGroup(groupName: string): Promise\<void\>
...
@@ -2124,7 +2136,7 @@ cancelGroup(groupName: string): Promise\<void\>
**示例:**
**示例:**
```
ts
```
ts
let
groupName
=
"
GroupName
"
;
let
groupName
:
string
=
"
GroupName
"
;
notificationManager
.
cancelGroup
(
groupName
).
then
(()
=>
{
notificationManager
.
cancelGroup
(
groupName
).
then
(()
=>
{
console
.
info
(
"
cancelGroup success
"
);
console
.
info
(
"
cancelGroup success
"
);
});
});
...
@@ -2164,7 +2176,7 @@ removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCall
...
@@ -2164,7 +2176,7 @@ removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCall
**示例:**
**示例:**
```
ts
```
ts
function
removeGroupByBundleCallback
(
err
)
{
function
removeGroupByBundleCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`removeGroupByBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`removeGroupByBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -2172,8 +2184,8 @@ function removeGroupByBundleCallback(err) {
...
@@ -2172,8 +2184,8 @@ function removeGroupByBundleCallback(err) {
}
}
}
}
let
bundleOption
=
{
bundle
:
"
Bundle
"
};
let
bundleOption
:
notificationManager
.
BundleOption
=
{
bundle
:
"
Bundle
"
};
let
groupName
=
"
GroupName
"
;
let
groupName
:
string
=
"
GroupName
"
;
notificationManager
.
removeGroupByBundle
(
bundleOption
,
groupName
,
removeGroupByBundleCallback
);
notificationManager
.
removeGroupByBundle
(
bundleOption
,
groupName
,
removeGroupByBundleCallback
);
```
```
...
@@ -2211,8 +2223,9 @@ removeGroupByBundle(bundle: BundleOption, groupName: string): Promise\<void\>
...
@@ -2211,8 +2223,9 @@ removeGroupByBundle(bundle: BundleOption, groupName: string): Promise\<void\>
**示例:**
**示例:**
```
ts
```
ts
let
bundleOption
=
{
bundle
:
"
Bundle
"
};
let
bundleOption
:
notificationManager
.
BundleOption
=
{
bundle
:
"
Bundle
"
};
let
groupName
=
"
GroupName
"
;
let
groupName
:
string
=
"
GroupName
"
;
notificationManager
.
removeGroupByBundle
(
bundleOption
,
groupName
).
then
(()
=>
{
notificationManager
.
removeGroupByBundle
(
bundleOption
,
groupName
).
then
(()
=>
{
console
.
info
(
"
removeGroupByBundle success
"
);
console
.
info
(
"
removeGroupByBundle success
"
);
});
});
...
@@ -2251,7 +2264,7 @@ setDoNotDisturbDate(date: DoNotDisturbDate, callback: AsyncCallback\<void\>): vo
...
@@ -2251,7 +2264,7 @@ setDoNotDisturbDate(date: DoNotDisturbDate, callback: AsyncCallback\<void\>): vo
**示例:**
**示例:**
```
ts
```
ts
function
setDoNotDisturbDateCallback
(
err
)
{
function
setDoNotDisturbDateCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`setDoNotDisturbDate failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`setDoNotDisturbDate failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -2259,7 +2272,7 @@ function setDoNotDisturbDateCallback(err) {
...
@@ -2259,7 +2272,7 @@ function setDoNotDisturbDateCallback(err) {
}
}
}
}
let
doNotDisturbDate
=
{
let
doNotDisturbDate
:
notificationManager
.
DoNotDisturbDate
=
{
type
:
notificationManager
.
DoNotDisturbType
.
TYPE_ONCE
,
type
:
notificationManager
.
DoNotDisturbType
.
TYPE_ONCE
,
begin
:
new
Date
(),
begin
:
new
Date
(),
end
:
new
Date
(
2021
,
11
,
15
,
18
,
0
)
end
:
new
Date
(
2021
,
11
,
15
,
18
,
0
)
...
@@ -2300,7 +2313,7 @@ setDoNotDisturbDate(date: DoNotDisturbDate): Promise\<void\>
...
@@ -2300,7 +2313,7 @@ setDoNotDisturbDate(date: DoNotDisturbDate): Promise\<void\>
**示例:**
**示例:**
```
ts
```
ts
let
doNotDisturbDate
=
{
let
doNotDisturbDate
:
notificationManager
.
DoNotDisturbDate
=
{
type
:
notificationManager
.
DoNotDisturbType
.
TYPE_ONCE
,
type
:
notificationManager
.
DoNotDisturbType
.
TYPE_ONCE
,
begin
:
new
Date
(),
begin
:
new
Date
(),
end
:
new
Date
(
2021
,
11
,
15
,
18
,
0
)
end
:
new
Date
(
2021
,
11
,
15
,
18
,
0
)
...
@@ -2346,7 +2359,7 @@ setDoNotDisturbDate(date: DoNotDisturbDate, userId: number, callback: AsyncCallb
...
@@ -2346,7 +2359,7 @@ setDoNotDisturbDate(date: DoNotDisturbDate, userId: number, callback: AsyncCallb
**示例:**
**示例:**
```
ts
```
ts
function
setDoNotDisturbDateCallback
(
err
)
{
function
setDoNotDisturbDateCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`setDoNotDisturbDate failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`setDoNotDisturbDate failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -2354,13 +2367,13 @@ function setDoNotDisturbDateCallback(err) {
...
@@ -2354,13 +2367,13 @@ function setDoNotDisturbDateCallback(err) {
}
}
}
}
let
doNotDisturbDate
=
{
let
doNotDisturbDate
:
notificationManager
.
DoNotDisturbDate
=
{
type
:
notificationManager
.
DoNotDisturbType
.
TYPE_ONCE
,
type
:
notificationManager
.
DoNotDisturbType
.
TYPE_ONCE
,
begin
:
new
Date
(),
begin
:
new
Date
(),
end
:
new
Date
(
2021
,
11
,
15
,
18
,
0
)
end
:
new
Date
(
2021
,
11
,
15
,
18
,
0
)
};
};
let
userId
=
1
;
let
userId
:
number
=
1
;
notificationManager
.
setDoNotDisturbDate
(
doNotDisturbDate
,
userId
,
setDoNotDisturbDateCallback
);
notificationManager
.
setDoNotDisturbDate
(
doNotDisturbDate
,
userId
,
setDoNotDisturbDateCallback
);
```
```
...
@@ -2399,13 +2412,13 @@ setDoNotDisturbDate(date: DoNotDisturbDate, userId: number): Promise\<void\>
...
@@ -2399,13 +2412,13 @@ setDoNotDisturbDate(date: DoNotDisturbDate, userId: number): Promise\<void\>
**示例:**
**示例:**
```
ts
```
ts
let
doNotDisturbDate
=
{
let
doNotDisturbDate
:
notificationManager
.
DoNotDisturbDate
=
{
type
:
notificationManager
.
DoNotDisturbType
.
TYPE_ONCE
,
type
:
notificationManager
.
DoNotDisturbType
.
TYPE_ONCE
,
begin
:
new
Date
(),
begin
:
new
Date
(),
end
:
new
Date
(
2021
,
11
,
15
,
18
,
0
)
end
:
new
Date
(
2021
,
11
,
15
,
18
,
0
)
};
};
let
userId
=
1
;
let
userId
:
number
=
1
;
notificationManager
.
setDoNotDisturbDate
(
doNotDisturbDate
,
userId
).
then
(()
=>
{
notificationManager
.
setDoNotDisturbDate
(
doNotDisturbDate
,
userId
).
then
(()
=>
{
console
.
info
(
"
setDoNotDisturbDate success
"
);
console
.
info
(
"
setDoNotDisturbDate success
"
);
...
@@ -2445,11 +2458,11 @@ getDoNotDisturbDate(callback: AsyncCallback\<DoNotDisturbDate\>): void
...
@@ -2445,11 +2458,11 @@ getDoNotDisturbDate(callback: AsyncCallback\<DoNotDisturbDate\>): void
**示例:**
**示例:**
```
ts
```
ts
function
getDoNotDisturbDateCallback
(
err
,
data
)
{
function
getDoNotDisturbDateCallback
(
err
:
Base
.
BusinessError
,
data
:
notificationManager
.
DoNotDisturbDate
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`getDoNotDisturbDate failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`getDoNotDisturbDate failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
console
.
info
(
"
getDoNotDisturbDate success
"
);
console
.
info
(
`getDoNotDisturbDate success, data is
${
JSON
.
stringify
(
data
)}
`
);
}
}
}
}
...
@@ -2488,7 +2501,7 @@ getDoNotDisturbDate(): Promise\<DoNotDisturbDate\>
...
@@ -2488,7 +2501,7 @@ getDoNotDisturbDate(): Promise\<DoNotDisturbDate\>
**示例:**
**示例:**
```
ts
```
ts
notificationManager
.
getDoNotDisturbDate
().
then
((
data
)
=>
{
notificationManager
.
getDoNotDisturbDate
().
then
((
data
:
notificationManager
.
DoNotDisturbDate
)
=>
{
console
.
info
(
"
getDoNotDisturbDate success, data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
getDoNotDisturbDate success, data:
"
+
JSON
.
stringify
(
data
));
});
});
```
```
...
@@ -2528,15 +2541,15 @@ getDoNotDisturbDate(userId: number, callback: AsyncCallback\<DoNotDisturbDate\>)
...
@@ -2528,15 +2541,15 @@ getDoNotDisturbDate(userId: number, callback: AsyncCallback\<DoNotDisturbDate\>)
**示例:**
**示例:**
```
ts
```
ts
function
getDoNotDisturbDateCallback
(
err
,
data
)
{
function
getDoNotDisturbDateCallback
(
err
:
Base
.
BusinessError
,
data
:
notificationManager
.
DoNotDisturbDate
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`getDoNotDisturbDate failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`getDoNotDisturbDate failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
console
.
info
(
"
getDoNotDisturbDate success
"
);
console
.
info
(
`getDoNotDisturbDate success, data is
${
JSON
.
stringify
(
data
)}
`
);
}
}
}
}
let
userId
=
1
;
let
userId
:
number
=
1
;
notificationManager
.
getDoNotDisturbDate
(
userId
,
getDoNotDisturbDateCallback
);
notificationManager
.
getDoNotDisturbDate
(
userId
,
getDoNotDisturbDateCallback
);
```
```
...
@@ -2580,9 +2593,9 @@ getDoNotDisturbDate(userId: number): Promise\<DoNotDisturbDate\>
...
@@ -2580,9 +2593,9 @@ getDoNotDisturbDate(userId: number): Promise\<DoNotDisturbDate\>
**示例:**
**示例:**
```
ts
```
ts
let
userId
=
1
;
let
userId
:
number
=
1
;
notificationManager
.
getDoNotDisturbDate
(
userId
).
then
((
data
)
=>
{
notificationManager
.
getDoNotDisturbDate
(
userId
).
then
((
data
:
notificationManager
.
DoNotDisturbDate
)
=>
{
console
.
info
(
"
getDoNotDisturbDate success, data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
getDoNotDisturbDate success, data:
"
+
JSON
.
stringify
(
data
));
});
});
```
```
...
@@ -2617,7 +2630,7 @@ notificationManager.getDoNotDisturbDate(userId).then((data) => {
...
@@ -2617,7 +2630,7 @@ notificationManager.getDoNotDisturbDate(userId).then((data) => {
**示例:**
**示例:**
```
ts
```
ts
function
isSupportDoNotDisturbModeCallback
(
err
,
data
)
{
function
isSupportDoNotDisturbModeCallback
(
err
:
Base
.
BusinessError
,
data
:
boolean
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`isSupportDoNotDisturbMode failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`isSupportDoNotDisturbMode failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -2659,7 +2672,7 @@ isSupportDoNotDisturbMode(): Promise\<boolean\>
...
@@ -2659,7 +2672,7 @@ isSupportDoNotDisturbMode(): Promise\<boolean\>
**示例:**
**示例:**
```
ts
```
ts
notificationManager
.
isSupportDoNotDisturbMode
().
then
((
data
)
=>
{
notificationManager
.
isSupportDoNotDisturbMode
().
then
((
data
:
boolean
)
=>
{
console
.
info
(
"
supportDoNotDisturbMode success, data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
supportDoNotDisturbMode success, data:
"
+
JSON
.
stringify
(
data
));
});
});
```
```
...
@@ -2692,8 +2705,8 @@ isSupportTemplate(templateName: string, callback: AsyncCallback\<boolean\>): voi
...
@@ -2692,8 +2705,8 @@ isSupportTemplate(templateName: string, callback: AsyncCallback\<boolean\>): voi
**示例:**
**示例:**
```
javascript
```
javascript
let
templateName
=
'
process
'
;
let
templateName
:
string
=
'
process
'
;
function
isSupportTemplateCallback
(
err
,
data
)
{
function
isSupportTemplateCallback
(
err
:
Base
.
BusinessError
,
data
:
boolean
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`isSupportTemplate failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`isSupportTemplate failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -2737,9 +2750,9 @@ isSupportTemplate(templateName: string): Promise\<boolean\>
...
@@ -2737,9 +2750,9 @@ isSupportTemplate(templateName: string): Promise\<boolean\>
**示例:**
**示例:**
```
javascript
```
javascript
let
templateName
=
'
process
'
;
let
templateName
:
string
=
'
process
'
;
notificationManager
.
isSupportTemplate
(
templateName
).
then
((
data
)
=>
{
notificationManager
.
isSupportTemplate
(
templateName
).
then
((
data
:
boolean
)
=>
{
console
.
info
(
"
isSupportTemplate success, data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
isSupportTemplate success, data:
"
+
JSON
.
stringify
(
data
));
});
});
```
```
...
@@ -2771,7 +2784,7 @@ requestEnableNotification(callback: AsyncCallback\<void\>): void
...
@@ -2771,7 +2784,7 @@ requestEnableNotification(callback: AsyncCallback\<void\>): void
**示例:**
**示例:**
```
javascript
```
javascript
function
requestEnableNotificationCallback
(
err
)
{
function
requestEnableNotificationCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`requestEnableNotification failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`requestEnableNotification failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -2808,7 +2821,76 @@ notificationManager.requestEnableNotification().then(() => {
...
@@ -2808,7 +2821,76 @@ notificationManager.requestEnableNotification().then(() => {
});
});
```
```
## notificationManager.requestEnableNotification<sup>10+<sup>
requestEnableNotification(context: UIAbilityContext, callback: AsyncCallback
\<
void
\>
): void
应用请求通知使能模态弹窗(Callback形式)。
**系统能力**
:SystemCapability.Notification.Notification
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------ | ---- |--------------------|
| context | UIAbilityContext | 是 | 通知弹窗绑定Ability的上下文。 |
| callback | AsyncCallback
\<
void
\>
| 是 | 应用请求通知使能的回调函数。 |
**错误码:**
错误码详细介绍请参考
[
errcode-notification
](
../errorcodes/errorcode-notification.md
)
。
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
**示例:**
```
javascript
function
requestEnableNotificationCallback
(
err
)
{
if
(
err
)
{
console
.
error
(
`requestEnableNotification failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
info
(
"
requestEnableNotification success
"
);
}
};
notificationManager
.
requestEnableNotification
(
globalThis
.
uicontext
,
requestEnableNotificationCallback
);
```
## notificationManager.requestEnableNotification<sup>10+<sup>
requestEnableNotification(context: UIAbilityContext): Promise
\<
void
\>
应用请求通知使能模态弹窗(Promise形式)。
**系统能力**
:SystemCapability.Notification.Notification
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------ | ---- |--------------------|
| context | UIAbilityContext | 是 | 通知弹窗绑定Ability的上下文。 |
**错误码:**
错误码详细介绍请参考
[
errcode-notification
](
../errorcodes/errorcode-notification.md
)
。
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
**示例:**
```
javascript
notificationManager
.
requestEnableNotification
(
globalThis
.
uicontext
).
then
(()
=>
{
console
.
info
(
"
requestEnableNotification success
"
);
});
```
## notificationManager.setDistributedEnable
## notificationManager.setDistributedEnable
...
@@ -2843,7 +2925,7 @@ setDistributedEnable(enable: boolean, callback: AsyncCallback\<void\>): void
...
@@ -2843,7 +2925,7 @@ setDistributedEnable(enable: boolean, callback: AsyncCallback\<void\>): void
**示例:**
**示例:**
```
javascript
```
javascript
function
setDistributedEnableCallback
(
err
)
{
function
setDistributedEnableCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`setDistributedEnable failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`setDistributedEnable failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -2851,7 +2933,7 @@ function setDistributedEnableCallback(err) {
...
@@ -2851,7 +2933,7 @@ function setDistributedEnableCallback(err) {
}
}
};
};
let
enable
=
true
;
let
enable
:
boolean
=
true
;
notificationManager
.
setDistributedEnable
(
enable
,
setDistributedEnableCallback
);
notificationManager
.
setDistributedEnable
(
enable
,
setDistributedEnableCallback
);
```
```
...
@@ -2888,11 +2970,11 @@ setDistributedEnable(enable: boolean): Promise\<void>
...
@@ -2888,11 +2970,11 @@ setDistributedEnable(enable: boolean): Promise\<void>
**示例:**
**示例:**
```
javascript
```
javascript
let
enable
=
true
;
let
enable
:
boolean
=
true
;
notificationManager
.
setDistributedEnable
(
enable
).
then
(()
=>
{
notificationManager
.
setDistributedEnable
(
enable
).
then
(()
=>
{
console
.
info
(
"
setDistributedEnable success
"
);
console
.
info
(
"
setDistributedEnable success
"
);
});
});
```
```
...
@@ -2924,7 +3006,7 @@ isDistributedEnabled(callback: AsyncCallback\<boolean>): void
...
@@ -2924,7 +3006,7 @@ isDistributedEnabled(callback: AsyncCallback\<boolean>): void
**示例:**
**示例:**
```
javascript
```
javascript
function
isDistributedEnabledCallback
(
err
,
data
)
{
function
isDistributedEnabledCallback
(
err
:
Base
.
BusinessError
,
data
:
boolean
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`isDistributedEnabled failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`isDistributedEnabled failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -2966,7 +3048,7 @@ isDistributedEnabled(): Promise\<boolean>
...
@@ -2966,7 +3048,7 @@ isDistributedEnabled(): Promise\<boolean>
```
javascript
```
javascript
notificationManager
.
isDistributedEnabled
()
notificationManager
.
isDistributedEnabled
()
.
then
((
data
)
=>
{
.
then
((
data
:
boolean
)
=>
{
console
.
info
(
"
isDistributedEnabled success, data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
isDistributedEnabled success, data:
"
+
JSON
.
stringify
(
data
));
});
});
```
```
...
@@ -3007,7 +3089,7 @@ setDistributedEnableByBundle(bundle: BundleOption, enable: boolean, callback: As
...
@@ -3007,7 +3089,7 @@ setDistributedEnableByBundle(bundle: BundleOption, enable: boolean, callback: As
**示例:**
**示例:**
```
javascript
```
javascript
function
setDistributedEnableByBundleCallback
(
err
)
{
function
setDistributedEnableByBundleCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`setDistributedEnableByBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`setDistributedEnableByBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -3015,11 +3097,11 @@ function setDistributedEnableByBundleCallback(err) {
...
@@ -3015,11 +3097,11 @@ function setDistributedEnableByBundleCallback(err) {
}
}
};
};
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
bundle
:
"
bundleName1
"
,
};
};
let
enable
=
true
let
enable
:
boolean
=
true
;
notificationManager
.
setDistributedEnableByBundle
(
bundle
,
enable
,
setDistributedEnableByBundleCallback
);
notificationManager
.
setDistributedEnableByBundle
(
bundle
,
enable
,
setDistributedEnableByBundleCallback
);
```
```
...
@@ -3060,11 +3142,11 @@ setDistributedEnableByBundle(bundle: BundleOption, enable: boolean): Promise\<vo
...
@@ -3060,11 +3142,11 @@ setDistributedEnableByBundle(bundle: BundleOption, enable: boolean): Promise\<vo
**示例:**
**示例:**
```
javascript
```
javascript
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
bundle
:
"
bundleName1
"
,
};
};
let
enable
=
true
let
enable
:
boolean
=
true
;
notificationManager
.
setDistributedEnableByBundle
(
bundle
,
enable
).
then
(()
=>
{
notificationManager
.
setDistributedEnableByBundle
(
bundle
,
enable
).
then
(()
=>
{
console
.
info
(
"
setDistributedEnableByBundle success
"
);
console
.
info
(
"
setDistributedEnableByBundle success
"
);
...
@@ -3105,7 +3187,7 @@ isDistributedEnabledByBundle(bundle: BundleOption, callback: AsyncCallback\<bool
...
@@ -3105,7 +3187,7 @@ isDistributedEnabledByBundle(bundle: BundleOption, callback: AsyncCallback\<bool
**示例:**
**示例:**
```
javascript
```
javascript
function
isDistributedEnabledByBundleCallback
(
err
,
data
)
{
function
isDistributedEnabledByBundleCallback
(
err
:
Base
.
BusinessError
,
data
:
boolean
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`isDistributedEnabledByBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`isDistributedEnabledByBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -3113,7 +3195,7 @@ function isDistributedEnabledByBundleCallback(err, data) {
...
@@ -3113,7 +3195,7 @@ function isDistributedEnabledByBundleCallback(err, data) {
}
}
};
};
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
bundle
:
"
bundleName1
"
,
};
};
...
@@ -3159,11 +3241,11 @@ isDistributedEnabledByBundle(bundle: BundleOption): Promise\<boolean>
...
@@ -3159,11 +3241,11 @@ isDistributedEnabledByBundle(bundle: BundleOption): Promise\<boolean>
**示例:**
**示例:**
```
javascript
```
javascript
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
bundle
:
"
bundleName1
"
,
};
};
notificationManager
.
isDistributedEnabledByBundle
(
bundle
).
then
((
data
)
=>
{
notificationManager
.
isDistributedEnabledByBundle
(
bundle
).
then
((
data
:
boolean
)
=>
{
console
.
info
(
"
isDistributedEnabledByBundle success, data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
isDistributedEnabledByBundle success, data:
"
+
JSON
.
stringify
(
data
));
});
});
```
```
...
@@ -3200,11 +3282,11 @@ getDeviceRemindType(callback: AsyncCallback\<DeviceRemindType\>): void
...
@@ -3200,11 +3282,11 @@ getDeviceRemindType(callback: AsyncCallback\<DeviceRemindType\>): void
**示例:**
**示例:**
```
javascript
```
javascript
function
getDeviceRemindTypeCallback
(
err
,
data
)
{
function
getDeviceRemindTypeCallback
(
err
:
Base
.
BusinessError
,
data
:
notificationManager
.
DeviceRemindType
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`getDeviceRemindType failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`getDeviceRemindType failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
console
.
info
(
"
getDeviceRemindType success
"
);
console
.
info
(
`getDeviceRemindType success, data is
${
JSON
.
stringify
(
data
)}
`
);
}
}
};
};
...
@@ -3242,7 +3324,7 @@ getDeviceRemindType(): Promise\<DeviceRemindType\>
...
@@ -3242,7 +3324,7 @@ getDeviceRemindType(): Promise\<DeviceRemindType\>
**示例:**
**示例:**
```
javascript
```
javascript
notificationManager
.
getDeviceRemindType
().
then
((
data
)
=>
{
notificationManager
.
getDeviceRemindType
().
then
((
data
:
notificationManager
.
DeviceRemindType
)
=>
{
console
.
info
(
"
getDeviceRemindType success, data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
getDeviceRemindType success, data:
"
+
JSON
.
stringify
(
data
));
});
});
```
```
...
@@ -3288,7 +3370,7 @@ publishAsBundle(request: NotificationRequest, representativeBundle: string, user
...
@@ -3288,7 +3370,7 @@ publishAsBundle(request: NotificationRequest, representativeBundle: string, user
```
ts
```
ts
//publishAsBundle回调
//publishAsBundle回调
function
callback
(
err
)
{
function
callback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`publishAsBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`publishAsBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -3296,11 +3378,11 @@ function callback(err) {
...
@@ -3296,11 +3378,11 @@ function callback(err) {
}
}
}
}
// 被代理应用的包名
// 被代理应用的包名
let
representativeBundle
=
"
com.example.demo
"
;
let
representativeBundle
:
string
=
"
com.example.demo
"
;
// 用户ID
// 用户ID
let
userId
=
100
;
let
userId
:
number
=
100
;
// NotificationRequest对象
// NotificationRequest对象
let
request
=
{
let
request
:
notificationManager
.
NotificationRequest
=
{
id
:
1
,
id
:
1
,
content
:
{
content
:
{
contentType
:
notificationManager
.
ContentType
.
NOTIFICATION_CONTENT_BASIC_TEXT
,
contentType
:
notificationManager
.
ContentType
.
NOTIFICATION_CONTENT_BASIC_TEXT
,
...
@@ -3355,11 +3437,11 @@ publishAsBundle(request: NotificationRequest, representativeBundle: string, user
...
@@ -3355,11 +3437,11 @@ publishAsBundle(request: NotificationRequest, representativeBundle: string, user
```
ts
```
ts
// 被代理应用的包名
// 被代理应用的包名
let
representativeBundle
=
"
com.example.demo
"
;
let
representativeBundle
:
string
=
"
com.example.demo
"
;
// 用户ID
// 用户ID
let
userId
=
100
;
let
userId
:
number
=
100
;
// NotificationRequest对象
// NotificationRequest对象
let
request
=
{
let
request
:
notificationManager
.
NotificationRequest
=
{
id
:
1
,
id
:
1
,
content
:
{
content
:
{
contentType
:
notificationManager
.
ContentType
.
NOTIFICATION_CONTENT_BASIC_TEXT
,
contentType
:
notificationManager
.
ContentType
.
NOTIFICATION_CONTENT_BASIC_TEXT
,
...
@@ -3415,7 +3497,7 @@ cancelAsBundle(id: number, representativeBundle: string, userId: number, callbac
...
@@ -3415,7 +3497,7 @@ cancelAsBundle(id: number, representativeBundle: string, userId: number, callbac
```
ts
```
ts
// cancelAsBundle
// cancelAsBundle
function
cancelAsBundleCallback
(
err
)
{
function
cancelAsBundleCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`cancelAsBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`cancelAsBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -3423,9 +3505,9 @@ function cancelAsBundleCallback(err) {
...
@@ -3423,9 +3505,9 @@ function cancelAsBundleCallback(err) {
}
}
}
}
// 被代理应用的包名
// 被代理应用的包名
let
representativeBundle
=
"
com.example.demo
"
;
let
representativeBundle
:
string
=
"
com.example.demo
"
;
// 用户ID
// 用户ID
let
userId
=
100
;
let
userId
:
number
=
100
;
notificationManager
.
cancelAsBundle
(
0
,
representativeBundle
,
userId
,
cancelAsBundleCallback
);
notificationManager
.
cancelAsBundle
(
0
,
representativeBundle
,
userId
,
cancelAsBundleCallback
);
```
```
...
@@ -3468,9 +3550,9 @@ cancelAsBundle(id: number, representativeBundle: string, userId: number): Promis
...
@@ -3468,9 +3550,9 @@ cancelAsBundle(id: number, representativeBundle: string, userId: number): Promis
```
ts
```
ts
// 被代理应用的包名
// 被代理应用的包名
let
representativeBundle
=
"
com.example.demo
"
;
let
representativeBundle
:
string
=
"
com.example.demo
"
;
// 用户ID
// 用户ID
let
userId
=
100
;
let
userId
:
number
=
100
;
notificationManager
.
cancelAsBundle
(
0
,
representativeBundle
,
userId
).
then
(()
=>
{
notificationManager
.
cancelAsBundle
(
0
,
representativeBundle
,
userId
).
then
(()
=>
{
console
.
info
(
"
cancelAsBundle success
"
);
console
.
info
(
"
cancelAsBundle success
"
);
...
@@ -3513,7 +3595,7 @@ setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean,
...
@@ -3513,7 +3595,7 @@ setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean,
```
ts
```
ts
// setNotificationEnableSlot
// setNotificationEnableSlot
function
setNotificationEnableSlotCallback
(
err
)
{
function
setNotificationEnableSlotCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`setNotificationEnableSlot failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`setNotificationEnableSlot failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -3606,11 +3688,11 @@ isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncC
...
@@ -3606,11 +3688,11 @@ isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncC
```
ts
```
ts
// isNotificationSlotEnabled
// isNotificationSlotEnabled
function
getEnableSlotCallback
(
err
,
data
)
{
function
getEnableSlotCallback
(
err
:
Base
.
BusinessError
,
data
:
boolean
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`isNotificationSlotEnabled failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`isNotificationSlotEnabled failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
console
.
info
(
"
isNotificationSlotEnabled success
"
);
console
.
info
(
`isNotificationSlotEnabled success, data is
${
JSON
.
stringify
(
data
)}
`
);
}
}
};
};
...
@@ -3661,7 +3743,7 @@ isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise\<boolea
...
@@ -3661,7 +3743,7 @@ isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise\<boolea
```
ts
```
ts
// isNotificationSlotEnabled
// isNotificationSlotEnabled
notificationManager
.
isNotificationSlotEnabled
({
bundle
:
"
ohos.samples.notification
"
,
},
notificationManager
.
isNotificationSlotEnabled
({
bundle
:
"
ohos.samples.notification
"
,
},
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
).
then
((
data
)
=>
{
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
).
then
((
data
:
boolean
)
=>
{
console
.
info
(
"
isNotificationSlotEnabled success, data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
isNotificationSlotEnabled success, data:
"
+
JSON
.
stringify
(
data
));
});
});
```
```
...
@@ -3701,10 +3783,10 @@ setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean, callback:
...
@@ -3701,10 +3783,10 @@ setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean, callback:
**示例:**
**示例:**
```
ts
```
ts
let
userId
=
100
;
let
userId
:
number
=
100
;
let
enable
=
true
;
let
enable
:
boolean
=
true
;
function
callback
(
err
)
{
function
callback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`setSyncNotificationEnabledWithoutApp failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`setSyncNotificationEnabledWithoutApp failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -3755,13 +3837,11 @@ setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean): Promise\<
...
@@ -3755,13 +3837,11 @@ setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean): Promise\<
**示例:**
**示例:**
```
ts
```
ts
let
userId
=
100
;
let
userId
:
number
=
100
;
let
enable
=
true
;
let
enable
:
boolean
=
true
;
notificationManager
.
setSyncNotificationEnabledWithoutApp
(
userId
,
enable
).
then
(()
=>
{
notificationManager
.
setSyncNotificationEnabledWithoutApp
(
userId
,
enable
).
then
(()
=>
{
console
.
info
(
'
setSyncNotificationEnabledWithoutApp success
'
);
console
.
info
(
'
setSyncNotificationEnabledWithoutApp success
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
`setSyncNotificationEnabledWithoutApp failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
});
});
```
```
...
@@ -3799,9 +3879,9 @@ getSyncNotificationEnabledWithoutApp(userId: number, callback: AsyncCallback\<bo
...
@@ -3799,9 +3879,9 @@ getSyncNotificationEnabledWithoutApp(userId: number, callback: AsyncCallback\<bo
**示例:**
**示例:**
```
ts
```
ts
let
userId
=
100
;
let
userId
:
number
=
100
;
function
getSyncNotificationEnabledWithoutAppCallback
(
err
,
data
)
{
function
getSyncNotificationEnabledWithoutAppCallback
(
err
:
Base
.
BusinessError
,
data
:
boolean
)
{
if
(
err
)
{
if
(
err
)
{
console
.
info
(
'
getSyncNotificationEnabledWithoutAppCallback, err:
'
+
err
);
console
.
info
(
'
getSyncNotificationEnabledWithoutAppCallback, err:
'
+
err
);
}
else
{
}
else
{
...
@@ -3851,11 +3931,10 @@ getSyncNotificationEnabledWithoutApp(userId: number): Promise\<boolean>
...
@@ -3851,11 +3931,10 @@ getSyncNotificationEnabledWithoutApp(userId: number): Promise\<boolean>
**示例:**
**示例:**
```
ts
```
ts
let
userId
=
100
;
let
userId
:
number
=
100
;
notificationManager
.
getSyncNotificationEnabledWithoutApp
(
userId
).
then
((
data
)
=>
{
notificationManager
.
getSyncNotificationEnabledWithoutApp
(
userId
).
then
((
data
:
boolean
)
=>
{
console
.
info
(
'
getSyncNotificationEnabledWithoutApp, data:
'
+
data
);
console
.
info
(
'
getSyncNotificationEnabledWithoutApp, data:
'
+
data
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
getSyncNotificationEnabledWithoutApp, err:
'
+
err
);
});
});
```
```
...
@@ -3897,9 +3976,11 @@ try{
...
@@ -3897,9 +3976,11 @@ try{
function
OnCheckNotification
(
info
:
notificationManager
.
NotificationCheckInfo
)
{
function
OnCheckNotification
(
info
:
notificationManager
.
NotificationCheckInfo
)
{
console
.
info
(
`====>OnCheckNotification info:
${
JSON
.
stringify
(
info
)}
`
);
console
.
info
(
`====>OnCheckNotification info:
${
JSON
.
stringify
(
info
)}
`
);
if
(
info
.
notificationId
==
1
){
if
(
info
.
notificationId
==
1
){
return
{
code
:
1
,
message
:
"
testMsg1
"
}
let
result
:
notificationManager
.
NotificationCheckResult
=
{
code
:
1
,
message
:
"
testMsg1
"
};
return
result
;
}
else
{
}
else
{
return
{
code
:
0
,
message
:
"
testMsg0
"
}
let
result
:
notificationManager
.
NotificationCheckResult
=
{
code
:
0
,
message
:
"
testMsg0
"
};
return
result
;
}
}
}
}
```
```
...
...
zh-cn/application-dev/reference/apis/js-apis-system-notification.md
浏览文件 @
1743c481
...
@@ -50,8 +50,12 @@ show(options?: ShowNotificationOptions): void
...
@@ -50,8 +50,12 @@ show(options?: ShowNotificationOptions): void
| options | ShowNotificationOptions | 否 | 通知标题。 |
| options | ShowNotificationOptions | 否 | 通知标题。 |
**示例:**
**示例:**
```
javascript
```
ts
export
default
{
class
NotificationClass
{
show
:
Function
}
let
notificationObj
:
NotificationClass
=
{
show
()
{
show
()
{
notification
.
show
({
notification
.
show
({
contentTitle
:
'
title info
'
,
contentTitle
:
'
title info
'
,
...
@@ -64,4 +68,6 @@ export default {
...
@@ -64,4 +68,6 @@ export default {
});
});
}
}
}
}
export
default
notificationObj
```
```
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录