未验证 提交 bf87c6e6 编写于 作者: O openharmony_ci 提交者: Gitee

!1646 修复通知示例代码

Merge pull request !1646 from zengsiyu/dev
...@@ -41,7 +41,7 @@ function publishCallback(err) { ...@@ -41,7 +41,7 @@ function publishCallback(err) {
var notificationRequest = { var notificationRequest = {
id: 1, id: 1,
content: { content: {
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: { normal: {
title: "test_title", title: "test_title",
text: "test_text", text: "test_text",
...@@ -71,7 +71,7 @@ Notification.publish(notificationRequest, publishCallback) ...@@ -71,7 +71,7 @@ Notification.publish(notificationRequest, publishCallback)
var notificationRequest = { var notificationRequest = {
notificationId: 1, notificationId: 1,
content: { content: {
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: { normal: {
title: "test_title", title: "test_title",
text: "test_text", text: "test_text",
...@@ -79,7 +79,7 @@ var notificationRequest = { ...@@ -79,7 +79,7 @@ var notificationRequest = {
} }
} }
} }
Notification.publish(notificationRequest).then((void) => { Notification.publish(notificationRequest).then(() => {
console.info("==========================>publishCallback=======================>"); console.info("==========================>publishCallback=======================>");
}); });
...@@ -137,7 +137,7 @@ Notification.cancel(0, "label", cancelCallback) ...@@ -137,7 +137,7 @@ Notification.cancel(0, "label", cancelCallback)
- 示例 - 示例
```js ```js
Notification.cancel(0).then((void) => { Notification.cancel(0).then(() => {
console.info("==========================>cancelCallback=======================>"); console.info("==========================>cancelCallback=======================>");
}); });
``` ```
...@@ -193,10 +193,10 @@ Notification.cancel(0, cancelCallback) ...@@ -193,10 +193,10 @@ Notification.cancel(0, cancelCallback)
```js ```js
//cancel回调 //cancel回调
function cancelAllback(err) { function cancelAllCallback(err) {
console.info("==========================>cancelAllback=======================>"); console.info("==========================>cancelAllCallback=======================>");
} }
Notification.cancelAll(cancelCallback) Notification.cancelAll(cancelAllCallback)
``` ```
...@@ -218,8 +218,8 @@ Notification.cancelAll(cancelCallback) ...@@ -218,8 +218,8 @@ Notification.cancelAll(cancelCallback)
- 示例 - 示例
```js ```js
Notification.cancelAll().then((void) => { Notification.cancelAll().then(() => {
console.info("==========================>cancelAllback=======================>"); console.info("==========================>cancelAllCallback=======================>");
}); });
``` ```
...@@ -281,7 +281,7 @@ Notification.addSlot(notificationSlot, addSlotCallBack) ...@@ -281,7 +281,7 @@ Notification.addSlot(notificationSlot, addSlotCallBack)
var notificationSlot = { var notificationSlot = {
type: Notification.SlotType.SOCIAL_COMMUNICATION type: Notification.SlotType.SOCIAL_COMMUNICATION
} }
Notification.addSlot(notificationSlot).then((void) => { Notification.addSlot(notificationSlot).then(() => {
console.info("==========================>addSlotCallback=======================>"); console.info("==========================>addSlotCallback=======================>");
}); });
``` ```
...@@ -336,7 +336,7 @@ Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION, addSlotCallBack ...@@ -336,7 +336,7 @@ Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION, addSlotCallBack
- 示例 - 示例
```js ```js
Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION).then((void) => { Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION).then(() => {
console.info("==========================>addSlotCallback=======================>"); console.info("==========================>addSlotCallback=======================>");
}); });
``` ```
...@@ -407,7 +407,7 @@ var notificationSlot = { ...@@ -407,7 +407,7 @@ var notificationSlot = {
var notificationSlotArray = new Array(); var notificationSlotArray = new Array();
notificationSlotArray[0] = notificationSlot; notificationSlotArray[0] = notificationSlot;
Notification.addSlots(notificationSlotArray).then((void) => { Notification.addSlots(notificationSlotArray).then(() => {
console.info("==========================>addSlotCallback=======================>"); console.info("==========================>addSlotCallback=======================>");
}); });
``` ```
...@@ -573,7 +573,7 @@ Notification.removeSlot(slotType,removeSlotCallback) ...@@ -573,7 +573,7 @@ Notification.removeSlot(slotType,removeSlotCallback)
```js ```js
var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; var slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
Notification.removeSlot(slotType).then((void) => { Notification.removeSlot(slotType).then(() => {
console.info("==========================>removeSlotCallback=======================>"); console.info("==========================>removeSlotCallback=======================>");
}); });
``` ```
...@@ -624,7 +624,7 @@ Notification.removeAllSlots(removeAllCallBack) ...@@ -624,7 +624,7 @@ Notification.removeAllSlots(removeAllCallBack)
- 示例 - 示例
```js ```js
Notification.removeAllSlots().then((void) => { Notification.removeAllSlots().then(() => {
console.info("==========================>removeAllCallBack=======================>"); console.info("==========================>removeAllCallBack=======================>");
}); });
``` ```
...@@ -730,7 +730,7 @@ function onConsumeCallback(err, data) { ...@@ -730,7 +730,7 @@ function onConsumeCallback(err, data) {
var subscriber = { var subscriber = {
onConsume: onConsumeCallback onConsume: onConsumeCallback
}; };
Notification.subscribe(subscriber).then((void) => { Notification.subscribe(subscriber).then(() => {
console.info("==========================>subscribeCallback=======================>"); console.info("==========================>subscribeCallback=======================>");
}); });
``` ```
...@@ -796,7 +796,7 @@ function onConsumeCallback(err, data) { ...@@ -796,7 +796,7 @@ function onConsumeCallback(err, data) {
var subscriber = { var subscriber = {
onConsume: onConsumeCallback onConsume: onConsumeCallback
}; };
Notification.unsubscribe(subscriber).then((void) => { Notification.unsubscribe(subscriber).then(() => {
console.info("==========================>unsubscribeCallback=======================>"); console.info("==========================>unsubscribeCallback=======================>");
}); });
``` ```
...@@ -828,7 +828,7 @@ function enableNotificationCallback(err) { ...@@ -828,7 +828,7 @@ function enableNotificationCallback(err) {
console.info("==========================>enableNotificationCallback=======================>"); console.info("==========================>enableNotificationCallback=======================>");
} }
var bundle = { var bundle = {
bundle: "bundleName1"; bundle: "bundleName1",
} }
Notification.enableNotification(bundle, false, enableNotificationCallback); Notification.enableNotification(bundle, false, enableNotificationCallback);
``` ```
...@@ -856,9 +856,9 @@ Notification.enableNotification(bundle, false, enableNotificationCallback); ...@@ -856,9 +856,9 @@ Notification.enableNotification(bundle, false, enableNotificationCallback);
```js ```js
var bundle = { var bundle = {
bundle: "bundleName1"; bundle: "bundleName1",
} }
Notification.enableNotification(bundle, false).then((void) => { Notification.enableNotification(bundle, false).then(() => {
console.info("==========================>enableNotificationCallback=======================>"); console.info("==========================>enableNotificationCallback=======================>");
}); });
``` ```
...@@ -889,7 +889,7 @@ function isNotificationEnabledCallback(err, data) { ...@@ -889,7 +889,7 @@ function isNotificationEnabledCallback(err, data) {
console.info("==========================>isNotificationEnabledCallback=======================>"); console.info("==========================>isNotificationEnabledCallback=======================>");
} }
var bundle = { var bundle = {
bundle: "bundleName1"; bundle: "bundleName1",
} }
Notification.isNotificationEnabled(bundle, isNotificationEnabledCallback); Notification.isNotificationEnabled(bundle, isNotificationEnabledCallback);
``` ```
...@@ -916,7 +916,7 @@ Notification.isNotificationEnabled(bundle, isNotificationEnabledCallback); ...@@ -916,7 +916,7 @@ Notification.isNotificationEnabled(bundle, isNotificationEnabledCallback);
```js ```js
var bundle = { var bundle = {
bundle: "bundleName1"; bundle: "bundleName1",
} }
Notification.isNotificationEnabled(bundle).then((data) => { Notification.isNotificationEnabled(bundle).then((data) => {
console.info("==========================>isNotificationEnabledCallback=======================>"); console.info("==========================>isNotificationEnabledCallback=======================>");
...@@ -1004,7 +1004,7 @@ function displayBadgeCallback(err) { ...@@ -1004,7 +1004,7 @@ function displayBadgeCallback(err) {
console.info("==========================>displayBadgeCallback=======================>"); console.info("==========================>displayBadgeCallback=======================>");
} }
var bundle = { var bundle = {
bundle: "bundleName1"; bundle: "bundleName1",
} }
Notification.displayBadge(bundle, false, displayBadgeCallback); Notification.displayBadge(bundle, false, displayBadgeCallback);
``` ```
...@@ -1032,9 +1032,9 @@ Notification.displayBadge(bundle, false, displayBadgeCallback); ...@@ -1032,9 +1032,9 @@ Notification.displayBadge(bundle, false, displayBadgeCallback);
```js ```js
var bundle = { var bundle = {
bundle: "bundleName1"; bundle: "bundleName1",
} }
Notification.displayBadge(bundle, false).then((void) => { Notification.displayBadge(bundle, false).then(() => {
console.info("==========================>displayBadgeCallback=======================>"); console.info("==========================>displayBadgeCallback=======================>");
}); });
``` ```
...@@ -1065,7 +1065,7 @@ function isBadgeDisplayedCallback(err, data) { ...@@ -1065,7 +1065,7 @@ function isBadgeDisplayedCallback(err, data) {
console.info("==========================>isBadgeDisplayedCallback=======================>"); console.info("==========================>isBadgeDisplayedCallback=======================>");
} }
var bundle = { var bundle = {
bundle: "bundleName1"; bundle: "bundleName1",
} }
Notification.isBadgeDisplayed(bundle, isBadgeDisplayedCallback); Notification.isBadgeDisplayed(bundle, isBadgeDisplayedCallback);
``` ```
...@@ -1092,7 +1092,7 @@ Notification.isBadgeDisplayed(bundle, isBadgeDisplayedCallback); ...@@ -1092,7 +1092,7 @@ Notification.isBadgeDisplayed(bundle, isBadgeDisplayedCallback);
```js ```js
var bundle = { var bundle = {
bundle: "bundleName1"; bundle: "bundleName1",
} }
Notification.isBadgeDisplayed(bundle).then((data) => { Notification.isBadgeDisplayed(bundle).then((data) => {
console.info("==========================>isBadgeDisplayedCallback=======================>"); console.info("==========================>isBadgeDisplayedCallback=======================>");
...@@ -1126,7 +1126,7 @@ function setSlotByBundleCallback(err) { ...@@ -1126,7 +1126,7 @@ function setSlotByBundleCallback(err) {
console.info("==========================>setSlotByBundleCallback=======================>"); console.info("==========================>setSlotByBundleCallback=======================>");
} }
var bundle = { var bundle = {
bundle: "bundleName1"; bundle: "bundleName1",
} }
var notificationSlot = { var notificationSlot = {
type: Notification.SlotType.SOCIAL_COMMUNICATION type: Notification.SlotType.SOCIAL_COMMUNICATION
...@@ -1157,12 +1157,12 @@ Notification.setSlotByBundle(bundle, notificationSlot, setSlotByBundleCallback); ...@@ -1157,12 +1157,12 @@ Notification.setSlotByBundle(bundle, notificationSlot, setSlotByBundleCallback);
```js ```js
var bundle = { var bundle = {
bundle: "bundleName1"; bundle: "bundleName1",
} }
var notificationSlot = { var notificationSlot = {
type: Notification.SlotType.SOCIAL_COMMUNICATION type: Notification.SlotType.SOCIAL_COMMUNICATION
} }
Notification.displayBadge(bundle, notificationSlot).then((void) => { Notification.displayBadge(bundle, notificationSlot).then(() => {
console.info("==========================>setSlotByBundleCallback=======================>"); console.info("==========================>setSlotByBundleCallback=======================>");
}); });
``` ```
...@@ -1193,7 +1193,7 @@ function getSlotsByBundleCallback(err, data) { ...@@ -1193,7 +1193,7 @@ function getSlotsByBundleCallback(err, data) {
console.info("==========================>getSlotsByBundleCallback=======================>"); console.info("==========================>getSlotsByBundleCallback=======================>");
} }
var bundle = { var bundle = {
bundle: "bundleName1"; bundle: "bundleName1",
} }
Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback); Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback);
``` ```
...@@ -1220,7 +1220,7 @@ Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback); ...@@ -1220,7 +1220,7 @@ Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback);
```js ```js
var bundle = { var bundle = {
bundle: "bundleName1"; bundle: "bundleName1",
} }
Notification.getSlotsByBundle(bundle).then((data) => { Notification.getSlotsByBundle(bundle).then((data) => {
console.info("==========================>getSlotsByBundleCallback=======================>"); console.info("==========================>getSlotsByBundleCallback=======================>");
...@@ -1253,7 +1253,7 @@ function getSlotNumByBundle(err, data) { ...@@ -1253,7 +1253,7 @@ function getSlotNumByBundle(err, data) {
console.info("==========================>getSlotNumByBundleCallback=======================>"); console.info("==========================>getSlotNumByBundleCallback=======================>");
} }
var bundle = { var bundle = {
bundle: "bundleName1"; bundle: "bundleName1",
} }
Notification.getSlotNumByBundle(bundle, getSlotNumByBundleCallback); Notification.getSlotNumByBundle(bundle, getSlotNumByBundleCallback);
``` ```
...@@ -1280,7 +1280,7 @@ Notification.getSlotNumByBundle(bundle, getSlotNumByBundleCallback); ...@@ -1280,7 +1280,7 @@ Notification.getSlotNumByBundle(bundle, getSlotNumByBundleCallback);
```js ```js
var bundle = { var bundle = {
bundle: "bundleName1"; bundle: "bundleName1",
} }
Notification.getSlotNumByBundle(bundle).then((data) => { Notification.getSlotNumByBundle(bundle).then((data) => {
console.info("==========================>getSlotNumByBundleCallback=======================>"); console.info("==========================>getSlotNumByBundleCallback=======================>");
...@@ -1314,11 +1314,11 @@ function removeCallback(err) { ...@@ -1314,11 +1314,11 @@ function removeCallback(err) {
console.info("==========================>removeCallback=======================>"); console.info("==========================>removeCallback=======================>");
} }
var bundle = { var bundle = {
bundle: "bundleName1"; bundle: "bundleName1",
} }
var notificationKey = { var notificationKey = {
id: 0; id: 0,
label: "label"; label: "label",
} }
Notification.remove(bundle, notificationKey, removeCallback); Notification.remove(bundle, notificationKey, removeCallback);
``` ```
...@@ -1346,13 +1346,13 @@ Notification.remove(bundle, notificationKey, removeCallback); ...@@ -1346,13 +1346,13 @@ Notification.remove(bundle, notificationKey, removeCallback);
```js ```js
var bundle = { var bundle = {
bundle: "bundleName1"; bundle: "bundleName1",
} }
var notificationKey = { var notificationKey = {
id: 0; id: 0,
label: "label"; label: "label",
} }
Notification.remove(bundle, notificationKey).then((void) => { Notification.remove(bundle, notificationKey).then(() => {
console.info("==========================>removeCallback=======================>"); console.info("==========================>removeCallback=======================>");
}); });
``` ```
...@@ -1407,7 +1407,7 @@ Notification.remove(hashCode, removeCallback); ...@@ -1407,7 +1407,7 @@ Notification.remove(hashCode, removeCallback);
- 示例 - 示例
```js ```js
Notification.remove(hashCode).then((void) => { Notification.remove(hashCode).then(() => {
console.info("==========================>removeCallback=======================>"); console.info("==========================>removeCallback=======================>");
}); });
``` ```
...@@ -1438,7 +1438,7 @@ function removeAllCallback(err) { ...@@ -1438,7 +1438,7 @@ function removeAllCallback(err) {
console.info("==========================>removeAllCallback=======================>"); console.info("==========================>removeAllCallback=======================>");
} }
var bundle = { var bundle = {
bundle: "bundleName1"; bundle: "bundleName1",
} }
Notification.removeAll(bundle, removeAllCallback); Notification.removeAll(bundle, removeAllCallback);
``` ```
...@@ -1492,7 +1492,7 @@ Notification.removeAll(removeAllCallback); ...@@ -1492,7 +1492,7 @@ Notification.removeAll(removeAllCallback);
- 示例 - 示例
```js ```js
Notification.removeAll().then((void) => { Notification.removeAll().then(() => {
console.info("==========================>removeAllCallback=======================>"); console.info("==========================>removeAllCallback=======================>");
}); });
``` ```
...@@ -1800,7 +1800,7 @@ function setDoNotDisturbDateCallback(err) { ...@@ -1800,7 +1800,7 @@ function setDoNotDisturbDateCallback(err) {
} }
var doNotDisturbDate = { var doNotDisturbDate = {
type: notification.DoNotDisturbType.TYPE_ONCE, type: Notification.DoNotDisturbType.TYPE_ONCE,
begin: new Date(), begin: new Date(),
end: new Date(2021, 11, 15, 18, 0) end: new Date(2021, 11, 15, 18, 0)
} }
...@@ -1830,7 +1830,7 @@ Notification.setDoNotDisturbDate(doNotDisturbDate, setDoNotDisturbDateCallback); ...@@ -1830,7 +1830,7 @@ Notification.setDoNotDisturbDate(doNotDisturbDate, setDoNotDisturbDateCallback);
```js ```js
var doNotDisturbDate = { var doNotDisturbDate = {
type: notification.DoNotDisturbType.TYPE_ONCE, type: Notification.DoNotDisturbType.TYPE_ONCE,
begin: new Date(), begin: new Date(),
end: new Date(2021, 11, 15, 18, 0) end: new Date(2021, 11, 15, 18, 0)
} }
...@@ -2120,7 +2120,7 @@ Notification.isNotificationEnabledSelf() ...@@ -2120,7 +2120,7 @@ Notification.isNotificationEnabledSelf()
| onConnect?:() | 读、写 | function | 否 | 注册订阅回调函数 | | onConnect?:() | 读、写 | function | 否 | 注册订阅回调函数 |
| onDisconnect?:() | 读、写 | function | 否 | 取消订阅回调函数 | | onDisconnect?:() | 读、写 | function | 否 | 取消订阅回调函数 |
| onDestroy?:() | 读、写 | function | 否 | 服务失联回调函数 | | onDestroy?:() | 读、写 | function | 否 | 服务失联回调函数 |
| onDoNotDisturbDateChange?:(mode: notification.[DoNotDisturbDate](#donotdisturbdate)) | 读、写 | function | 否 | 免打扰时间选项变更回调函数 | | onDoNotDisturbDateChange?:(mode: Notification.[DoNotDisturbDate](#donotdisturbdate)) | 读、写 | function | 否 | 免打扰时间选项变更回调函数 |
### onEnabledNotificationChanged ### onEnabledNotificationChanged
...@@ -2895,7 +2895,7 @@ var wantAgentInfo = { ...@@ -2895,7 +2895,7 @@ var wantAgentInfo = {
], ],
operationType: OperationType.START_ABILITIES, operationType: OperationType.START_ABILITIES,
requestCode: 0, requestCode: 0,
wantAgentFlags:[WantAgentWantAgentFlags.UPDATE_PRESENT_FLAG] wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG]
} }
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback) WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册