Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
87e56a43
D
Docs
项目概览
OpenHarmony
/
Docs
接近 2 年 前同步成功
通知
159
Star
292
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看板
未验证
提交
87e56a43
编写于
8月 25, 2023
作者:
O
openharmony_ci
提交者:
Gitee
8月 25, 2023
浏览文件
操作
浏览文件
下载
差异文件
!22966 示例代码ArkTS整改
Merge pull request !22966 from xuzhihao/master
上级
96f2e2bf
5c46bbab
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
365 addition
and
341 deletion
+365
-341
en/application-dev/reference/apis/js-apis-notificationManager.md
...ication-dev/reference/apis/js-apis-notificationManager.md
+175
-163
zh-cn/application-dev/reference/apis/js-apis-notificationManager.md
...ication-dev/reference/apis/js-apis-notificationManager.md
+190
-178
未找到文件。
en/application-dev/reference/apis/js-apis-notificationManager.md
浏览文件 @
87e56a43
...
...
@@ -10,6 +10,7 @@ The **notificationManager** module provides notification management capabilities
```
ts
import
notificationManager
from
'
@ohos.notificationManager
'
;
import
Base
from
'
@ohos.base
'
;
```
## notificationManager.publish
...
...
@@ -45,7 +46,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```
ts
// publish callback
function
publishCallback
(
err
)
{
function
publishCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`publish failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -155,7 +156,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```
ts
// publish callback
function
publishCallback
(
err
)
{
function
publishCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`publish failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -163,7 +164,7 @@ function publishCallback(err) {
}
}
// User ID
let
userId
=
1
;
let
userId
:
number
=
1
;
// NotificationRequest object
let
notificationRequest
:
notificationManager
.
NotificationRequest
=
{
id
:
1
,
...
...
@@ -228,7 +229,7 @@ let notificationRequest: notificationManager.NotificationRequest = {
}
};
let
userId
=
1
;
let
userId
:
number
=
1
;
notificationManager
.
publish
(
notificationRequest
,
userId
).
then
(()
=>
{
console
.
info
(
"
publish success
"
);
...
...
@@ -267,7 +268,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```
ts
// cancel callback
function
cancelCallback
(
err
)
{
function
cancelCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`cancel failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -341,7 +342,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```
ts
// cancel callback
function
cancelCallback
(
err
)
{
function
cancelCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`cancel failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -379,7 +380,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```
ts
// cancel callback
function
cancelAllCallback
(
err
)
{
function
cancelAllCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`cancelAll failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -449,7 +450,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```
ts
// addSlot callback
function
addSlotCallBack
(
err
)
{
function
addSlotCallBack
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`addSlot failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -457,7 +458,7 @@ function addSlotCallBack(err) {
}
}
// NotificationSlot object
let
notificationSlot
=
{
let
notificationSlot
:
notificationManager
.
NotificationSlot
=
{
type
:
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
};
notificationManager
.
addSlot
(
notificationSlot
,
addSlotCallBack
);
...
...
@@ -496,7 +497,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```
ts
// NotificationSlot object
let
notificationSlot
=
{
let
notificationSlot
:
notificationManager
.
NotificationSlot
=
{
type
:
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
};
notificationManager
.
addSlot
(
notificationSlot
).
then
(()
=>
{
...
...
@@ -534,7 +535,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```
ts
// addSlot callback
function
addSlotCallBack
(
err
)
{
function
addSlotCallBack
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`addSlot failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -611,7 +612,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```
ts
// addSlots callback
function
addSlotsCallBack
(
err
)
{
function
addSlotsCallBack
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`addSlots failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -619,11 +620,11 @@ function addSlotsCallBack(err) {
}
}
// NotificationSlot object
let
notificationSlot
=
{
let
notificationSlot
:
notificationManager
.
NotificationSlot
=
{
type
:
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
};
// NotificationSlotArray object
let
notificationSlotArray
=
new
Array
();
let
notificationSlotArray
:
notificationManager
.
NotificationSlot
[]
=
new
Array
();
notificationSlotArray
[
0
]
=
notificationSlot
;
notificationManager
.
addSlots
(
notificationSlotArray
,
addSlotsCallBack
);
...
...
@@ -662,11 +663,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```
ts
// NotificationSlot object
let
notificationSlot
=
{
let
notificationSlot
:
notificationManager
.
NotificationSlot
=
{
type
:
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
};
// NotificationSlotArray object
let
notificationSlotArray
=
new
Array
();
let
notificationSlotArray
:
notificationManager
.
NotificationSlot
[]
=
new
Array
();
notificationSlotArray
[
0
]
=
notificationSlot
;
notificationManager
.
addSlots
(
notificationSlotArray
).
then
(()
=>
{
...
...
@@ -703,14 +704,14 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```
ts
// getSlot callback
function
getSlotCallback
(
err
,
data
)
{
function
getSlotCallback
(
err
:
Base
.
BusinessError
,
data
:
notificationManager
.
NotificationSlot
)
{
if
(
err
)
{
console
.
error
(
`getSlot failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
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
);
```
...
...
@@ -747,8 +748,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
ts
let
slotType
=
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
;
notificationManager
.
getSlot
(
slotType
).
then
((
data
)
=>
{
let
slotType
:
notificationManager
.
SlotType
=
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
;
notificationManager
.
getSlot
(
slotType
).
then
((
data
:
notificationManager
.
NotificationSlot
)
=>
{
console
.
info
(
"
getSlot success, data:
"
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -781,11 +783,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```
ts
// getSlots callback
function
getSlotsCallback
(
err
,
data
)
{
function
getSlotsCallback
(
err
:
Base
.
BusinessError
,
data
:
Array
<
notificationManager
.
NotificationSlot
>
)
{
if
(
err
)
{
console
.
error
(
`getSlots failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
info
(
"
getSlots success
"
);
console
.
info
(
`getSlots success, data is
${
JSON
.
stringify
(
data
)}
`
);
}
}
notificationManager
.
getSlots
(
getSlotsCallback
);
...
...
@@ -818,7 +820,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
ts
notificationManager
.
getSlots
().
then
((
data
)
=>
{
notificationManager
.
getSlots
().
then
((
data
:
Array
<
notificationManager
.
NotificationSlot
>
)
=>
{
console
.
info
(
"
getSlots success, data:
"
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -852,7 +854,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```
ts
// removeSlot callback
function
removeSlotCallback
(
err
)
{
function
removeSlotCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`removeSlot failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -860,7 +862,7 @@ function removeSlotCallback(err) {
}
}
let
slotType
=
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
;
notificationManager
.
removeSlot
(
slotType
,
removeSlotCallback
);
notificationManager
.
removeSlot
(
slotType
,
removeSlotCallback
);
```
## notificationManager.removeSlot
...
...
@@ -890,7 +892,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
ts
let
slotType
=
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
;
let
slotType
:
notificationManager
.
SlotType
=
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
;
notificationManager
.
removeSlot
(
slotType
).
then
(()
=>
{
console
.
info
(
"
removeSlot success
"
);
});
...
...
@@ -923,7 +925,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
ts
function
removeAllCallBack
(
err
)
{
function
removeAllCallBack
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`removeAllSlots failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -993,17 +995,17 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
ts
function
setNotificationEnable
nCallback
(
er
r
)
{
function
setNotificationEnable
Callback
(
err
:
Base
.
BusinessErro
r
)
{
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
{
console
.
info
(
"
setNotificationEnable
n
Callback success
"
);
console
.
info
(
"
setNotificationEnableCallback success
"
);
}
}
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
};
notificationManager
.
setNotificationEnable
(
bundle
,
false
,
setNotificationEnable
n
Callback
);
notificationManager
.
setNotificationEnable
(
bundle
,
false
,
setNotificationEnableCallback
);
```
## notificationManager.setNotificationEnable
...
...
@@ -1039,7 +1041,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
ts
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
};
notificationManager
.
setNotificationEnable
(
bundle
,
false
).
then
(()
=>
{
...
...
@@ -1080,16 +1082,18 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
ts
function
isNotificationEnabledCallback
(
err
,
data
)
{
function
isNotificationEnabledCallback
(
err
:
Base
.
BusinessError
,
data
:
boolean
)
{
if
(
err
)
{
console
.
error
(
`isNotificationEnabled failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
info
(
"
isNotificationEnabled success
"
);
console
.
info
(
`isNotificationEnabled success, data is
${
JSON
.
stringify
(
data
)}
`
);
}
}
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
};
notificationManager
.
isNotificationEnabled
(
bundle
,
isNotificationEnabledCallback
);
```
...
...
@@ -1131,10 +1135,10 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
ts
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
};
notificationManager
.
isNotificationEnabled
(
bundle
).
then
((
data
)
=>
{
notificationManager
.
isNotificationEnabled
(
bundle
).
then
((
data
:
boolean
)
=>
{
console
.
info
(
"
isNotificationEnabled success, data:
"
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -1170,11 +1174,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
ts
function
isNotificationEnabledCallback
(
err
,
data
)
{
function
isNotificationEnabledCallback
(
err
:
Base
.
BusinessError
,
data
:
boolean
)
{
if
(
err
)
{
console
.
error
(
`isNotificationEnabled failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
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/
**Example**
```
ts
notificationManager
.
isNotificationEnabled
().
then
((
data
)
=>
{
notificationManager
.
isNotificationEnabled
().
then
((
data
:
boolean
)
=>
{
console
.
info
(
"
isNotificationEnabled success, data:
"
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -1250,15 +1254,15 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
ts
function
isNotificationEnabledCallback
(
err
,
data
)
{
function
isNotificationEnabledCallback
(
err
:
Base
.
BusinessError
,
data
:
boolean
)
{
if
(
err
)
{
console
.
error
(
`isNotificationEnabled failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
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
);
```
...
...
@@ -1301,9 +1305,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
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
));
});
```
...
...
@@ -1342,14 +1346,14 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
ts
function
displayBadgeCallback
(
err
)
{
function
displayBadgeCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`displayBadge failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
info
(
"
displayBadge success
"
);
}
}
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
};
notificationManager
.
displayBadge
(
bundle
,
false
,
displayBadgeCallback
);
...
...
@@ -1388,7 +1392,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
ts
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
};
notificationManager
.
displayBadge
(
bundle
,
false
).
then
(()
=>
{
...
...
@@ -1413,7 +1417,7 @@ Checks whether the notification badge is enabled for a specified application. Th
| Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | ------------------------ |
| 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**
...
...
@@ -1429,14 +1433,14 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
ts
function
isBadgeDisplayedCallback
(
err
,
data
)
{
function
isBadgeDisplayedCallback
(
err
:
Base
.
BusinessError
,
data
:
boolean
)
{
if
(
err
)
{
console
.
error
(
`isBadgeDisplayed failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
info
(
"
isBadgeDisplayed success
"
);
console
.
info
(
`isBadgeDisplayed success, data is
${
JSON
.
stringify
(
data
)}
`
);
}
}
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
};
notificationManager
.
isBadgeDisplayed
(
bundle
,
isBadgeDisplayedCallback
);
...
...
@@ -1480,10 +1484,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
ts
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
};
notificationManager
.
isBadgeDisplayed
(
bundle
).
then
((
data
)
=>
{
notificationManager
.
isBadgeDisplayed
(
bundle
).
then
((
data
:
boolean
)
=>
{
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
**Example**
```
ts
let
badgeNumber
=
10
let
badgeNumber
:
number
=
10
notificationManager
.
setBadgeNumber
(
badgeNumber
).
then
(()
=>
{
console
.
info
(
"
displayBadge success
"
);
});
...
...
@@ -1549,7 +1555,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
ts
function
setBadgeNumberCallback
(
err
)
{
function
setBadgeNumberCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
info
(
`displayBadge failed code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -1557,7 +1563,7 @@ function setBadgeNumberCallback(err) {
}
}
let
badgeNumber
=
10
let
badgeNumber
:
number
=
10
notificationManager
.
setBadgeNumber
(
badgeNumber
,
setBadgeNumberCallback
);
```
...
...
@@ -1595,17 +1601,17 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
ts
function
setSlotByBundleCallback
(
err
)
{
function
setSlotByBundleCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`setSlotByBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
info
(
"
setSlotByBundle success
"
);
}
}
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
};
let
notificationSlot
=
{
let
notificationSlot
:
notificationManager
.
NotificationSlots
=
{
type
:
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
};
notificationManager
.
setSlotByBundle
(
bundle
,
notificationSlot
,
setSlotByBundleCallback
);
...
...
@@ -1644,12 +1650,14 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
ts
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
};
let
notificationSlot
=
{
let
notificationSlot
:
notificationManager
.
NotificationSlot
=
{
type
:
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
};
notificationManager
.
setSlotByBundle
(
bundle
,
notificationSlot
).
then
(()
=>
{
console
.
info
(
"
setSlotByBundle success
"
);
});
...
...
@@ -1688,14 +1696,14 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
ts
function
getSlotsByBundleCallback
(
err
,
data
)
{
function
getSlotsByBundleCallback
(
err
:
Base
.
BusinessError
,
data
:
Array
<
notificationManager
.
NotificationSlot
>
)
{
if
(
err
)
{
console
.
error
(
`getSlotByBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
info
(
"
getSlotsByBundle success
"
);
console
.
info
(
`getSlotsByBundle success, data is
${
JSON
.
stringify
(
data
)}
`
);
}
}
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
};
notificationManager
.
getSlotsByBundle
(
bundle
,
getSlotsByBundleCallback
);
...
...
@@ -1739,10 +1747,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
ts
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
};
notificationManager
.
getSlotsByBundle
(
bundle
).
then
((
data
)
=>
{
notificationManager
.
getSlotsByBundle
(
bundle
).
then
((
data
:
Array
<
notificationManager
.
NotificationSlot
>
)
=>
{
console
.
info
(
"
getSlotsByBundle success, data:
"
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -1780,16 +1789,18 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
ts
function
getSlotNumByBundleCallback
(
err
,
data
)
{
function
getSlotNumByBundleCallback
(
err
:
Base
.
BusinessError
,
data
:
number
)
{
if
(
err
)
{
console
.
error
(
`getSlotByBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
info
(
"
getSlotNumByBundle success
"
);
console
.
info
(
`getSlotNumByBundle success data is
${
JSON
.
stringify
(
data
)}
`
);
}
}
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
};
notificationManager
.
getSlotNumByBundle
(
bundle
,
getSlotNumByBundleCallback
);
```
...
...
@@ -1831,10 +1842,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
ts
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
};
notificationManager
.
getSlotNumByBundle
(
bundle
).
then
((
data
)
=>
{
notificationManager
.
getSlotNumByBundle
(
bundle
).
then
((
data
:
number
)
=>
{
console
.
info
(
"
getSlotNumByBundle success, data:
"
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -1869,11 +1881,11 @@ Obtains all active notifications. This API uses an asynchronous callback to retu
**Example**
```
ts
function
getAllActiveNotificationsCallback
(
err
,
data
)
{
function
getAllActiveNotificationsCallback
(
err
:
Base
.
BusinessError
,
data
:
Array
<
notificationManager
.
NotificationRequest
>
)
{
if
(
err
)
{
console
.
error
(
`getAllActiveNotifications failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
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/
**Example**
```
ts
notificationManager
.
getAllActiveNotifications
().
then
((
data
)
=>
{
notificationManager
.
getAllActiveNotifications
().
then
((
data
:
Array
<
notificationManager
.
NotificationRequest
>
)
=>
{
console
.
info
(
"
getAllActiveNotifications success, data:
"
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -1943,11 +1955,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
ts
function
getActiveNotificationCountCallback
(
err
,
data
)
{
function
getActiveNotificationCountCallback
(
err
:
Base
.
BusinessError
,
data
:
number
)
{
if
(
err
)
{
console
.
error
(
`getActiveNotificationCount failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
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/
**Example**
```
ts
notificationManager
.
getActiveNotificationCount
().
then
((
data
)
=>
{
notificationManager
.
getActiveNotificationCount
().
then
((
data
:
number
)
=>
{
console
.
info
(
"
getActiveNotificationCount success, data:
"
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -2013,7 +2025,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
ts
function
getActiveNotificationsCallback
(
err
,
data
)
{
function
getActiveNotificationsCallback
(
err
:
Base
.
BusinessError
,
data
:
Array
<
notificationManager
.
NotificationRequest
>
)
{
if
(
err
)
{
console
.
error
(
`getActiveNotifications failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -2051,7 +2063,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
ts
notificationManager
.
getActiveNotifications
().
then
((
data
)
=>
{
notificationManager
.
getActiveNotifications
().
then
((
data
:
Array
<
notificationManager
.
NotificationRequest
>
)
=>
{
console
.
info
(
"
removeGroupByBundle success, data:
"
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -2084,7 +2096,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
ts
function
cancelGroupCallback
(
err
)
{
function
cancelGroupCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`cancelGroup failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -2092,7 +2104,7 @@ function cancelGroupCallback(err) {
}
}
let
groupName
=
"
GroupName
"
;
let
groupName
:
string
=
"
GroupName
"
;
notificationManager
.
cancelGroup
(
groupName
,
cancelGroupCallback
);
```
...
...
@@ -2124,7 +2136,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
ts
let
groupName
=
"
GroupName
"
;
let
groupName
:
string
=
"
GroupName
"
;
notificationManager
.
cancelGroup
(
groupName
).
then
(()
=>
{
console
.
info
(
"
cancelGroup success
"
);
});
...
...
@@ -2164,7 +2176,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
ts
function
removeGroupByBundleCallback
(
err
)
{
function
removeGroupByBundleCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`removeGroupByBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -2172,8 +2184,8 @@ function removeGroupByBundleCallback(err) {
}
}
let
bundleOption
=
{
bundle
:
"
Bundle
"
};
let
groupName
=
"
GroupName
"
;
let
bundleOption
:
notificationManager
.
BundleOption
=
{
bundle
:
"
Bundle
"
};
let
groupName
:
string
=
"
GroupName
"
;
notificationManager
.
removeGroupByBundle
(
bundleOption
,
groupName
,
removeGroupByBundleCallback
);
```
...
...
@@ -2211,8 +2223,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
ts
let
bundleOption
=
{
bundle
:
"
Bundle
"
};
let
groupName
=
"
GroupName
"
;
let
bundleOption
:
notificationManager
.
BundleOption
=
{
bundle
:
"
Bundle
"
};
let
groupName
:
string
=
"
GroupName
"
;
notificationManager
.
removeGroupByBundle
(
bundleOption
,
groupName
).
then
(()
=>
{
console
.
info
(
"
removeGroupByBundle success
"
);
});
...
...
@@ -2251,7 +2264,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
ts
function
setDoNotDisturbDateCallback
(
err
)
{
function
setDoNotDisturbDateCallback
(
err
:
notificationManager
.
BundleOption
)
{
if
(
err
)
{
console
.
error
(
`setDoNotDisturbDate failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -2259,7 +2272,7 @@ function setDoNotDisturbDateCallback(err) {
}
}
let
doNotDisturbDate
=
{
let
doNotDisturbDate
:
notificationManager
.
DoNotDisturbDate
=
{
type
:
notificationManager
.
DoNotDisturbType
.
TYPE_ONCE
,
begin
:
new
Date
(),
end
:
new
Date
(
2021
,
11
,
15
,
18
,
0
)
...
...
@@ -2300,7 +2313,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
ts
let
doNotDisturbDate
=
{
let
doNotDisturbDate
:
notificationManager
.
DoNotDisturbDate
=
{
type
:
notificationManager
.
DoNotDisturbType
.
TYPE_ONCE
,
begin
:
new
Date
(),
end
:
new
Date
(
2021
,
11
,
15
,
18
,
0
)
...
...
@@ -2346,7 +2359,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
ts
function
setDoNotDisturbDateCallback
(
err
)
{
function
setDoNotDisturbDateCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`setDoNotDisturbDate failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -2354,13 +2367,13 @@ function setDoNotDisturbDateCallback(err) {
}
}
let
doNotDisturbDate
=
{
let
doNotDisturbDate
:
notificationManager
.
DoNotDisturbDate
=
{
type
:
notificationManager
.
DoNotDisturbType
.
TYPE_ONCE
,
begin
:
new
Date
(),
end
:
new
Date
(
2021
,
11
,
15
,
18
,
0
)
};
let
userId
=
1
;
let
userId
:
number
=
1
;
notificationManager
.
setDoNotDisturbDate
(
doNotDisturbDate
,
userId
,
setDoNotDisturbDateCallback
);
```
...
...
@@ -2399,13 +2412,13 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
ts
let
doNotDisturbDate
=
{
let
doNotDisturbDate
:
notificationManager
.
DoNotDisturbDate
=
{
type
:
notificationManager
.
DoNotDisturbType
.
TYPE_ONCE
,
begin
:
new
Date
(),
end
:
new
Date
(
2021
,
11
,
15
,
18
,
0
)
};
let
userId
=
1
;
let
userId
:
number
=
1
;
notificationManager
.
setDoNotDisturbDate
(
doNotDisturbDate
,
userId
).
then
(()
=>
{
console
.
info
(
"
setDoNotDisturbDate success
"
);
...
...
@@ -2445,11 +2458,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
ts
function
getDoNotDisturbDateCallback
(
err
,
data
)
{
function
getDoNotDisturbDateCallback
(
err
:
Base
.
BusinessError
,
data
:
notificationManager
.
DoNotDisturbDate
)
{
if
(
err
)
{
console
.
error
(
`getDoNotDisturbDate failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
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/
**Example**
```
ts
notificationManager
.
getDoNotDisturbDate
().
then
((
data
)
=>
{
notificationManager
.
getDoNotDisturbDate
().
then
((
data
:
notificationManager
.
DoNotDisturbDate
)
=>
{
console
.
info
(
"
getDoNotDisturbDate success, data:
"
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -2528,15 +2541,15 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
ts
function
getDoNotDisturbDateCallback
(
err
,
data
)
{
function
getDoNotDisturbDateCallback
(
err
:
Base
.
BusinessError
,
data
:
notificationManager
.
DoNotDisturbDate
)
{
if
(
err
)
{
console
.
error
(
`getDoNotDisturbDate failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
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
);
```
...
...
@@ -2580,9 +2593,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
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
));
});
```
...
...
@@ -2617,7 +2630,7 @@ Checks whether DND mode is supported. This API uses an asynchronous callback to
**Example**
```
ts
function
isSupportDoNotDisturbModeCallback
(
err
,
data
)
{
function
isSupportDoNotDisturbModeCallback
(
err
:
Base
.
BusinessError
,
data
:
boolean
)
{
if
(
err
)
{
console
.
error
(
`isSupportDoNotDisturbMode failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -2659,7 +2672,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
ts
notificationManager
.
isSupportDoNotDisturbMode
().
then
((
data
)
=>
{
notificationManager
.
isSupportDoNotDisturbMode
().
then
((
data
:
data
)
=>
{
console
.
info
(
"
supportDoNotDisturbMode success, data:
"
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -2692,8 +2705,8 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
javascript
let
templateName
=
'
process
'
;
function
isSupportTemplateCallback
(
err
,
data
)
{
let
templateName
:
string
=
'
process
'
;
function
isSupportTemplateCallback
(
err
:
Base
.
BusinessError
,
data
:
boolean
)
{
if
(
err
)
{
console
.
error
(
`isSupportTemplate failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -2737,9 +2750,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
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
));
});
```
...
...
@@ -2771,7 +2784,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
javascript
function
requestEnableNotificationCallback
(
err
)
{
function
requestEnableNotificationCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`requestEnableNotification failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -2843,7 +2856,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
javascript
function
setDistributedEnableCallback
(
err
)
{
function
setDistributedEnableCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`setDistributedEnable failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -2851,7 +2864,7 @@ function setDistributedEnableCallback(err) {
}
};
let
enable
=
true
;
let
enable
:
boolean
=
true
;
notificationManager
.
setDistributedEnable
(
enable
,
setDistributedEnableCallback
);
```
...
...
@@ -2888,11 +2901,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
javascript
let
enable
=
true
;
let
enable
:
boolean
=
true
;
notificationManager
.
setDistributedEnable
(
enable
).
then
(()
=>
{
console
.
info
(
"
setDistributedEnable success
"
);
});
});
```
...
...
@@ -2924,7 +2937,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
javascript
function
isDistributedEnabledCallback
(
err
,
data
)
{
function
isDistributedEnabledCallback
(
err
:
Base
.
BusinessError
,
data
:
boolean
)
{
if
(
err
)
{
console
.
error
(
`isDistributedEnabled failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -2966,7 +2979,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```
javascript
notificationManager
.
isDistributedEnabled
()
.
then
((
data
)
=>
{
.
then
((
data
:
boolean
)
=>
{
console
.
info
(
"
isDistributedEnabled success, data:
"
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -3007,7 +3020,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
javascript
function
setDistributedEnableByBundleCallback
(
err
)
{
function
setDistributedEnableByBundleCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`setDistributedEnableByBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -3015,11 +3028,11 @@ function setDistributedEnableByBundleCallback(err) {
}
};
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
};
let
enable
=
true
let
enable
:
boolean
=
true
notificationManager
.
setDistributedEnableByBundle
(
bundle
,
enable
,
setDistributedEnableByBundleCallback
);
```
...
...
@@ -3060,11 +3073,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
javascript
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
};
let
enable
=
true
let
enable
:
boolean
=
true
notificationManager
.
setDistributedEnableByBundle
(
bundle
,
enable
).
then
(()
=>
{
console
.
info
(
"
setDistributedEnableByBundle success
"
);
...
...
@@ -3105,7 +3118,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
javascript
function
isDistributedEnabledByBundleCallback
(
err
,
data
)
{
function
isDistributedEnabledByBundleCallback
(
err
:
Base
.
BusinessError
,
data
:
boolean
)
{
if
(
err
)
{
console
.
error
(
`isDistributedEnabledByBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -3113,7 +3126,7 @@ function isDistributedEnabledByBundleCallback(err, data) {
}
};
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
};
...
...
@@ -3159,11 +3172,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
javascript
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
};
notificationManager
.
isDistributedEnabledByBundle
(
bundle
).
then
((
data
)
=>
{
notificationManager
.
isDistributedEnabledByBundle
(
bundle
).
then
((
data
:
boolean
)
=>
{
console
.
info
(
"
isDistributedEnabledByBundle success, data:
"
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -3200,11 +3213,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
javascript
function
getDeviceRemindTypeCallback
(
err
,
data
)
{
function
getDeviceRemindTypeCallback
(
err
:
Base
.
BusinessError
,
data
:
notificationManager
.
DeviceRemindType
)
{
if
(
err
)
{
console
.
error
(
`getDeviceRemindType failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
info
(
"
getDeviceRemindType success
"
);
console
.
info
(
`getDeviceRemindType success, data is
${
JSON
.
stringify
(
data
)}
`
);
}
};
...
...
@@ -3242,7 +3255,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
javascript
notificationManager
.
getDeviceRemindType
().
then
((
data
)
=>
{
notificationManager
.
getDeviceRemindType
().
then
((
data
:
notificationManager
.
DeviceRemindType
)
=>
{
console
.
info
(
"
getDeviceRemindType success, data:
"
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -3288,7 +3301,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```
ts
// publishAsBundle callback
function
callback
(
err
)
{
function
callback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`publishAsBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -3296,11 +3309,11 @@ function callback(err) {
}
}
// 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
let
userId
=
100
;
let
userId
:
number
=
100
;
// NotificationRequest object
let
request
=
{
let
request
:
notificationManager
.
NotificationRequest
=
{
id
:
1
,
content
:
{
contentType
:
notificationManager
.
ContentType
.
NOTIFICATION_CONTENT_BASIC_TEXT
,
...
...
@@ -3355,11 +3368,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```
ts
// 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
let
userId
=
100
;
let
userId
:
number
=
100
;
// NotificationRequest object
let
request
=
{
let
request
:
notificationManager
.
NotificationRequest
=
{
id
:
1
,
content
:
{
contentType
:
notificationManager
.
ContentType
.
NOTIFICATION_CONTENT_BASIC_TEXT
,
...
...
@@ -3415,7 +3428,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```
ts
// cancelAsBundle
function
cancelAsBundleCallback
(
err
)
{
function
cancelAsBundleCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`cancelAsBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -3423,9 +3436,9 @@ function cancelAsBundleCallback(err) {
}
}
// 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
let
userId
=
100
;
let
userId
:
number
=
100
;
notificationManager
.
cancelAsBundle
(
0
,
representativeBundle
,
userId
,
cancelAsBundleCallback
);
```
...
...
@@ -3468,9 +3481,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```
ts
// 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
let
userId
=
100
;
let
userId
:
number
=
100
;
notificationManager
.
cancelAsBundle
(
0
,
representativeBundle
,
userId
).
then
(()
=>
{
console
.
info
(
"
cancelAsBundle success
"
);
...
...
@@ -3513,7 +3526,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```
ts
// setNotificationEnableSlot
function
setNotificationEnableSlotCallback
(
err
)
{
function
setNotificationEnableSlotCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`setNotificationEnableSlot failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -3606,11 +3619,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```
ts
// isNotificationSlotEnabled
function
getEnableSlotCallback
(
err
,
data
)
{
function
getEnableSlotCallback
(
err
:
Base
.
BusinessError
,
data
:
boolean
)
{
if
(
err
)
{
console
.
error
(
`isNotificationSlotEnabled failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
info
(
"
isNotificationSlotEnabled success
"
);
console
.
info
(
`isNotificationSlotEnabled success, data is
${
JSON
.
stringify
(
data
)}
`
);
}
};
...
...
@@ -3661,7 +3674,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```
ts
// isNotificationSlotEnabled
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
));
});
```
...
...
@@ -3701,10 +3714,10 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
ts
let
userId
=
100
;
let
enable
=
true
;
let
userId
:
number
=
100
;
let
enable
:
boolean
=
true
;
function
callback
(
err
)
{
function
callback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`setSyncNotificationEnabledWithoutApp failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -3755,13 +3768,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
ts
let
userId
=
100
;
let
enable
=
true
;
let
userId
:
number
=
100
;
let
enable
:
boolean
=
true
;
notificationManager
.
setSyncNotificationEnabledWithoutApp
(
userId
,
enable
).
then
(()
=>
{
console
.
info
(
'
setSyncNotificationEnabledWithoutApp success
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
`setSyncNotificationEnabledWithoutApp failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
});
```
...
...
@@ -3799,9 +3810,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
ts
let
userId
=
100
;
let
userId
:
number
=
100
;
function
getSyncNotificationEnabledWithoutAppCallback
(
err
,
data
)
{
function
getSyncNotificationEnabledWithoutAppCallback
(
err
:
Base
.
BusinessError
,
data
:
boolean
)
{
if
(
err
)
{
console
.
info
(
'
getSyncNotificationEnabledWithoutAppCallback, err:
'
+
err
);
}
else
{
...
...
@@ -3851,11 +3862,10 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example**
```
ts
let
userId
=
100
;
notificationManager
.
getSyncNotificationEnabledWithoutApp
(
userId
).
then
((
data
)
=>
{
let
userId
:
number
=
100
;
notificationManager
.
getSyncNotificationEnabledWithoutApp
(
userId
).
then
((
data
:
boolean
)
=>
{
console
.
info
(
'
getSyncNotificationEnabledWithoutApp, data:
'
+
data
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
getSyncNotificationEnabledWithoutApp, err:
'
+
err
);
});
```
...
...
@@ -3897,9 +3907,11 @@ try{
function
OnCheckNotification
(
info
:
notificationManager
.
NotificationCheckInfo
)
{
console
.
info
(
`====>OnCheckNotification info:
${
JSON
.
stringify
(
info
)}
`
);
if
(
info
.
notificationId
==
1
){
return
{
code
:
1
,
message
:
"
testMsg1
"
}
let
result
:
notificationManager
.
NotificationCheckResult
=
{
code
:
1
,
message
:
"
testMsg1
"
};
return
result
;
}
else
{
return
{
code
:
0
,
message
:
"
testMsg0
"
}
let
result
:
notificationManager
.
NotificationCheckResult
=
{
code
:
0
,
message
:
"
testMsg0
"
};
return
result
;
}
}
```
...
...
zh-cn/application-dev/reference/apis/js-apis-notificationManager.md
浏览文件 @
87e56a43
...
...
@@ -10,6 +10,7 @@
```
ts
import
notificationManager
from
'
@ohos.notificationManager
'
;
import
Base
from
'
@ohos.base
'
;
```
## notificationManager.publish
...
...
@@ -45,7 +46,7 @@ publish(request: NotificationRequest, callback: AsyncCallback\<void\>): void
```
ts
//publish回调
function
publishCallback
(
err
)
{
function
publishCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`publish failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -155,7 +156,7 @@ publish(request: NotificationRequest, userId: number, callback: AsyncCallback\<v
```
ts
// publish回调
function
publishCallback
(
err
)
{
function
publishCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`publish failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -163,7 +164,7 @@ function publishCallback(err) {
}
}
// 用户ID
let
userId
=
1
;
let
userId
:
number
=
1
;
// 通知Request对象
let
notificationRequest
:
notificationManager
.
NotificationRequest
=
{
id
:
1
,
...
...
@@ -228,7 +229,7 @@ let notificationRequest: notificationManager.NotificationRequest = {
}
};
let
userId
=
1
;
let
userId
:
number
=
1
;
notificationManager
.
publish
(
notificationRequest
,
userId
).
then
(()
=>
{
console
.
info
(
"
publish success
"
);
...
...
@@ -267,7 +268,7 @@ cancel(id: number, label: string, callback: AsyncCallback\<void\>): void
```
ts
// cancel回调
function
cancelCallback
(
err
)
{
function
cancelCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`cancel failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -341,7 +342,7 @@ cancel(id: number, callback: AsyncCallback\<void\>): void
```
ts
// cancel回调
function
cancelCallback
(
err
)
{
function
cancelCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`cancel failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -379,7 +380,7 @@ cancelAll(callback: AsyncCallback\<void\>): void
```
ts
// cancel回调
function
cancelAllCallback
(
err
)
{
function
cancelAllCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`cancelAll failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -449,7 +450,7 @@ addSlot(slot: NotificationSlot, callback: AsyncCallback\<void\>): void
```
ts
// addslot回调
function
addSlotCallBack
(
err
)
{
function
addSlotCallBack
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`addSlot failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -457,7 +458,7 @@ function addSlotCallBack(err) {
}
}
// 通知slot对象
let
notificationSlot
=
{
let
notificationSlot
:
notificationManager
.
NotificationSlot
=
{
type
:
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
};
notificationManager
.
addSlot
(
notificationSlot
,
addSlotCallBack
);
...
...
@@ -496,7 +497,7 @@ addSlot(slot: NotificationSlot): Promise\<void\>
```
ts
// 通知slot对象
let
notificationSlot
=
{
let
notificationSlot
:
notificationManager
.
NotificationSlot
=
{
type
:
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
};
notificationManager
.
addSlot
(
notificationSlot
).
then
(()
=>
{
...
...
@@ -534,7 +535,7 @@ addSlot(type: SlotType, callback: AsyncCallback\<void\>): void
```
ts
// addslot回调
function
addSlotCallBack
(
err
)
{
function
addSlotCallBack
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`addSlot failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -611,7 +612,7 @@ addSlots(slots: Array\<NotificationSlot\>, callback: AsyncCallback\<void\>): voi
```
ts
// addSlots回调
function
addSlotsCallBack
(
err
)
{
function
addSlotsCallBack
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`addSlots failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -619,11 +620,11 @@ function addSlotsCallBack(err) {
}
}
// 通知slot对象
let
notificationSlot
=
{
let
notificationSlot
:
notificationManager
.
NotificationSlot
=
{
type
:
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
};
// 通知slot array 对象
let
notificationSlotArray
=
new
Array
();
let
notificationSlotArray
:
notificationManager
.
NotificationSlot
[]
=
new
Array
();
notificationSlotArray
[
0
]
=
notificationSlot
;
notificationManager
.
addSlots
(
notificationSlotArray
,
addSlotsCallBack
);
...
...
@@ -662,11 +663,11 @@ addSlots(slots: Array\<NotificationSlot\>): Promise\<void\>
```
ts
// 通知slot对象
let
notificationSlot
=
{
let
notificationSlot
:
notificationManager
.
NotificationSlot
=
{
type
:
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
};
// 通知slot array 对象
let
notificationSlotArray
=
new
Array
();
let
notificationSlotArray
:
notificationManager
.
NotificationSlot
[]
=
new
Array
();
notificationSlotArray
[
0
]
=
notificationSlot
;
notificationManager
.
addSlots
(
notificationSlotArray
).
then
(()
=>
{
...
...
@@ -703,14 +704,14 @@ getSlot(slotType: SlotType, callback: AsyncCallback\<NotificationSlot\>): void
```
ts
// getSlot回调
function
getSlotCallback
(
err
,
data
)
{
function
getSlotCallback
(
err
:
Base
.
BusinessError
,
data
:
notificationManager
.
NotificationSlot
)
{
if
(
err
)
{
console
.
error
(
`getSlot failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
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
);
```
...
...
@@ -747,8 +748,9 @@ getSlot(slotType: SlotType): Promise\<NotificationSlot\>
**示例:**
```
ts
let
slotType
=
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
;
notificationManager
.
getSlot
(
slotType
).
then
((
data
)
=>
{
let
slotType
:
notificationManager
.
SlotType
=
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
;
notificationManager
.
getSlot
(
slotType
).
then
((
data
:
notificationManager
.
NotificationSlot
)
=>
{
console
.
info
(
"
getSlot success, data:
"
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -781,11 +783,11 @@ getSlots(callback: AsyncCallback\<Array\<NotificationSlot>>): void
```
ts
// getSlots回调
function
getSlotsCallback
(
err
,
data
)
{
function
getSlotsCallback
(
err
:
Base
.
BusinessError
,
data
:
Array
<
notificationManager
.
NotificationSlot
>
)
{
if
(
err
)
{
console
.
error
(
`getSlots failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
info
(
"
getSlots success
"
);
console
.
info
(
`getSlots success, data is
${
JSON
.
stringify
(
data
)}
`
);
}
}
notificationManager
.
getSlots
(
getSlotsCallback
);
...
...
@@ -818,7 +820,7 @@ getSlots(): Promise\<Array\<NotificationSlot>>
**示例:**
```
ts
notificationManager
.
getSlots
().
then
((
data
)
=>
{
notificationManager
.
getSlots
().
then
((
data
:
Array
<
notificationManager
.
NotificationSlot
>
)
=>
{
console
.
info
(
"
getSlots success, data:
"
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -852,7 +854,7 @@ removeSlot(slotType: SlotType, callback: AsyncCallback\<void\>): void
```
ts
// removeSlot回调
function
removeSlotCallback
(
err
)
{
function
removeSlotCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`removeSlot failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -860,7 +862,7 @@ function removeSlotCallback(err) {
}
}
let
slotType
=
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
;
notificationManager
.
removeSlot
(
slotType
,
removeSlotCallback
);
notificationManager
.
removeSlot
(
slotType
,
removeSlotCallback
);
```
## notificationManager.removeSlot
...
...
@@ -890,7 +892,7 @@ removeSlot(slotType: SlotType): Promise\<void\>
**示例:**
```
ts
let
slotType
=
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
;
let
slotType
:
notificationManager
.
SlotType
=
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
;
notificationManager
.
removeSlot
(
slotType
).
then
(()
=>
{
console
.
info
(
"
removeSlot success
"
);
});
...
...
@@ -923,7 +925,7 @@ removeAllSlots(callback: AsyncCallback\<void\>): void
**示例:**
```
ts
function
removeAllCallBack
(
err
)
{
function
removeAllCallBack
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`removeAllSlots failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -993,17 +995,17 @@ setNotificationEnable(bundle: BundleOption, enable: boolean, callback: AsyncCall
**示例:**
```
ts
function
setNotificationEnable
nCallback
(
er
r
)
{
function
setNotificationEnable
Callback
(
err
:
Base
.
BusinessErro
r
)
{
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
{
console
.
info
(
"
setNotificationEnable
n
Callback success
"
);
console
.
info
(
"
setNotificationEnableCallback success
"
);
}
}
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
};
notificationManager
.
setNotificationEnable
(
bundle
,
false
,
setNotificationEnable
n
Callback
);
notificationManager
.
setNotificationEnable
(
bundle
,
false
,
setNotificationEnableCallback
);
```
## notificationManager.setNotificationEnable
...
...
@@ -1039,7 +1041,7 @@ setNotificationEnable(bundle: BundleOption, enable: boolean): Promise\<void\>
**示例:**
```
ts
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
};
notificationManager
.
setNotificationEnable
(
bundle
,
false
).
then
(()
=>
{
...
...
@@ -1080,16 +1082,18 @@ isNotificationEnabled(bundle: BundleOption, callback: AsyncCallback\<boolean\>):
**示例:**
```
ts
function
isNotificationEnabledCallback
(
err
,
data
)
{
function
isNotificationEnabledCallback
(
err
:
Base
.
BusinessError
,
data
:
boolean
)
{
if
(
err
)
{
console
.
error
(
`isNotificationEnabled failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
info
(
"
isNotificationEnabled success
"
);
console
.
info
(
`isNotificationEnabled success, data is
${
JSON
.
stringify
(
data
)}
`
);
}
}
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
};
notificationManager
.
isNotificationEnabled
(
bundle
,
isNotificationEnabledCallback
);
```
...
...
@@ -1131,10 +1135,10 @@ isNotificationEnabled(bundle: BundleOption): Promise\<boolean\>
**示例:**
```
ts
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
};
notificationManager
.
isNotificationEnabled
(
bundle
).
then
((
data
)
=>
{
notificationManager
.
isNotificationEnabled
(
bundle
).
then
((
data
:
boolean
)
=>
{
console
.
info
(
"
isNotificationEnabled success, data:
"
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -1170,11 +1174,11 @@ isNotificationEnabled(callback: AsyncCallback\<boolean\>): void
**示例:**
```
ts
function
isNotificationEnabledCallback
(
err
,
data
)
{
function
isNotificationEnabledCallback
(
err
:
Base
.
BusinessError
,
data
:
boolean
)
{
if
(
err
)
{
console
.
error
(
`isNotificationEnabled failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
info
(
"
isNotificationEnabled success
"
);
console
.
info
(
`isNotificationEnabled success, data is
${
JSON
.
stringify
(
data
)}
`
);
}
}
...
...
@@ -1212,7 +1216,7 @@ isNotificationEnabled(): Promise\<boolean\>
**示例:**
```
ts
notificationManager
.
isNotificationEnabled
().
then
((
data
)
=>
{
notificationManager
.
isNotificationEnabled
().
then
((
data
:
boolean
)
=>
{
console
.
info
(
"
isNotificationEnabled success, data:
"
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -1250,15 +1254,15 @@ isNotificationEnabled(userId: number, callback: AsyncCallback\<boolean\>): void
**示例:**
```
ts
function
isNotificationEnabledCallback
(
err
,
data
)
{
function
isNotificationEnabledCallback
(
err
:
Base
.
BusinessError
,
data
:
boolean
)
{
if
(
err
)
{
console
.
error
(
`isNotificationEnabled failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
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
);
```
...
...
@@ -1301,9 +1305,9 @@ isNotificationEnabled(userId: number): Promise\<boolean\>
**示例:**
```
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
));
});
```
...
...
@@ -1342,14 +1346,14 @@ displayBadge(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<voi
**示例:**
```
ts
function
displayBadgeCallback
(
err
)
{
function
displayBadgeCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`displayBadge failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
info
(
"
displayBadge success
"
);
}
}
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
};
notificationManager
.
displayBadge
(
bundle
,
false
,
displayBadgeCallback
);
...
...
@@ -1388,7 +1392,7 @@ displayBadge(bundle: BundleOption, enable: boolean): Promise\<void\>
**示例:**
```
ts
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
};
notificationManager
.
displayBadge
(
bundle
,
false
).
then
(()
=>
{
...
...
@@ -1413,7 +1417,7 @@ isBadgeDisplayed(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | ------------------------ |
| 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
**示例:**
```
ts
function
isBadgeDisplayedCallback
(
err
,
data
)
{
function
isBadgeDisplayedCallback
(
err
:
Base
.
BusinessError
,
data
:
boolean
)
{
if
(
err
)
{
console
.
error
(
`isBadgeDisplayed failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
info
(
"
isBadgeDisplayed success
"
);
console
.
info
(
`isBadgeDisplayed success, data is
${
JSON
.
stringify
(
data
)}
`
);
}
}
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
};
notificationManager
.
isBadgeDisplayed
(
bundle
,
isBadgeDisplayedCallback
);
...
...
@@ -1480,10 +1484,11 @@ isBadgeDisplayed(bundle: BundleOption): Promise\<boolean\>
**示例:**
```
ts
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
};
notificationManager
.
isBadgeDisplayed
(
bundle
).
then
((
data
)
=>
{
notificationManager
.
isBadgeDisplayed
(
bundle
).
then
((
data
:
boolean
)
=>
{
console
.
info
(
"
isBadgeDisplayed success, data:
"
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -1514,7 +1519,8 @@ setBadgeNumber(badgeNumber: number): Promise\<void\>
**示例:**
```
ts
let
badgeNumber
=
10
let
badgeNumber
:
number
=
10
;
notificationManager
.
setBadgeNumber
(
badgeNumber
).
then
(()
=>
{
console
.
info
(
"
displayBadge success
"
);
});
...
...
@@ -1549,7 +1555,7 @@ setBadgeNumber(badgeNumber: number, callback: AsyncCallback\<void\>): void
**示例:**
```
ts
function
setBadgeNumberCallback
(
err
)
{
function
setBadgeNumberCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
info
(
`displayBadge failed code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -1557,7 +1563,7 @@ function setBadgeNumberCallback(err) {
}
}
let
badgeNumber
=
10
let
badgeNumber
:
number
=
10
;
notificationManager
.
setBadgeNumber
(
badgeNumber
,
setBadgeNumberCallback
);
```
...
...
@@ -1595,17 +1601,17 @@ setSlotByBundle(bundle: BundleOption, slot: NotificationSlot, callback: AsyncCal
**示例:**
```
ts
function
setSlotByBundleCallback
(
err
)
{
function
setSlotByBundleCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`setSlotByBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
info
(
"
setSlotByBundle success
"
);
}
}
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
};
let
notificationSlot
=
{
let
notificationSlot
:
notificationManager
.
NotificationSlot
=
{
type
:
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
};
notificationManager
.
setSlotByBundle
(
bundle
,
notificationSlot
,
setSlotByBundleCallback
);
...
...
@@ -1644,12 +1650,14 @@ setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise\<void\>
**示例:**
```
ts
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
};
let
notificationSlot
=
{
let
notificationSlot
:
notificationManager
.
NotificationSlot
=
{
type
:
notificationManager
.
SlotType
.
SOCIAL_COMMUNICATION
};
notificationManager
.
setSlotByBundle
(
bundle
,
notificationSlot
).
then
(()
=>
{
console
.
info
(
"
setSlotByBundle success
"
);
});
...
...
@@ -1688,14 +1696,14 @@ getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback\<Array\<Notificat
**示例:**
```
ts
function
getSlotsByBundleCallback
(
err
,
data
)
{
function
getSlotsByBundleCallback
(
err
:
Base
.
BusinessError
,
data
:
Array
<
notificationManager
.
NotificationSlot
>
)
{
if
(
err
)
{
console
.
error
(
`getSlotByBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
info
(
"
getSlotsByBundle success
"
);
console
.
info
(
`getSlotsByBundle success, data is
${
JSON
.
stringify
(
data
)}
`
);
}
}
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
};
notificationManager
.
getSlotsByBundle
(
bundle
,
getSlotsByBundleCallback
);
...
...
@@ -1739,10 +1747,11 @@ getSlotsByBundle(bundle: BundleOption): Promise\<Array\<NotificationSlot>>
**示例:**
```
ts
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
};
notificationManager
.
getSlotsByBundle
(
bundle
).
then
((
data
)
=>
{
notificationManager
.
getSlotsByBundle
(
bundle
).
then
((
data
:
Array
<
notificationManager
.
NotificationSlot
>
)
=>
{
console
.
info
(
"
getSlotsByBundle success, data:
"
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -1780,16 +1789,18 @@ getSlotNumByBundle(bundle: BundleOption, callback: AsyncCallback\<number\>): voi
**示例:**
```
ts
function
getSlotNumByBundleCallback
(
err
,
data
)
{
function
getSlotNumByBundleCallback
(
err
:
Base
.
BusinessError
,
data
:
number
)
{
if
(
err
)
{
console
.
error
(
`getSlotByBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
info
(
"
getSlotNumByBundle success
"
);
console
.
info
(
`getSlotNumByBundle success data is
${
JSON
.
stringify
(
data
)}
`
);
}
}
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
};
notificationManager
.
getSlotNumByBundle
(
bundle
,
getSlotNumByBundleCallback
);
```
...
...
@@ -1831,10 +1842,11 @@ getSlotNumByBundle(bundle: BundleOption): Promise\<number\>
**示例:**
```
ts
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
};
notificationManager
.
getSlotNumByBundle
(
bundle
).
then
((
data
)
=>
{
notificationManager
.
getSlotNumByBundle
(
bundle
).
then
((
data
:
number
)
=>
{
console
.
info
(
"
getSlotNumByBundle success, data:
"
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -1869,11 +1881,11 @@ getAllActiveNotifications(callback: AsyncCallback\<Array\<NotificationRequest>>)
**示例:**
```
ts
function
getAllActiveNotificationsCallback
(
err
,
data
)
{
function
getAllActiveNotificationsCallback
(
err
:
Base
.
BusinessError
,
data
:
Array
<
notificationManager
.
NotificationRequest
>
)
{
if
(
err
)
{
console
.
error
(
`getAllActiveNotifications failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
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
**示例:**
```
ts
notificationManager
.
getAllActiveNotifications
().
then
((
data
)
=>
{
notificationManager
.
getAllActiveNotifications
().
then
((
data
:
Array
<
notificationManager
.
NotificationRequest
>
)
=>
{
console
.
info
(
"
getAllActiveNotifications success, data:
"
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -1943,11 +1955,11 @@ getActiveNotificationCount(callback: AsyncCallback\<number\>): void
**示例:**
```
ts
function
getActiveNotificationCountCallback
(
err
,
data
)
{
function
getActiveNotificationCountCallback
(
err
:
Base
.
BusinessError
,
data
:
number
)
{
if
(
err
)
{
console
.
error
(
`getActiveNotificationCount failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
info
(
"
getActiveNotificationCount success
"
);
console
.
info
(
`getActiveNotificationCount success, data is
${
JSON
.
stringify
(
data
)}
`
);
}
}
...
...
@@ -1981,7 +1993,7 @@ getActiveNotificationCount(): Promise\<number\>
**示例:**
```
ts
notificationManager
.
getActiveNotificationCount
().
then
((
data
)
=>
{
notificationManager
.
getActiveNotificationCount
().
then
((
data
:
number
)
=>
{
console
.
info
(
"
getActiveNotificationCount success, data:
"
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -2013,7 +2025,7 @@ getActiveNotifications(callback: AsyncCallback\<Array\<NotificationRequest>>): v
**示例:**
```
ts
function
getActiveNotificationsCallback
(
err
,
data
)
{
function
getActiveNotificationsCallback
(
err
:
Base
.
BusinessError
,
data
:
Array
<
notificationManager
.
NotificationRequest
>
)
{
if
(
err
)
{
console
.
error
(
`getActiveNotifications failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -2051,7 +2063,7 @@ getActiveNotifications(): Promise\<Array\<[NotificationRequest](js-apis-inner-no
**示例:**
```
ts
notificationManager
.
getActiveNotifications
().
then
((
data
)
=>
{
notificationManager
.
getActiveNotifications
().
then
((
data
:
Array
<
notificationManager
.
NotificationRequest
>
)
=>
{
console
.
info
(
"
removeGroupByBundle success, data:
"
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -2084,7 +2096,7 @@ cancelGroup(groupName: string, callback: AsyncCallback\<void\>): void
**示例:**
```
ts
function
cancelGroupCallback
(
err
)
{
function
cancelGroupCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`cancelGroup failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -2092,7 +2104,7 @@ function cancelGroupCallback(err) {
}
}
let
groupName
=
"
GroupName
"
;
let
groupName
:
string
=
"
GroupName
"
;
notificationManager
.
cancelGroup
(
groupName
,
cancelGroupCallback
);
```
...
...
@@ -2124,7 +2136,7 @@ cancelGroup(groupName: string): Promise\<void\>
**示例:**
```
ts
let
groupName
=
"
GroupName
"
;
let
groupName
:
string
=
"
GroupName
"
;
notificationManager
.
cancelGroup
(
groupName
).
then
(()
=>
{
console
.
info
(
"
cancelGroup success
"
);
});
...
...
@@ -2164,7 +2176,7 @@ removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCall
**示例:**
```
ts
function
removeGroupByBundleCallback
(
err
)
{
function
removeGroupByBundleCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`removeGroupByBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -2172,8 +2184,8 @@ function removeGroupByBundleCallback(err) {
}
}
let
bundleOption
=
{
bundle
:
"
Bundle
"
};
let
groupName
=
"
GroupName
"
;
let
bundleOption
:
notificationManager
.
BundleOption
=
{
bundle
:
"
Bundle
"
};
let
groupName
:
string
=
"
GroupName
"
;
notificationManager
.
removeGroupByBundle
(
bundleOption
,
groupName
,
removeGroupByBundleCallback
);
```
...
...
@@ -2211,8 +2223,9 @@ removeGroupByBundle(bundle: BundleOption, groupName: string): Promise\<void\>
**示例:**
```
ts
let
bundleOption
=
{
bundle
:
"
Bundle
"
};
let
groupName
=
"
GroupName
"
;
let
bundleOption
:
notificationManager
.
BundleOption
=
{
bundle
:
"
Bundle
"
};
let
groupName
:
string
=
"
GroupName
"
;
notificationManager
.
removeGroupByBundle
(
bundleOption
,
groupName
).
then
(()
=>
{
console
.
info
(
"
removeGroupByBundle success
"
);
});
...
...
@@ -2251,7 +2264,7 @@ setDoNotDisturbDate(date: DoNotDisturbDate, callback: AsyncCallback\<void\>): vo
**示例:**
```
ts
function
setDoNotDisturbDateCallback
(
err
)
{
function
setDoNotDisturbDateCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`setDoNotDisturbDate failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -2259,7 +2272,7 @@ function setDoNotDisturbDateCallback(err) {
}
}
let
doNotDisturbDate
=
{
let
doNotDisturbDate
:
notificationManager
.
DoNotDisturbDate
=
{
type
:
notificationManager
.
DoNotDisturbType
.
TYPE_ONCE
,
begin
:
new
Date
(),
end
:
new
Date
(
2021
,
11
,
15
,
18
,
0
)
...
...
@@ -2300,7 +2313,7 @@ setDoNotDisturbDate(date: DoNotDisturbDate): Promise\<void\>
**示例:**
```
ts
let
doNotDisturbDate
=
{
let
doNotDisturbDate
:
notificationManager
.
DoNotDisturbDate
=
{
type
:
notificationManager
.
DoNotDisturbType
.
TYPE_ONCE
,
begin
:
new
Date
(),
end
:
new
Date
(
2021
,
11
,
15
,
18
,
0
)
...
...
@@ -2346,7 +2359,7 @@ setDoNotDisturbDate(date: DoNotDisturbDate, userId: number, callback: AsyncCallb
**示例:**
```
ts
function
setDoNotDisturbDateCallback
(
err
)
{
function
setDoNotDisturbDateCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`setDoNotDisturbDate failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -2354,13 +2367,13 @@ function setDoNotDisturbDateCallback(err) {
}
}
let
doNotDisturbDate
=
{
let
doNotDisturbDate
:
notificationManager
.
DoNotDisturbDate
=
{
type
:
notificationManager
.
DoNotDisturbType
.
TYPE_ONCE
,
begin
:
new
Date
(),
end
:
new
Date
(
2021
,
11
,
15
,
18
,
0
)
};
let
userId
=
1
;
let
userId
:
number
=
1
;
notificationManager
.
setDoNotDisturbDate
(
doNotDisturbDate
,
userId
,
setDoNotDisturbDateCallback
);
```
...
...
@@ -2399,13 +2412,13 @@ setDoNotDisturbDate(date: DoNotDisturbDate, userId: number): Promise\<void\>
**示例:**
```
ts
let
doNotDisturbDate
=
{
let
doNotDisturbDate
:
notificationManager
.
DoNotDisturbDate
=
{
type
:
notificationManager
.
DoNotDisturbType
.
TYPE_ONCE
,
begin
:
new
Date
(),
end
:
new
Date
(
2021
,
11
,
15
,
18
,
0
)
};
let
userId
=
1
;
let
userId
:
number
=
1
;
notificationManager
.
setDoNotDisturbDate
(
doNotDisturbDate
,
userId
).
then
(()
=>
{
console
.
info
(
"
setDoNotDisturbDate success
"
);
...
...
@@ -2445,11 +2458,11 @@ getDoNotDisturbDate(callback: AsyncCallback\<DoNotDisturbDate\>): void
**示例:**
```
ts
function
getDoNotDisturbDateCallback
(
err
,
data
)
{
function
getDoNotDisturbDateCallback
(
err
:
Base
.
BusinessError
,
data
:
notificationManager
.
DoNotDisturbDate
)
{
if
(
err
)
{
console
.
error
(
`getDoNotDisturbDate failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
info
(
"
getDoNotDisturbDate success
"
);
console
.
info
(
`getDoNotDisturbDate success, data is
${
JSON
.
stringify
(
data
)}
`
);
}
}
...
...
@@ -2488,7 +2501,7 @@ getDoNotDisturbDate(): Promise\<DoNotDisturbDate\>
**示例:**
```
ts
notificationManager
.
getDoNotDisturbDate
().
then
((
data
)
=>
{
notificationManager
.
getDoNotDisturbDate
().
then
((
data
:
notificationManager
.
DoNotDisturbDate
)
=>
{
console
.
info
(
"
getDoNotDisturbDate success, data:
"
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -2528,15 +2541,15 @@ getDoNotDisturbDate(userId: number, callback: AsyncCallback\<DoNotDisturbDate\>)
**示例:**
```
ts
function
getDoNotDisturbDateCallback
(
err
,
data
)
{
function
getDoNotDisturbDateCallback
(
err
:
Base
.
BusinessError
,
data
:
notificationManager
.
DoNotDisturbDate
)
{
if
(
err
)
{
console
.
error
(
`getDoNotDisturbDate failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
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
);
```
...
...
@@ -2580,9 +2593,9 @@ getDoNotDisturbDate(userId: number): Promise\<DoNotDisturbDate\>
**示例:**
```
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
));
});
```
...
...
@@ -2617,7 +2630,7 @@ notificationManager.getDoNotDisturbDate(userId).then((data) => {
**示例:**
```
ts
function
isSupportDoNotDisturbModeCallback
(
err
,
data
)
{
function
isSupportDoNotDisturbModeCallback
(
err
:
Base
.
BusinessError
,
data
:
boolean
)
{
if
(
err
)
{
console
.
error
(
`isSupportDoNotDisturbMode failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -2659,7 +2672,7 @@ isSupportDoNotDisturbMode(): Promise\<boolean\>
**示例:**
```
ts
notificationManager
.
isSupportDoNotDisturbMode
().
then
((
data
)
=>
{
notificationManager
.
isSupportDoNotDisturbMode
().
then
((
data
:
boolean
)
=>
{
console
.
info
(
"
supportDoNotDisturbMode success, data:
"
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -2692,8 +2705,8 @@ isSupportTemplate(templateName: string, callback: AsyncCallback\<boolean\>): voi
**示例:**
```
javascript
let
templateName
=
'
process
'
;
function
isSupportTemplateCallback
(
err
,
data
)
{
let
templateName
:
string
=
'
process
'
;
function
isSupportTemplateCallback
(
err
:
Base
.
BusinessError
,
data
:
boolean
)
{
if
(
err
)
{
console
.
error
(
`isSupportTemplate failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -2737,9 +2750,9 @@ isSupportTemplate(templateName: string): Promise\<boolean\>
**示例:**
```
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
));
});
```
...
...
@@ -2771,7 +2784,7 @@ requestEnableNotification(callback: AsyncCallback\<void\>): void
**示例:**
```
javascript
function
requestEnableNotificationCallback
(
err
)
{
function
requestEnableNotificationCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`requestEnableNotification failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -2912,7 +2925,7 @@ setDistributedEnable(enable: boolean, callback: AsyncCallback\<void\>): void
**示例:**
```
javascript
function
setDistributedEnableCallback
(
err
)
{
function
setDistributedEnableCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`setDistributedEnable failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -2920,7 +2933,7 @@ function setDistributedEnableCallback(err) {
}
};
let
enable
=
true
;
let
enable
:
boolean
=
true
;
notificationManager
.
setDistributedEnable
(
enable
,
setDistributedEnableCallback
);
```
...
...
@@ -2957,11 +2970,11 @@ setDistributedEnable(enable: boolean): Promise\<void>
**示例:**
```
javascript
let
enable
=
true
;
let
enable
:
boolean
=
true
;
notificationManager
.
setDistributedEnable
(
enable
).
then
(()
=>
{
console
.
info
(
"
setDistributedEnable success
"
);
});
});
```
...
...
@@ -2993,7 +3006,7 @@ isDistributedEnabled(callback: AsyncCallback\<boolean>): void
**示例:**
```
javascript
function
isDistributedEnabledCallback
(
err
,
data
)
{
function
isDistributedEnabledCallback
(
err
:
Base
.
BusinessError
,
data
:
boolean
)
{
if
(
err
)
{
console
.
error
(
`isDistributedEnabled failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -3035,7 +3048,7 @@ isDistributedEnabled(): Promise\<boolean>
```
javascript
notificationManager
.
isDistributedEnabled
()
.
then
((
data
)
=>
{
.
then
((
data
:
boolean
)
=>
{
console
.
info
(
"
isDistributedEnabled success, data:
"
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -3076,7 +3089,7 @@ setDistributedEnableByBundle(bundle: BundleOption, enable: boolean, callback: As
**示例:**
```
javascript
function
setDistributedEnableByBundleCallback
(
err
)
{
function
setDistributedEnableByBundleCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`setDistributedEnableByBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -3084,11 +3097,11 @@ function setDistributedEnableByBundleCallback(err) {
}
};
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
};
let
enable
=
true
let
enable
:
boolean
=
true
;
notificationManager
.
setDistributedEnableByBundle
(
bundle
,
enable
,
setDistributedEnableByBundleCallback
);
```
...
...
@@ -3129,11 +3142,11 @@ setDistributedEnableByBundle(bundle: BundleOption, enable: boolean): Promise\<vo
**示例:**
```
javascript
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
};
let
enable
=
true
let
enable
:
boolean
=
true
;
notificationManager
.
setDistributedEnableByBundle
(
bundle
,
enable
).
then
(()
=>
{
console
.
info
(
"
setDistributedEnableByBundle success
"
);
...
...
@@ -3174,7 +3187,7 @@ isDistributedEnabledByBundle(bundle: BundleOption, callback: AsyncCallback\<bool
**示例:**
```
javascript
function
isDistributedEnabledByBundleCallback
(
err
,
data
)
{
function
isDistributedEnabledByBundleCallback
(
err
:
Base
.
BusinessError
,
data
:
boolean
)
{
if
(
err
)
{
console
.
error
(
`isDistributedEnabledByBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -3182,7 +3195,7 @@ function isDistributedEnabledByBundleCallback(err, data) {
}
};
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
};
...
...
@@ -3228,11 +3241,11 @@ isDistributedEnabledByBundle(bundle: BundleOption): Promise\<boolean>
**示例:**
```
javascript
let
bundle
=
{
let
bundle
:
notificationManager
.
BundleOption
=
{
bundle
:
"
bundleName1
"
,
};
notificationManager
.
isDistributedEnabledByBundle
(
bundle
).
then
((
data
)
=>
{
notificationManager
.
isDistributedEnabledByBundle
(
bundle
).
then
((
data
:
boolean
)
=>
{
console
.
info
(
"
isDistributedEnabledByBundle success, data:
"
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -3269,11 +3282,11 @@ getDeviceRemindType(callback: AsyncCallback\<DeviceRemindType\>): void
**示例:**
```
javascript
function
getDeviceRemindTypeCallback
(
err
,
data
)
{
function
getDeviceRemindTypeCallback
(
err
:
Base
.
BusinessError
,
data
:
notificationManager
.
DeviceRemindType
)
{
if
(
err
)
{
console
.
error
(
`getDeviceRemindType failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
info
(
"
getDeviceRemindType success
"
);
console
.
info
(
`getDeviceRemindType success, data is
${
JSON
.
stringify
(
data
)}
`
);
}
};
...
...
@@ -3311,7 +3324,7 @@ getDeviceRemindType(): Promise\<DeviceRemindType\>
**示例:**
```
javascript
notificationManager
.
getDeviceRemindType
().
then
((
data
)
=>
{
notificationManager
.
getDeviceRemindType
().
then
((
data
:
notificationManager
.
DeviceRemindType
)
=>
{
console
.
info
(
"
getDeviceRemindType success, data:
"
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -3357,7 +3370,7 @@ publishAsBundle(request: NotificationRequest, representativeBundle: string, user
```
ts
//publishAsBundle回调
function
callback
(
err
)
{
function
callback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`publishAsBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -3365,11 +3378,11 @@ function callback(err) {
}
}
// 被代理应用的包名
let
representativeBundle
=
"
com.example.demo
"
;
let
representativeBundle
:
string
=
"
com.example.demo
"
;
// 用户ID
let
userId
=
100
;
let
userId
:
number
=
100
;
// NotificationRequest对象
let
request
=
{
let
request
:
notificationManager
.
NotificationRequest
=
{
id
:
1
,
content
:
{
contentType
:
notificationManager
.
ContentType
.
NOTIFICATION_CONTENT_BASIC_TEXT
,
...
...
@@ -3424,11 +3437,11 @@ publishAsBundle(request: NotificationRequest, representativeBundle: string, user
```
ts
// 被代理应用的包名
let
representativeBundle
=
"
com.example.demo
"
;
let
representativeBundle
:
string
=
"
com.example.demo
"
;
// 用户ID
let
userId
=
100
;
let
userId
:
number
=
100
;
// NotificationRequest对象
let
request
=
{
let
request
:
notificationManager
.
NotificationRequest
=
{
id
:
1
,
content
:
{
contentType
:
notificationManager
.
ContentType
.
NOTIFICATION_CONTENT_BASIC_TEXT
,
...
...
@@ -3484,7 +3497,7 @@ cancelAsBundle(id: number, representativeBundle: string, userId: number, callbac
```
ts
// cancelAsBundle
function
cancelAsBundleCallback
(
err
)
{
function
cancelAsBundleCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`cancelAsBundle failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -3492,9 +3505,9 @@ function cancelAsBundleCallback(err) {
}
}
// 被代理应用的包名
let
representativeBundle
=
"
com.example.demo
"
;
let
representativeBundle
:
string
=
"
com.example.demo
"
;
// 用户ID
let
userId
=
100
;
let
userId
:
number
=
100
;
notificationManager
.
cancelAsBundle
(
0
,
representativeBundle
,
userId
,
cancelAsBundleCallback
);
```
...
...
@@ -3537,9 +3550,9 @@ cancelAsBundle(id: number, representativeBundle: string, userId: number): Promis
```
ts
// 被代理应用的包名
let
representativeBundle
=
"
com.example.demo
"
;
let
representativeBundle
:
string
=
"
com.example.demo
"
;
// 用户ID
let
userId
=
100
;
let
userId
:
number
=
100
;
notificationManager
.
cancelAsBundle
(
0
,
representativeBundle
,
userId
).
then
(()
=>
{
console
.
info
(
"
cancelAsBundle success
"
);
...
...
@@ -3582,7 +3595,7 @@ setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean,
```
ts
// setNotificationEnableSlot
function
setNotificationEnableSlotCallback
(
err
)
{
function
setNotificationEnableSlotCallback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`setNotificationEnableSlot failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -3675,11 +3688,11 @@ isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncC
```
ts
// isNotificationSlotEnabled
function
getEnableSlotCallback
(
err
,
data
)
{
function
getEnableSlotCallback
(
err
:
Base
.
BusinessError
,
data
:
boolean
)
{
if
(
err
)
{
console
.
error
(
`isNotificationSlotEnabled failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
info
(
"
isNotificationSlotEnabled success
"
);
console
.
info
(
`isNotificationSlotEnabled success, data is
${
JSON
.
stringify
(
data
)}
`
);
}
};
...
...
@@ -3730,7 +3743,7 @@ isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise\<boolea
```
ts
// isNotificationSlotEnabled
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
));
});
```
...
...
@@ -3770,10 +3783,10 @@ setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean, callback:
**示例:**
```
ts
let
userId
=
100
;
let
enable
=
true
;
let
userId
:
number
=
100
;
let
enable
:
boolean
=
true
;
function
callback
(
err
)
{
function
callback
(
err
:
Base
.
BusinessError
)
{
if
(
err
)
{
console
.
error
(
`setSyncNotificationEnabledWithoutApp failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
...
...
@@ -3824,13 +3837,11 @@ setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean): Promise\<
**示例:**
```
ts
let
userId
=
100
;
let
enable
=
true
;
let
userId
:
number
=
100
;
let
enable
:
boolean
=
true
;
notificationManager
.
setSyncNotificationEnabledWithoutApp
(
userId
,
enable
).
then
(()
=>
{
console
.
info
(
'
setSyncNotificationEnabledWithoutApp success
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
`setSyncNotificationEnabledWithoutApp failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
});
```
...
...
@@ -3868,9 +3879,9 @@ getSyncNotificationEnabledWithoutApp(userId: number, callback: AsyncCallback\<bo
**示例:**
```
ts
let
userId
=
100
;
let
userId
:
number
=
100
;
function
getSyncNotificationEnabledWithoutAppCallback
(
err
,
data
)
{
function
getSyncNotificationEnabledWithoutAppCallback
(
err
:
Base
.
BusinessError
,
data
:
boolean
)
{
if
(
err
)
{
console
.
info
(
'
getSyncNotificationEnabledWithoutAppCallback, err:
'
+
err
);
}
else
{
...
...
@@ -3920,11 +3931,10 @@ getSyncNotificationEnabledWithoutApp(userId: number): Promise\<boolean>
**示例:**
```
ts
let
userId
=
100
;
notificationManager
.
getSyncNotificationEnabledWithoutApp
(
userId
).
then
((
data
)
=>
{
let
userId
:
number
=
100
;
notificationManager
.
getSyncNotificationEnabledWithoutApp
(
userId
).
then
((
data
:
boolean
)
=>
{
console
.
info
(
'
getSyncNotificationEnabledWithoutApp, data:
'
+
data
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
getSyncNotificationEnabledWithoutApp, err:
'
+
err
);
});
```
...
...
@@ -3966,9 +3976,11 @@ try{
function
OnCheckNotification
(
info
:
notificationManager
.
NotificationCheckInfo
)
{
console
.
info
(
`====>OnCheckNotification info:
${
JSON
.
stringify
(
info
)}
`
);
if
(
info
.
notificationId
==
1
){
return
{
code
:
1
,
message
:
"
testMsg1
"
}
let
result
:
notificationManager
.
NotificationCheckResult
=
{
code
:
1
,
message
:
"
testMsg1
"
};
return
result
;
}
else
{
return
{
code
:
0
,
message
:
"
testMsg0
"
}
let
result
:
notificationManager
.
NotificationCheckResult
=
{
code
:
0
,
message
:
"
testMsg0
"
};
return
result
;
}
}
```
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录