You need to sign in or sign up before continuing.
提交 c281113d 编写于 作者: E ester.zhou

update notification docs

Signed-off-by: Nester.zhou <ester.zhou@huawei.com>
上级 d8f8ae5f
# CommonEvent # CommonEvent
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Required Permissions ## Required Permissions
...@@ -181,7 +181,7 @@ Publishes a common event. This API uses a callback to return the result. ...@@ -181,7 +181,7 @@ Publishes a common event. This API uses a callback to return the result.
**Example** **Example**
```js ```js
// Callback for common event publication // Callback for common event publication.
function PublishCallBack(err) { function PublishCallBack(err) {
if (err.code) { if (err.code) {
console.error("publish failed " + JSON.stringify(err)); console.error("publish failed " + JSON.stringify(err));
...@@ -219,7 +219,7 @@ Publishes a common event with given attributes. This API uses a callback to retu ...@@ -219,7 +219,7 @@ Publishes a common event with given attributes. This API uses a callback to retu
// Attributes of a common event. // Attributes of a common event.
var options = { var options = {
code: 0, // Result code of the common event code: 0, // Result code of the common event
data: "initial data";// Result data of the common event data: "initial data",// Result data of the common event
isOrdered: true // The common event is an ordered one. isOrdered: true // The common event is an ordered one.
} }
...@@ -257,7 +257,7 @@ Publishes a common event to a specific user. This API uses a callback to return ...@@ -257,7 +257,7 @@ Publishes a common event to a specific user. This API uses a callback to return
**Example** **Example**
```js ```js
// Callback for common event publication // Callback for common event publication.
function PublishAsUserCallBack(err) { function PublishAsUserCallBack(err) {
if (err.code) { if (err.code) {
console.error("publishAsUser failed " + JSON.stringify(err)); console.error("publishAsUser failed " + JSON.stringify(err));
...@@ -299,7 +299,7 @@ Publishes a common event with given attributes to a specific user. This API uses ...@@ -299,7 +299,7 @@ Publishes a common event with given attributes to a specific user. This API uses
// Attributes of a common event. // Attributes of a common event.
var options = { var options = {
code: 0, // Result code of the common event code: 0, // Result code of the common event
data: "initial data";// Result data of the common event data: "initial data",// Result data of the common event
} }
// Callback for common event publication // Callback for common event publication
...@@ -1177,12 +1177,12 @@ Finishes this ordered common event. This API uses a callback to return the resul ...@@ -1177,12 +1177,12 @@ Finishes this ordered common event. This API uses a callback to return the resul
var subscriber; // Subscriber object successfully created. var subscriber; // Subscriber object successfully created.
// Callback for ordered common event finishing. // Callback for ordered common event finishing.
function finishCommonEventCallback() { function finishCommonEventCallback(err) {
if (err.code) { if (err.code) {
console.error("finishCommonEvent failed " + JSON.stringify(err)); console.error("finishCommonEvent failed " + JSON.stringify(err));
} else { } else {
console.info("FinishCommonEvent"); console.info("FinishCommonEvent");
} }
} }
subscriber.finishCommonEvent(finishCommonEventCallback); subscriber.finishCommonEvent(finishCommonEventCallback);
``` ```
......
# Notification # Notification
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**<br>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import ## Modules to Import
...@@ -85,6 +85,8 @@ Publishes a notification. This API uses an asynchronous callback to return the r ...@@ -85,6 +85,8 @@ Publishes a notification. This API uses an asynchronous callback to return the r
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -100,7 +102,7 @@ Publishes a notification. This API uses an asynchronous callback to return the r ...@@ -100,7 +102,7 @@ Publishes a notification. This API uses an asynchronous callback to return the r
function publishCallback(err) { function publishCallback(err) {
console.info("==========================>publishCallback=======================>"); console.info("==========================>publishCallback=======================>");
} }
// ID of the user who receives the notification. // ID of the user who receives the notification
var userId = 1 var userId = 1
// NotificationRequest object // NotificationRequest object
var notificationRequest = { var notificationRequest = {
...@@ -125,6 +127,8 @@ Publishes a notification. This API uses a promise to return the result. ...@@ -125,6 +127,8 @@ Publishes a notification. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -287,6 +291,8 @@ Adds a notification slot. This API uses an asynchronous callback to return the r ...@@ -287,6 +291,8 @@ Adds a notification slot. This API uses an asynchronous callback to return the r
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -318,6 +324,8 @@ Adds a notification slot. This API uses a promise to return the result. ...@@ -318,6 +324,8 @@ Adds a notification slot. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name| Readable| Writable| Type | Mandatory| Description | | Name| Readable| Writable| Type | Mandatory| Description |
...@@ -397,6 +405,8 @@ Adds multiple notification slots. This API uses an asynchronous callback to retu ...@@ -397,6 +405,8 @@ Adds multiple notification slots. This API uses an asynchronous callback to retu
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -432,6 +442,8 @@ Adds multiple notification slots. This API uses a promise to return the result. ...@@ -432,6 +442,8 @@ Adds multiple notification slots. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -669,6 +681,8 @@ Subscribes to a notification with the subscription information specified. This A ...@@ -669,6 +681,8 @@ Subscribes to a notification with the subscription information specified. This A
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -684,7 +698,7 @@ Subscribes to a notification with the subscription information specified. This A ...@@ -684,7 +698,7 @@ Subscribes to a notification with the subscription information specified. This A
function subscribeCallback(err) { function subscribeCallback(err) {
console.info("==========================>subscribeCallback=======================>"); console.info("==========================>subscribeCallback=======================>");
} }
function onConsumeCallback(err, data) { function onConsumeCallback(data) {
console.info("==========================>onConsumeCallback=======================>"); console.info("==========================>onConsumeCallback=======================>");
} }
var subscriber = { var subscriber = {
...@@ -706,6 +720,8 @@ Subscribes to a notification with the subscription information specified. This A ...@@ -706,6 +720,8 @@ Subscribes to a notification with the subscription information specified. This A
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -719,7 +735,7 @@ Subscribes to a notification with the subscription information specified. This A ...@@ -719,7 +735,7 @@ Subscribes to a notification with the subscription information specified. This A
function subscribeCallback(err) { function subscribeCallback(err) {
console.info("==========================>subscribeCallback=======================>"); console.info("==========================>subscribeCallback=======================>");
} }
function onConsumeCallback(err, data) { function onConsumeCallback(data) {
console.info("==========================>onConsumeCallback=======================>"); console.info("==========================>onConsumeCallback=======================>");
} }
var subscriber = { var subscriber = {
...@@ -738,6 +754,8 @@ Subscribes to a notification with the subscription information specified. This A ...@@ -738,6 +754,8 @@ Subscribes to a notification with the subscription information specified. This A
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -748,7 +766,7 @@ Subscribes to a notification with the subscription information specified. This A ...@@ -748,7 +766,7 @@ Subscribes to a notification with the subscription information specified. This A
**Example** **Example**
```js ```js
function onConsumeCallback(err, data) { function onConsumeCallback(data) {
console.info("==========================>onConsumeCallback=======================>"); console.info("==========================>onConsumeCallback=======================>");
} }
var subscriber = { var subscriber = {
...@@ -769,6 +787,8 @@ Unsubscribes from a notification. This API uses an asynchronous callback to retu ...@@ -769,6 +787,8 @@ Unsubscribes from a notification. This API uses an asynchronous callback to retu
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -782,7 +802,7 @@ Unsubscribes from a notification. This API uses an asynchronous callback to retu ...@@ -782,7 +802,7 @@ Unsubscribes from a notification. This API uses an asynchronous callback to retu
function unsubscribeCallback(err) { function unsubscribeCallback(err) {
console.info("==========================>unsubscribeCallback=======================>"); console.info("==========================>unsubscribeCallback=======================>");
} }
function onConsumeCallback(err, data) { function onConsumeCallback(data) {
console.info("==========================>onConsumeCallback=======================>"); console.info("==========================>onConsumeCallback=======================>");
} }
var subscriber = { var subscriber = {
...@@ -801,6 +821,8 @@ Unsubscribes from a notification. This API uses a promise to return the result. ...@@ -801,6 +821,8 @@ Unsubscribes from a notification. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -810,7 +832,7 @@ Unsubscribes from a notification. This API uses a promise to return the result. ...@@ -810,7 +832,7 @@ Unsubscribes from a notification. This API uses a promise to return the result.
**Example** **Example**
```js ```js
function onConsumeCallback(err, data) { function onConsumeCallback(data) {
console.info("==========================>onConsumeCallback=======================>"); console.info("==========================>onConsumeCallback=======================>");
} }
var subscriber = { var subscriber = {
...@@ -831,6 +853,8 @@ Sets whether to enable notification for a specified bundle. This API uses an asy ...@@ -831,6 +853,8 @@ Sets whether to enable notification for a specified bundle. This API uses an asy
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -861,6 +885,8 @@ Sets whether to enable notification for a specified bundle. This API uses a prom ...@@ -861,6 +885,8 @@ Sets whether to enable notification for a specified bundle. This API uses a prom
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -889,6 +915,8 @@ Checks whether notification is enabled for a specified bundle. This API uses an ...@@ -889,6 +915,8 @@ Checks whether notification is enabled for a specified bundle. This API uses an
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -918,6 +946,8 @@ Checks whether notification is enabled for a specified bundle. This API uses a p ...@@ -918,6 +946,8 @@ Checks whether notification is enabled for a specified bundle. This API uses a p
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -951,6 +981,8 @@ Checks whether notification is enabled for this application. This API uses an as ...@@ -951,6 +981,8 @@ Checks whether notification is enabled for this application. This API uses an as
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -977,6 +1009,8 @@ Checks whether notification is enabled for this application. This API uses a pro ...@@ -977,6 +1009,8 @@ Checks whether notification is enabled for this application. This API uses a pro
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -1007,6 +1041,8 @@ Sets whether to enable the notification badge for a specified bundle. This API u ...@@ -1007,6 +1041,8 @@ Sets whether to enable the notification badge for a specified bundle. This API u
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -1037,6 +1073,8 @@ Sets the notification slot for a specified bundle. This API uses a promise to re ...@@ -1037,6 +1073,8 @@ Sets the notification slot for a specified bundle. This API uses a promise to re
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -1065,6 +1103,8 @@ Checks whether the notification badge is enabled for a specified bundle. This AP ...@@ -1065,6 +1103,8 @@ Checks whether the notification badge is enabled for a specified bundle. This AP
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -1094,6 +1134,8 @@ Checks whether the notification badge is enabled for a specified bundle. This AP ...@@ -1094,6 +1134,8 @@ Checks whether the notification badge is enabled for a specified bundle. This AP
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -1127,6 +1169,8 @@ Sets the notification slot for a specified bundle. This API uses an asynchronous ...@@ -1127,6 +1169,8 @@ Sets the notification slot for a specified bundle. This API uses an asynchronous
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -1160,6 +1204,8 @@ Sets the notification slot for a specified bundle. This API uses a promise to re ...@@ -1160,6 +1204,8 @@ Sets the notification slot for a specified bundle. This API uses a promise to re
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -1176,7 +1222,7 @@ var bundle = { ...@@ -1176,7 +1222,7 @@ var bundle = {
var notificationSlot = { var notificationSlot = {
type: Notification.SlotType.SOCIAL_COMMUNICATION type: Notification.SlotType.SOCIAL_COMMUNICATION
} }
Notification.displayBadge(bundle, notificationSlot).then(() => { Notification.setSlotByBundle(bundle, notificationSlot).then(() => {
console.info("==========================>setSlotByBundleCallback=======================>"); console.info("==========================>setSlotByBundleCallback=======================>");
}); });
``` ```
...@@ -1191,6 +1237,8 @@ Obtains the notification slots of a specified bundle. This API uses an asynchron ...@@ -1191,6 +1237,8 @@ Obtains the notification slots of a specified bundle. This API uses an asynchron
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -1220,6 +1268,8 @@ Obtains the notification slots of a specified bundle. This API uses a promise to ...@@ -1220,6 +1268,8 @@ Obtains the notification slots of a specified bundle. This API uses a promise to
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -1253,6 +1303,8 @@ Obtains the number of notification slots of a specified bundle. This API uses an ...@@ -1253,6 +1303,8 @@ Obtains the number of notification slots of a specified bundle. This API uses an
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -1263,7 +1315,7 @@ Obtains the number of notification slots of a specified bundle. This API uses an ...@@ -1263,7 +1315,7 @@ Obtains the number of notification slots of a specified bundle. This API uses an
**Example** **Example**
```js ```js
function getSlotNumByBundle(err, data) { function getSlotNumByBundleCallback(err, data) {
console.info("==========================>getSlotNumByBundleCallback=======================>"); console.info("==========================>getSlotNumByBundleCallback=======================>");
} }
var bundle = { var bundle = {
...@@ -1282,6 +1334,8 @@ Obtains the number of notification slots of a specified bundle. This API uses a ...@@ -1282,6 +1334,8 @@ Obtains the number of notification slots of a specified bundle. This API uses a
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -1315,6 +1369,8 @@ Removes a notification for a specified bundle. This API uses an asynchronous cal ...@@ -1315,6 +1369,8 @@ Removes a notification for a specified bundle. This API uses an asynchronous cal
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -1349,6 +1405,8 @@ Removes a notification for a specified bundle. This API uses a promise to return ...@@ -1349,6 +1405,8 @@ Removes a notification for a specified bundle. This API uses a promise to return
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -1381,6 +1439,8 @@ Removes a notification for a specified bundle. This API uses an asynchronous cal ...@@ -1381,6 +1439,8 @@ Removes a notification for a specified bundle. This API uses an asynchronous cal
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -1391,6 +1451,8 @@ Removes a notification for a specified bundle. This API uses an asynchronous cal ...@@ -1391,6 +1451,8 @@ Removes a notification for a specified bundle. This API uses an asynchronous cal
**Example** **Example**
```js ```js
var hashCode = 'hashCode'
function removeCallback(err) { function removeCallback(err) {
console.info("==========================>removeCallback=======================>"); console.info("==========================>removeCallback=======================>");
} }
...@@ -1408,6 +1470,8 @@ Removes a notification for a specified bundle. This API uses a promise to return ...@@ -1408,6 +1470,8 @@ Removes a notification for a specified bundle. This API uses a promise to return
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -1417,6 +1481,8 @@ Removes a notification for a specified bundle. This API uses a promise to return ...@@ -1417,6 +1481,8 @@ Removes a notification for a specified bundle. This API uses a promise to return
**Example** **Example**
```js ```js
var hashCode = 'hashCode'
Notification.remove(hashCode).then(() => { Notification.remove(hashCode).then(() => {
console.info("==========================>removeCallback=======================>"); console.info("==========================>removeCallback=======================>");
}); });
...@@ -1432,6 +1498,8 @@ Removes all notifications for a specified bundle. This API uses an asynchronous ...@@ -1432,6 +1498,8 @@ Removes all notifications for a specified bundle. This API uses an asynchronous
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -1461,6 +1529,8 @@ Removes all notifications. This API uses an asynchronous callback to return the ...@@ -1461,6 +1529,8 @@ Removes all notifications. This API uses an asynchronous callback to return the
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -1487,6 +1557,8 @@ Removes all notifications for a specified user. This API uses a promise to retur ...@@ -1487,6 +1557,8 @@ Removes all notifications for a specified user. This API uses a promise to retur
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -1509,6 +1581,8 @@ Removes all notifications for a specified user. This API uses an asynchronous ca ...@@ -1509,6 +1581,8 @@ Removes all notifications for a specified user. This API uses an asynchronous ca
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -1536,6 +1610,8 @@ Removes all notifications for a specified user. This API uses a promise to retur ...@@ -1536,6 +1610,8 @@ Removes all notifications for a specified user. This API uses a promise to retur
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -1563,6 +1639,8 @@ Obtains all active notifications. This API uses an asynchronous callback to retu ...@@ -1563,6 +1639,8 @@ Obtains all active notifications. This API uses an asynchronous callback to retu
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -1589,6 +1667,8 @@ Obtains all active notifications. This API uses a promise to return the result. ...@@ -1589,6 +1667,8 @@ Obtains all active notifications. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Return value** **Return value**
| Type | Description | | Type | Description |
...@@ -1767,6 +1847,8 @@ Removes a notification group for a specified bundle. This API uses an asynchrono ...@@ -1767,6 +1847,8 @@ Removes a notification group for a specified bundle. This API uses an asynchrono
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -1798,6 +1880,8 @@ Removes a notification group for a specified bundle. This API uses a promise to ...@@ -1798,6 +1880,8 @@ Removes a notification group for a specified bundle. This API uses a promise to
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -1825,6 +1909,8 @@ Sets the DND time. This API uses an asynchronous callback to return the result. ...@@ -1825,6 +1909,8 @@ Sets the DND time. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -1858,6 +1944,8 @@ Sets the DND time. This API uses a promise to return the result. ...@@ -1858,6 +1944,8 @@ Sets the DND time. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name| Readable| Writable| Type | Mandatory| Description | | Name| Readable| Writable| Type | Mandatory| Description |
...@@ -1886,6 +1974,8 @@ Sets the DND time for a specified user. This API uses an asynchronous callback t ...@@ -1886,6 +1974,8 @@ Sets the DND time for a specified user. This API uses an asynchronous callback t
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -1922,6 +2012,8 @@ Sets the DND time for a specified user. This API uses a promise to return the re ...@@ -1922,6 +2012,8 @@ Sets the DND time for a specified user. This API uses a promise to return the re
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -1954,6 +2046,8 @@ Obtains the DND time. This API uses an asynchronous callback to return the resul ...@@ -1954,6 +2046,8 @@ Obtains the DND time. This API uses an asynchronous callback to return the resul
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -1980,6 +2074,8 @@ Obtains the DND time. This API uses a promise to return the result. ...@@ -1980,6 +2074,8 @@ Obtains the DND time. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Return value** **Return value**
| Type | Description | | Type | Description |
...@@ -2063,6 +2159,8 @@ Checks whether the DND mode is supported. This API uses an asynchronous callback ...@@ -2063,6 +2159,8 @@ Checks whether the DND mode is supported. This API uses an asynchronous callback
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
...@@ -2089,6 +2187,8 @@ Checks whether the DND mode is supported. This API uses a promise to return the ...@@ -2089,6 +2187,8 @@ Checks whether the DND mode is supported. This API uses a promise to return the
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Return value** **Return value**
| Type | Description | | Type | Description |
...@@ -2182,11 +2282,11 @@ Requests notification to be enabled for this application. This API uses an async ...@@ -2182,11 +2282,11 @@ Requests notification to be enabled for this application. This API uses an async
**Example** **Example**
```javascript ```javascript
function requestEnabledNotificationCallback() { function requestEnableNotificationCallback() {
console.log('------------- requestEnabledNotification --------------'); console.log('------------- requestEnabledNotification --------------');
}; };
Notification.requestEnabledNotification(requestEnabledNotificationCallback); Notification.requestEnableNotification(requestEnableNotificationCallback);
``` ```
...@@ -2217,6 +2317,8 @@ Sets whether this device supports distributed notifications. This API uses an as ...@@ -2217,6 +2317,8 @@ Sets whether this device supports distributed notifications. This API uses an as
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
...@@ -2246,6 +2348,8 @@ Sets whether this device supports distributed notifications. This API uses a pro ...@@ -2246,6 +2348,8 @@ Sets whether this device supports distributed notifications. This API uses a pro
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
...@@ -2285,7 +2389,7 @@ function isDistributedEnabledCallback() { ...@@ -2285,7 +2389,7 @@ function isDistributedEnabledCallback() {
console.log('----------- isDistributedEnabled ------------'); console.log('----------- isDistributedEnabled ------------');
}; };
Notification.enableDistributed(isDistributedEnabledCallback); Notification.isDistributedEnabled(isDistributedEnabledCallback);
``` ```
...@@ -2322,6 +2426,8 @@ Sets whether an application supports distributed notifications based on the bund ...@@ -2322,6 +2426,8 @@ Sets whether an application supports distributed notifications based on the bund
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
...@@ -2350,12 +2456,14 @@ Notification.enableDistributedByBundle(bundle, enable, enableDistributedByBundle ...@@ -2350,12 +2456,14 @@ Notification.enableDistributedByBundle(bundle, enable, enableDistributedByBundle
## Notification.enableDistributedByBundle<sup>8+</sup> ## Notification.enableDistributedByBundle<sup>8+</sup>
bundleenableDistributedByBundle(bundle: BundleOption, enable: boolean): Promise<void> bundleenableDistributedByBundle(bundle: BundleOption, enable: boolean): Promise\<void>
Sets whether an application supports distributed notifications based on the bundle. This API uses a promise to return the result. Sets whether an application supports distributed notifications based on the bundle. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
...@@ -2386,6 +2494,8 @@ Obtains whether an application supports distributed notifications based on the b ...@@ -2386,6 +2494,8 @@ Obtains whether an application supports distributed notifications based on the b
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
...@@ -2404,7 +2514,7 @@ var bundle = { ...@@ -2404,7 +2514,7 @@ var bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} }
Notification.enableDistributedByBundle(bundle, isDistributedEnabledByBundleCallback); Notification.isDistributedEnabledByBundle(bundle, isDistributedEnabledByBundleCallback);
``` ```
...@@ -2417,6 +2527,8 @@ Obtains whether an application supports distributed notifications based on the b ...@@ -2417,6 +2527,8 @@ Obtains whether an application supports distributed notifications based on the b
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
...@@ -2451,6 +2563,8 @@ Obtains the notification reminder type. This API uses an asynchronous callback t ...@@ -2451,6 +2563,8 @@ Obtains the notification reminder type. This API uses an asynchronous callback t
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
...@@ -2477,6 +2591,8 @@ Obtains the notification reminder type. This API uses a promise to return the re ...@@ -2477,6 +2591,8 @@ Obtains the notification reminder type. This API uses a promise to return the re
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Return value** **Return value**
| Type | Description | | Type | Description |
...@@ -2492,8 +2608,289 @@ Notification.getDeviceRemindType() ...@@ -2492,8 +2608,289 @@ Notification.getDeviceRemindType()
}); });
``` ```
## Notification.publishAsBundle<sup>9+</sup>
publishAsBundle(request: NotificationRequest, representativeBundle: string, userId: number, callback: AsyncCallback\<void\>): void
Publishes an agent-powered notification. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
| -------------------- | ------------------------------------------- | ---- | --------------------------------------------- |
| request | [NotificationRequest](#notificationrequest) | Yes | Notification to publish.|
| representativeBundle | string | Yes | Bundle name of the application whose notification function is taken over by the reminder agent. |
| userId | number | Yes | ID of the user who receives the notification. |
| callback | AsyncCallback | Yes | Callback used to return the result. |
**Example**
```js
// Callback for publishAsBundle
function publishAsBundleCallback(err) {
console.info("==========================>publishAsBundleCallback=======================>");
}
// Bundle name of the application whose notification function is taken over by the reminder agent
let representativeBundle = "com.example.demo"
// ID of the user who receives the notification
let userId = 100
// NotificationRequest object
let notificationRequest = {
id: 1,
content: {
contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test_title",
text: "test_text",
additionalText: "test_additionalText"
}
}
}
Notification.publishAsBundle(notificationRequest, representativeBundle, userId, publishAsBundleCallback);
```
## Notification.publishAsBundle<sup>9+</sup>
publishAsBundle(request: NotificationRequest, representativeBundle: string, userId: number): Promise\<void\>
Publishes a notification through the reminder agent. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
| -------------------- | ------------------------------------------- | ---- | --------------------------------------------- |
| request | [NotificationRequest](#notificationrequest) | Yes | Notification to publish.|
| representativeBundle | string | Yes | Bundle name of the application whose notification function is taken over by the reminder agent. |
| userId | number | Yes | ID of the user who receives the notification. |
**Example**
```js
// Bundle name of the application whose notification function is taken over by the reminder agent
let representativeBundle = "com.example.demo"
// ID of the user who receives the notification
let userId = 100
// NotificationRequest object
var notificationRequest = {
id: 1,
content: {
contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test_title",
text: "test_text",
additionalText: "test_additionalText"
}
}
}
Notification.publishAsBundle(notificationRequest, representativeBundle, userId).then(() => {
console.info("==========================>publishAsBundleCallback=======================>");
});
```
## Notification.cancelAsBundle<sup>9+</sup>
cancelAsBundle(id: number, representativeBundle: string, userId: number, callback: AsyncCallback\<void\>): void
Cancels a notification published by the reminder agent. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.Notification
**Parameters**
| Name | Type | Mandatory| Description |
| -------------------- | ------------- | ---- | ------------------------ |
| id | number | Yes | Notification ID. |
| representativeBundle | string | Yes | Bundle name of the application whose notification function is taken over by the reminder agent. |
| userId | number | Yes | ID of the user who receives the notification. |
| callback | AsyncCallback | Yes | Callback used to return the result.|
**Example**
```js
//cancelAsBundle
function cancelAsBundleCallback(err) {
console.info("==========================>cancelAsBundleCallback=======================>");
}
// Bundle name of the application whose notification function is taken over by the reminder agent
let representativeBundle = "com.example.demo"
// ID of the user who receives the notification
let userId = 100
Notification.cancelAsBundle(0, representativeBundle, userId, cancelAsBundleCallback);
```
## Notification.cancelAsBundle<sup>9+</sup>
cancelAsBundle(id: number, representativeBundle: string, userId: number): Promise\<void\>
Publishes a notification through the reminder agent. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.Notification
**Parameters**
| Name | Type | Mandatory| Description |
| -------------------- | ------ | ---- | ------------------ |
| id | number | Yes | Notification ID. |
| representativeBundle | string | Yes | Bundle name of the application whose notification function is taken over by the reminder agent.|
| userId | number | Yes | ID of the user who receives the notification.|
**Example**
```js
// Bundle name of the application whose notification function is taken over by the reminder agent
let representativeBundle = "com.example.demo"
// ID of the user who receives the notification
let userId = 100
Notification.cancelAsBundle(0, representativeBundle, userId).then(() => {
console.info("==========================>cancelAsBundleCallback=======================>");
});
```
## Notification.enableNotificationSlot<sup>9+</sup>
enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean, callback: AsyncCallback<void>): void
Sets the enabled status for a notification slot of a specified type. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------------- | ---- | ---------------------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle information. |
| type | [SlotType](#slottype) | Yes | Notification slot type. |
| enable | boolean | Yes | Whether to enable notification. |
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
**Example**
```js
//enableNotificationSlot
function enableSlotCallback(err) {
console.log('===================>enableSlotCallback==================>');
};
Notification.enableNotificationSlot(
{ bundle: "ohos.samples.notification", },
notify.SlotType.SOCIAL_COMMUNICATION,
true,
enableSlotCallback);
```
## Notification.enableNotificationSlot<sup>9+</sup>
enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean): Promise<void>
Sets the enabled status for a notification slot of a specified type. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ----------------------------- | ---- | -------------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle information. |
| type | [SlotType](#slottype) | Yes | Notification slot type.|
| enable | boolean | Yes | Whether to enable notification. |
**Example**
```js
//enableNotificationSlot
Notification.enableNotificationSlot(
{ bundle: "ohos.samples.notification", },
notify.SlotType.SOCIAL_COMMUNICATION,
true).then(() => {
console.log('====================>enableNotificationSlot====================>');
});
```
## Notification.isNotificationSlotEnabled<sup>9+</sup>
isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncCallback<boolean>): void
Obtains the enabled status of a notification slot of a specified type. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------------- | ---- | ---------------------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle information. |
| type | [SlotType](#slottype) | Yes | Notification slot type. |
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
**Example**
```js
//isNotificationSlotEnabled
function getEnableSlotCallback(err, data) {
console.log('===================>getEnableSlotCallback==================');
};
Notification.isNotificationSlotEnabled(
{ bundle: "ohos.samples.notification", },
notify.SlotType.SOCIAL_COMMUNICATION,
getEnableSlotCallback);
```
## Notification.isNotificationSlotEnabled<sup>9+</sup>
isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise<boolean>
Obtains the enabled status of a notification slot of a specified type. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ----------------------------- | ---- | -------------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle information. |
| type | [SlotType](#slottype) | Yes | Notification slot type.|
**Example**
```js
//isNotificationSlotEnabled
Notification.isNotificationSlotEnabled(
{ bundle: "ohos.samples.notification", },
notify.SlotType.SOCIAL_COMMUNICATION,
true).then((data) => {
console.log('====================>isNotificationSlotEnabled====================>');
});
```
## NotificationSubscriber ## NotificationSubscriber
**System API**: This is a system API and cannot be called by third-party applications.
### onConsume ### onConsume
onConsume?:(data: [SubscribeCallbackData](#subscribecallbackdata)) onConsume?:(data: [SubscribeCallbackData](#subscribecallbackdata))
...@@ -2526,12 +2923,12 @@ function onConsumeCallback(data) { ...@@ -2526,12 +2923,12 @@ function onConsumeCallback(data) {
let wantAgent = data.wantAgent; let wantAgent = data.wantAgent;
wantAgent .getWant(wantAgent) wantAgent .getWant(wantAgent)
.then((data1) => { .then((data1) => {
console.log('===> getWant success want:' + JSON.stringfy(data1)); console.log('===> getWant success want:' + JSON.stringify(data1));
}) })
.catch((err) => { .catch((err) => {
console.error('===> getWant failed because' + JSON.stringfy(err)); console.error('===> getWant failed because' + JSON.stringify(err));
}); });
console.info('===> onConsume callback req.wantAgent:' + JSON.stringfy(req.wantAgent)); console.info('===> onConsume callback req.wantAgent:' + JSON.stringify(req.wantAgent));
}; };
var subscriber = { var subscriber = {
...@@ -2766,14 +3163,10 @@ function subscribeCallback(err) { ...@@ -2766,14 +3163,10 @@ function subscribeCallback(err) {
} }
}; };
function onEnabledNotificationChangedCallback(err, callbackData) { function onEnabledNotificationChangedCallback(callbackData) {
if (err.code) {
console.info("subscribe failed " + JSON.stringify(err));
} else {
console.info("bundle: ", callbackData.bundle); console.info("bundle: ", callbackData.bundle);
console.info("uid: ", callbackData.uid); console.info("uid: ", callbackData.uid);
console.info("enable: ", callbackData.enable); console.info("enable: ", callbackData.enable);
}
}; };
var subscriber = { var subscriber = {
...@@ -2787,6 +3180,8 @@ Notification.subscribe(subscriber, subscribeCallback); ...@@ -2787,6 +3180,8 @@ Notification.subscribe(subscriber, subscribeCallback);
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
| --------------- | ---- | --- | ------------------------------------------------- | ---- | -------- | | --------------- | ---- | --- | ------------------------------------------------- | ---- | -------- |
| request | Yes | No | [NotificationRequest](#notificationrequest) | Yes | Notification content.| | request | Yes | No | [NotificationRequest](#notificationrequest) | Yes | Notification content.|
...@@ -2800,6 +3195,8 @@ Notification.subscribe(subscriber, subscribeCallback); ...@@ -2800,6 +3195,8 @@ Notification.subscribe(subscriber, subscribeCallback);
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
| ------ | ---- | --- | ------- | ---- | ---------------- | | ------ | ---- | --- | ------- | ---- | ---------------- |
| bundle | Yes | No | string | Yes | Bundle name of the application. | | bundle | Yes | No | string | Yes | Bundle name of the application. |
...@@ -2811,6 +3208,8 @@ Notification.subscribe(subscriber, subscribeCallback); ...@@ -2811,6 +3208,8 @@ Notification.subscribe(subscriber, subscribeCallback);
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Readable| Writable| Type | Description | | Name | Readable| Writable| Type | Description |
| ----- | ---- | --- | ------------------------------------- | ------------------------ | | ----- | ---- | --- | ------------------------------------- | ------------------------ |
| type | Yes | No | [DoNotDisturbType](#donotdisturbtype8) | DND time type.| | type | Yes | No | [DoNotDisturbType](#donotdisturbtype8) | DND time type.|
...@@ -2823,13 +3222,14 @@ Notification.subscribe(subscriber, subscribeCallback); ...@@ -2823,13 +3222,14 @@ Notification.subscribe(subscriber, subscribeCallback);
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Value | Description | | Name | Value | Description |
| ------------ | ---------------- | ------------------------------------------ | | ------------ | ---------------- | ------------------------------------------ |
| TYPE_NONE | DoNotDisturbType | Non-DND. | | TYPE_NONE | 0 | Non-DND. |
| TYPE_ONCE | DoNotDisturbType | One-shot DND at the specified time segment (only considering the hour and minute).| | TYPE_ONCE | 1 | One-shot DND at the specified time segment (only considering the hour and minute).|
| TYPE_DAILY | DoNotDisturbType | Daily DND at the specified time segment (only considering the hour and minute).| | TYPE_DAILY | 2 | Daily DND at the specified time segment (only considering the hour and minute).|
| TYPE_CLEARLY | DoNotDisturbType | DND at the specified time segment (considering the year, month, day, hour, and minute). | | TYPE_CLEARLY | 3 | DND at the specified time segment (considering the year, month, day, hour, and minute). |
## ContentType ## ContentType
...@@ -2838,11 +3238,11 @@ Notification.subscribe(subscriber, subscribeCallback); ...@@ -2838,11 +3238,11 @@ Notification.subscribe(subscriber, subscribeCallback);
| Name | Value | Description | | Name | Value | Description |
| --------------------------------- | ----------- | ------------------ | | --------------------------------- | ----------- | ------------------ |
| NOTIFICATION_CONTENT_BASIC_TEXT | ContentType | Normal text notification. | | NOTIFICATION_CONTENT_BASIC_TEXT | NOTIFICATION_CONTENT_BASIC_TEXT | Normal text notification. |
| NOTIFICATION_CONTENT_LONG_TEXT | ContentType | Long text notification. | | NOTIFICATION_CONTENT_LONG_TEXT | NOTIFICATION_CONTENT_LONG_TEXT | Long text notification. |
| NOTIFICATION_CONTENT_PICTURE | ContentType | Picture-attached notification. | | NOTIFICATION_CONTENT_PICTURE | NOTIFICATION_CONTENT_PICTURE | Picture-attached notification. |
| NOTIFICATION_CONTENT_CONVERSATION | ContentType | Conversation notification. | | NOTIFICATION_CONTENT_CONVERSATION | NOTIFICATION_CONTENT_CONVERSATION | Conversation notification. |
| NOTIFICATION_CONTENT_MULTILINE | ContentType | Multi-line text notification.| | NOTIFICATION_CONTENT_MULTILINE | NOTIFICATION_CONTENT_MULTILINE | Multi-line text notification.|
## SlotLevel ## SlotLevel
...@@ -2850,9 +3250,9 @@ Notification.subscribe(subscriber, subscribeCallback); ...@@ -2850,9 +3250,9 @@ Notification.subscribe(subscriber, subscribeCallback);
| Name | Value | Description | | Name | Value | Description |
| --------------------------------- | ----------- | ------------------ | | --------------------------------- | ----------- | ------------------ |
| LEVEL_NONE | 0 | The notification feature is disabled. | | LEVEL_NONE | 0 | The notification function is disabled. |
| LEVEL_MIN | 1 | The notification feature is enabled, but the notification icon is not displayed in the status bar, with no banner or alert tone.| | LEVEL_MIN | 1 | The notification function is enabled, but the notification icon is not displayed in the status bar, with no banner or alert tone.|
| LEVEL_LOW | 2 | The notification feature is enabled, and the notification icon is displayed in the status bar, with no banner or alert tone.| | LEVEL_LOW | 2 | The notification function is enabled, and the notification icon is displayed in the status bar, with no banner or alert tone.|
| LEVEL_DEFAULT | 3 | The notification feature is enabled, and the notification icon is displayed in the status bar, with an alert tone but no banner.| | LEVEL_DEFAULT | 3 | The notification feature is enabled, and the notification icon is displayed in the status bar, with an alert tone but no banner.|
| LEVEL_HIGH | 4 | The notification feature is enabled, and the notification icon is displayed in the status bar, with an alert tone and banner.| | LEVEL_HIGH | 4 | The notification feature is enabled, and the notification icon is displayed in the status bar, with an alert tone and banner.|
...@@ -2884,11 +3284,11 @@ Notification.subscribe(subscriber, subscribeCallback); ...@@ -2884,11 +3284,11 @@ Notification.subscribe(subscriber, subscribeCallback);
| Name | Value | Description | | Name | Value | Description |
| -------------------- | -------- | ---------- | | -------------------- | -------- | ---------- |
| UNKNOWN_TYPE | SlotType | Unknown type.| | UNKNOWN_TYPE | 0 | Unknown type.|
| SOCIAL_COMMUNICATION | SlotType | Notification slot for social communication.| | SOCIAL_COMMUNICATION | 1 | Notification slot for social communication.|
| SERVICE_INFORMATION | SlotType | Notification slot for service information.| | SERVICE_INFORMATION | 2 | Notification slot for service information.|
| CONTENT_INFORMATION | SlotType | Notification slot for content consultation.| | CONTENT_INFORMATION | 3 | Notification slot for content consultation.|
| OTHER_TYPES | SlotType | Notification slot for other purposes.| | OTHER_TYPES | 0xFFFF | Notification slot for other purposes.|
## NotificationActionButton ## NotificationActionButton
...@@ -2973,6 +3373,8 @@ Notification.subscribe(subscriber, subscribeCallback); ...@@ -2973,6 +3373,8 @@ Notification.subscribe(subscriber, subscribeCallback);
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Value | Description | | Name | Value | Description |
| -------------- | --- | --------------------------------- | | -------------- | --- | --------------------------------- |
| TYPE_NONE | 0 | The default flag is used. | | TYPE_NONE | 0 | The default flag is used. |
...@@ -3021,7 +3423,7 @@ Notification.subscribe(subscriber, subscribeCallback); ...@@ -3021,7 +3423,7 @@ Notification.subscribe(subscriber, subscribeCallback);
| creatorBundleName | Yes | No | string | No | Name of the bundle that creates the notification. | | creatorBundleName | Yes | No | string | No | Name of the bundle that creates the notification. |
| creatorUid | Yes | No | number | No | UID used for creating the notification. | | creatorUid | Yes | No | number | No | UID used for creating the notification. |
| creatorPid | Yes | No | number | No | PID used for creating the notification. | | creatorPid | Yes | No | number | No | PID used for creating the notification. |
| creatorUserId<sup>8+</sup>| Yes | No | number | No | ID of the user who creates a notification. | | creatorUserId<sup>8+</sup>| Yes | No | number | No | ID of the user who creates the notification. |
| hashCode | Yes | No | string | No | Unique ID of the notification. | | hashCode | Yes | No | string | No | Unique ID of the notification. |
| classification | Yes | Yes | string | No | Notification category. | | classification | Yes | Yes | string | No | Notification category. |
| groupName<sup>8+</sup>| Yes | Yes | string | No | Group notification name. | | groupName<sup>8+</sup>| Yes | Yes | string | No | Group notification name. |
...@@ -3062,12 +3464,15 @@ Notification.subscribe(subscriber, subscribeCallback); ...@@ -3062,12 +3464,15 @@ Notification.subscribe(subscriber, subscribeCallback);
| lightEnabled | Yes | Yes | boolean | No | Whether the indicator blinks for the notification. | | lightEnabled | Yes | Yes | boolean | No | Whether the indicator blinks for the notification. |
| lightColor | Yes | Yes | number | No | Indicator color of the notification. | | lightColor | Yes | Yes | number | No | Indicator color of the notification. |
| vibrationValues | Yes | Yes | Array\<number\> | No | Vibration mode of the notification. | | vibrationValues | Yes | Yes | Array\<number\> | No | Vibration mode of the notification. |
| enabled<sup>9+</sup> | Yes | No | boolean | No | Enabled status of the notification slot. |
## NotificationSorting ## NotificationSorting
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
| -------- | ---- | --- | ------------------------------------- | ---- | ------------ | | -------- | ---- | --- | ------------------------------------- | ---- | ------------ |
| slot | Yes | No | [NotificationSlot](#notificationslot) | Yes | Notification slot content.| | slot | Yes | No | [NotificationSlot](#notificationslot) | Yes | Notification slot content.|
...@@ -3079,6 +3484,8 @@ Notification.subscribe(subscriber, subscribeCallback); ...@@ -3079,6 +3484,8 @@ Notification.subscribe(subscriber, subscribeCallback);
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
| -------------- | ---- | --- | ------------------------------------------------------------ | ---- | ---------------- | | -------------- | ---- | --- | ------------------------------------------------------------ | ---- | ---------------- |
| sortings | Yes | No | {[key: string]: [NotificationSorting](#notificationsorting)} | Yes | Array of notification sorting information.| | sortings | Yes | No | {[key: string]: [NotificationSorting](#notificationsorting)} | Yes | Array of notification sorting information.|
...@@ -3089,6 +3496,8 @@ Notification.subscribe(subscriber, subscribeCallback); ...@@ -3089,6 +3496,8 @@ Notification.subscribe(subscriber, subscribeCallback);
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
| ----------- | --- | ---- | --------------- | ---- | ------------------------------- | | ----------- | --- | ---- | --------------- | ---- | ------------------------------- |
| bundleNames | Yes | Yes | Array\<string\> | No | Bundle names of the applications whose notifications are to be subscribed to.| | bundleNames | Yes | Yes | Array\<string\> | No | Bundle names of the applications whose notifications are to be subscribed to.|
...@@ -3118,6 +3527,8 @@ Notification.subscribe(subscriber, subscribeCallback); ...@@ -3118,6 +3527,8 @@ Notification.subscribe(subscriber, subscribeCallback);
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Value | Description | | Name | Value | Description |
| -------------------- | --- | --------------------------------- | | -------------------- | --- | --------------------------------- |
| IDLE_DONOT_REMIND | 0 | The device is not in use. No notification is required. | | IDLE_DONOT_REMIND | 0 | The device is not in use. No notification is required. |
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册