提交 a6fc9360 编写于 作者: E ester.zhou

update docs (14558)

Signed-off-by: Nester.zhou <ester.zhou@huawei.com>
上级 be46489b
# @ohos.notificationSubscribe
# @ohos.notificationSubscribe (NotificationSubscribe)
The **NotificationSubscribe** module provides APIs for notification subscription, notification unsubscription, subscription removal, and more. In general cases, only system applications can call these APIs.
......@@ -36,6 +36,8 @@ Subscribes to a notification with the subscription information specified. This A
**Error codes**
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).
| ID| Error Message |
| -------- | ----------------------------------- |
| 1600001 | Internal error. |
......@@ -56,12 +58,12 @@ function subscribeCallback(err) {
function onConsumeCallback(data) {
console.info("Consume callback: " + JSON.stringify(data));
}
var subscriber = {
let subscriber = {
onConsume: onConsumeCallback
}
var info = {
};
let info = {
bundleNames: ["bundleName1","bundleName2"]
}
};
NotificationSubscribe.subscribe(subscriber, info, subscribeCallback);
```
......@@ -88,6 +90,8 @@ Subscribes to notifications of all applications under this user. This API uses a
**Error codes**
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).
| ID| Error Message |
| -------- | ----------------------------------- |
| 1600001 | Internal error. |
......@@ -107,9 +111,9 @@ function subscribeCallback(err) {
function onConsumeCallback(data) {
console.info("Consume callback: " + JSON.stringify(data));
}
var subscriber = {
let subscriber = {
onConsume: onConsumeCallback
}
};
NotificationSubscribe.subscribe(subscriber, subscribeCallback);
```
......@@ -136,6 +140,8 @@ Subscribes to a notification with the subscription information specified. This A
**Error codes**
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).
| ID| Error Message |
| -------- | ----------------------------------- |
| 1600001 | Internal error. |
......@@ -148,7 +154,7 @@ Subscribes to a notification with the subscription information specified. This A
function onConsumeCallback(data) {
console.info("Consume callback: " + JSON.stringify(data));
}
var subscriber = {
let subscriber = {
onConsume: onConsumeCallback
};
NotificationSubscribe.subscribe(subscriber).then(() => {
......@@ -179,6 +185,8 @@ Unsubscribes from a notification. This API uses an asynchronous callback to retu
**Error codes**
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).
| ID| Error Message |
| -------- | ----------------------------------- |
| 1600001 | Internal error. |
......@@ -198,9 +206,9 @@ function unsubscribeCallback(err) {
function onDisconnectCallback(data) {
console.info("Cancel callback: " + JSON.stringify(data));
}
var subscriber = {
let subscriber = {
onDisconnect: onDisconnectCallback
}
};
NotificationSubscribe.unsubscribe(subscriber, unsubscribeCallback);
```
......@@ -226,6 +234,8 @@ Unsubscribes from a notification. This API uses a promise to return the result.
**Error codes**
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).
| ID| Error Message |
| -------- | ----------------------------------- |
| 1600001 | Internal error. |
......@@ -238,7 +248,7 @@ Unsubscribes from a notification. This API uses a promise to return the result.
function onDisconnectCallback(data) {
console.info("Cancel callback: " + JSON.stringify(data));
}
var subscriber = {
let subscriber = {
onDisconnect: onDisconnectCallback
};
NotificationSubscribe.unsubscribe(subscriber).then(() => {
......@@ -271,6 +281,8 @@ Removes a notification for a specified application. This API uses an asynchronou
**Error codes**
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).
| ID| Error Message |
| -------- | ---------------------------------------- |
| 1600001 | Internal error. |
......@@ -289,14 +301,14 @@ function removeCallback(err) {
console.info("remove success");
}
}
var bundle = {
let bundle = {
bundle: "bundleName1",
}
var notificationKey = {
};
let notificationKey = {
id: 0,
label: "label",
}
var reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE;
};
let reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE;
NotificationSubscribe.remove(bundle, notificationKey, reason, removeCallback);
```
......@@ -324,6 +336,8 @@ Removes a notification for a specified application. This API uses a promise to r
**Error codes**
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).
| ID| Error Message |
| -------- | ---------------------------------------- |
| 1600001 | Internal error. |
......@@ -335,14 +349,14 @@ Removes a notification for a specified application. This API uses a promise to r
**Example**
```js
var bundle = {
let bundle = {
bundle: "bundleName1",
}
var notificationKey = {
};
let notificationKey = {
id: 0,
label: "label",
}
var reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE;
};
let reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE;
NotificationSubscribe.remove(bundle, notificationKey, reason).then(() => {
console.info("remove success");
});
......@@ -372,6 +386,8 @@ Removes a specified notification. This API uses an asynchronous callback to retu
**Error codes**
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).
| ID| Error Message |
| -------- | ----------------------------------- |
| 1600001 | Internal error. |
......@@ -382,7 +398,7 @@ Removes a specified notification. This API uses an asynchronous callback to retu
**Example**
```js
var hashCode = 'hashCode'
let hashCode = 'hashCode';
function removeCallback(err) {
if (err) {
......@@ -391,7 +407,7 @@ function removeCallback(err) {
console.info("remove success");
}
}
var reason = NotificationSubscribe.RemoveReason.CANCEL_REASON_REMOVE;
let reason = NotificationSubscribe.RemoveReason.CANCEL_REASON_REMOVE;
NotificationSubscribe.remove(hashCode, reason, removeCallback);
```
......@@ -418,6 +434,8 @@ Removes a specified notification. This API uses a promise to return the result.
**Error codes**
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).
| ID| Error Message |
| -------- | ----------------------------------- |
| 1600001 | Internal error. |
......@@ -428,8 +446,8 @@ Removes a specified notification. This API uses a promise to return the result.
**Example**
```js
var hashCode = 'hashCode'
var reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE;
let hashCode = 'hashCode';
let reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE;
NotificationSubscribe.remove(hashCode, reason).then(() => {
console.info("remove success");
});
......@@ -458,6 +476,8 @@ Removes all notifications for a specified application. This API uses an asynchro
**Error codes**
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).
| ID| Error Message |
| -------- | ---------------------------------------- |
| 1600001 | Internal error. |
......@@ -475,9 +495,9 @@ function removeAllCallback(err) {
console.info("removeAll success");
}
}
var bundle = {
let bundle = {
bundle: "bundleName1",
}
};
NotificationSubscribe.removeAll(bundle, removeAllCallback);
```
......@@ -503,6 +523,8 @@ Removes all notifications. This API uses an asynchronous callback to return the
**Error codes**
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).
| ID| Error Message |
| -------- | ----------------------------------- |
| 1600001 | Internal error. |
......@@ -545,6 +567,8 @@ Removes all notifications for a specified application. This API uses a promise t
**Error codes**
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).
| ID| Error Message |
| -------- | ---------------------------------------- |
| 1600001 | Internal error. |
......@@ -582,6 +606,8 @@ Removes all notifications for a specified user. This API uses an asynchronous ca
**Error codes**
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).
| ID| Error Message |
| -------- | ----------------------------------- |
| 1600001 | Internal error. |
......@@ -600,7 +626,7 @@ function removeAllCallback(err) {
}
}
var userId = 1
let userId = 1;
NotificationSubscribe.removeAll(userId, removeAllCallback);
```
......@@ -625,6 +651,8 @@ Removes all notifications for a specified user. This API uses a promise to retur
**Error codes**
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).
| ID| Error Message |
| -------- | ----------------------------------- |
| 1600001 | Internal error. |
......@@ -643,7 +671,7 @@ function removeAllCallback(err) {
}
}
var userId = 1
let userId = 1;
NotificationSubscribe.removeAll(userId, removeAllCallback);
```
......@@ -689,7 +717,7 @@ function onConsumeCallback(data) {
console.info('===> onConsume callback req.id:' + req.id);
};
var subscriber = {
let subscriber = {
onConsume: onConsumeCallback
};
......@@ -729,7 +757,7 @@ function onCancelCallback(data) {
console.info('===> onCancel callback req.id:' + req.id);
}
var subscriber = {
let subscriber = {
onCancel: onCancelCallback
};
......@@ -767,7 +795,7 @@ function onUpdateCallback(map) {
console.info('===> onUpdateCallback map:' + JSON.stringify(map));
}
var subscriber = {
let subscriber = {
onUpdate: onUpdateCallback
};
......@@ -799,7 +827,7 @@ function onConnectCallback() {
console.info('===> onConnect in test');
}
var subscriber = {
let subscriber = {
onConnect: onConnectCallback
};
......@@ -841,7 +869,7 @@ function onDisconnectCallback() {
console.info('===> onDisconnect in test');
}
var subscriber = {
let subscriber = {
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback
};
......@@ -877,7 +905,7 @@ function onDestroyCallback() {
console.info('===> onDestroy in test');
}
var subscriber = {
let subscriber = {
onDestroy: onDestroyCallback
};
......@@ -915,7 +943,7 @@ function onDoNotDisturbDateChangeCallback(mode) {
console.info('===> onDoNotDisturbDateChange:' + mode);
}
var subscriber = {
let subscriber = {
onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback
};
......@@ -956,7 +984,7 @@ function onEnabledNotificationChangedCallback(callbackData) {
console.info("enable: ", callbackData.enable);
};
var subscriber = {
let subscriber = {
onEnabledNotificationChanged: onEnabledNotificationChangedCallback
};
......@@ -1011,7 +1039,7 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback);
## NotificationSorting
Provides sorting information of activity notifications.
Provides sorting information of active notifications.
**System capability**: SystemCapability.Notification.Notification
......
# Notification Error Codes
## 1600001 Internal Error
**Error Message**
Internal error.
**Description**
This error code is reported when an error occurs during internal processing, such as multi-thread processing or internal pointer checks.
**Cause**
Common kernel errors such as multi-thread processing and internal processing errors occur.
**Solution**
Make sure the system resources are sufficient.
## 1600002 Marshalling or Unmarshalling Error
**Error Message**
marshalling or unmarshalling error.
**Description**
This error code is reported when a marshalling or unmarshalling error occurs before data transmission.
**Cause**
A parameter mismatch is detected between the application and the notification service.
**Solution**
Make sure the application SDK version matches the system version.
## 1600003 Failed to Connect to the Notification Service
**Error Message**
Failed to connect service.
**Description**
This error code is reported when the application fails to connect to the notification service.
**Cause**
The notification service is busy or abnormal.
**Solution**
Restart the system.
## 1600004 Notification Disabled
**Error Message**
Notification is not enabled.
**Description**
This error code is reported when notification is disabled.
**Cause**
The notification feature is not enabled for the application.
**Solution**
Enable notification for the application in the notification settings.
## 1600005 Notification Slot Disabled
**Error Message**
Notification slot is not enabled.
**Description**
This error code is reported when the notification slot is not available.
**Cause**
The notification slot is disabled or has not been added.
**Solution**
1. Access the notification settings and check whether the application has the notification slot. If no, add it.
2. Make sure the notification slot is enabled.
## 1600006 Notification Deletion Failed
**Error Message**
Notification is not allowed to remove.
**Description**
This error code is reported when notification deletion is disabled.
**Cause**
The notification attribute **isUnremovable** is set to true.
**Solution**
Set **isUnremovable** as needed. For details, see [NotificationRequest](../apis/js-apis-notificationManager.md#notificationrequest).
## 1600007 Notification Not Found
**Error Message**
The notification is not exist.
**Description**
This error code is reported when the notification service could not find the notification.
**Cause**
The notification has been canceled or deleted.
**Solution**
N/A
## 1600008 User Not Found
**Error Message**
The user is not exist.
**Description**
This error code is reported when the specified user is not found in the information system.
**Cause**
The user information passed is incorrect.
**Solution**
Verify the user information.
## 1600009 Notification Sending Limit Reached
**Error Message**
Over max number notifications per second.
**Description**
This error code is reported when the notification sending frequency reaches the upper limit.
**Cause**
More than 10 notifications are sent per second.
**Solution**
Reduce the notification sending frequency to no more than 10 per second.
## 16000010 Distributed Operation Failed
**Error Message**
Distributed operation failed.
**Description**
This error code is reported when an error occurs with the distributed database operation or distributed API invoking.
**Cause**
The distributed database could not be operated or the distributed API could not be invoked.
**Solution**
Verify the distributed connection.
## 16000011 Failed to Read the Template Configuration
**Error Message**
Read template config failed.
**Description**
This error code is reported when the attempt to read the template configuration file fails.
**Cause**
The template configuration file is lost in the system.
**Solution**
Check for the template configuration file: /system/etc/notification_template/external.json.
## 16000012 Insufficient Memory Space
**Error Message**
No memory space.
**Description**
This error code is reported when a memory allocation error occurs.
**Cause**
A memory allocation error occurs.
**Solution**
Ensure sufficient system memory.
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册