Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
c6be59c2
D
Docs
项目概览
OpenHarmony
/
Docs
大约 1 年 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
c6be59c2
编写于
5月 26, 2022
作者:
X
xuzhihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix wrong example code of Notification docs
Signed-off-by:
N
xuzhihao
<
xuzhihao16@huawei.com
>
上级
b055f647
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
30 addition
and
30 deletion
+30
-30
zh-cn/application-dev/reference/apis/js-apis-commonEvent.md
zh-cn/application-dev/reference/apis/js-apis-commonEvent.md
+5
-5
zh-cn/application-dev/reference/apis/js-apis-notification.md
zh-cn/application-dev/reference/apis/js-apis-notification.md
+25
-25
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-commonEvent.md
浏览文件 @
c6be59c2
...
...
@@ -1185,12 +1185,12 @@ finishCommonEvent(callback: AsyncCallback\<void\>): void
var
subscriber
;
//创建成功的订阅者对象
//结束当前有序公共事件的回调
function
finishCommonEventCallback
()
{
function
finishCommonEventCallback
(
err
)
{
if
(
err
.
code
)
{
console
.
error
(
"
finishCommonEvent failed
"
+
JSON
.
stringify
(
err
));
}
else
{
}
else
{
console
.
info
(
"
FinishCommonEvent
"
);
}
}
}
subscriber
.
finishCommonEvent
(
finishCommonEventCallback
);
```
...
...
zh-cn/application-dev/reference/apis/js-apis-notification.md
浏览文件 @
c6be59c2
...
...
@@ -684,7 +684,7 @@ subscribe(subscriber: NotificationSubscriber, info: NotificationSubscribeInfo, c
function
subscribeCallback
(
err
)
{
console
.
info
(
"
==========================>subscribeCallback=======================>
"
);
}
function
onConsumeCallback
(
err
,
data
)
{
function
onConsumeCallback
(
data
)
{
console
.
info
(
"
==========================>onConsumeCallback=======================>
"
);
}
var
subscriber
=
{
...
...
@@ -719,7 +719,7 @@ subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>):
function
subscribeCallback
(
err
)
{
console
.
info
(
"
==========================>subscribeCallback=======================>
"
);
}
function
onConsumeCallback
(
err
,
data
)
{
function
onConsumeCallback
(
data
)
{
console
.
info
(
"
==========================>onConsumeCallback=======================>
"
);
}
var
subscriber
=
{
...
...
@@ -748,7 +748,7 @@ subscribe(subscriber: NotificationSubscriber, info?: NotificationSubscribeInfo):
**示例:**
```
js
function
onConsumeCallback
(
err
,
data
)
{
function
onConsumeCallback
(
data
)
{
console
.
info
(
"
==========================>onConsumeCallback=======================>
"
);
}
var
subscriber
=
{
...
...
@@ -782,7 +782,7 @@ unsubscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>)
function
unsubscribeCallback
(
err
)
{
console
.
info
(
"
==========================>unsubscribeCallback=======================>
"
);
}
function
onConsumeCallback
(
err
,
data
)
{
function
onConsumeCallback
(
data
)
{
console
.
info
(
"
==========================>onConsumeCallback=======================>
"
);
}
var
subscriber
=
{
...
...
@@ -810,7 +810,7 @@ unsubscribe(subscriber: NotificationSubscriber): Promise\<void\>
**示例:**
```
js
function
onConsumeCallback
(
err
,
data
)
{
function
onConsumeCallback
(
data
)
{
console
.
info
(
"
==========================>onConsumeCallback=======================>
"
);
}
var
subscriber
=
{
...
...
@@ -1176,7 +1176,7 @@ var bundle = {
var
notificationSlot
=
{
type
:
Notification
.
SlotType
.
SOCIAL_COMMUNICATION
}
Notification
.
displayBadg
e
(
bundle
,
notificationSlot
).
then
(()
=>
{
Notification
.
setSlotByBundl
e
(
bundle
,
notificationSlot
).
then
(()
=>
{
console
.
info
(
"
==========================>setSlotByBundleCallback=======================>
"
);
});
```
...
...
@@ -1263,7 +1263,7 @@ getSlotNumByBundle(bundle: BundleOption, callback: AsyncCallback\<number\>): voi
**示例:**
```
js
function
getSlotNumByBundle
(
err
,
data
)
{
function
getSlotNumByBundle
Callback
(
err
,
data
)
{
console
.
info
(
"
==========================>getSlotNumByBundleCallback=======================>
"
);
}
var
bundle
=
{
...
...
@@ -1391,6 +1391,8 @@ remove(hashCode: string, callback: AsyncCallback\<void\>): void
**示例:**
```
js
var
hashCode
=
'
hashCode
'
function
removeCallback
(
err
)
{
console
.
info
(
"
==========================>removeCallback=======================>
"
);
}
...
...
@@ -1417,6 +1419,8 @@ remove(hashCode: string): Promise\<void\>
**示例:**
```
js
var
hashCode
=
'
hashCode
'
Notification
.
remove
(
hashCode
).
then
(()
=>
{
console
.
info
(
"
==========================>removeCallback=======================>
"
);
});
...
...
@@ -2182,11 +2186,11 @@ requestEnableNotification(callback: AsyncCallback\<void\>): void
**示例:**
```
javascript
function
requestEnable
d
NotificationCallback
()
{
function
requestEnableNotificationCallback
()
{
console
.
log
(
'
------------- requestEnabledNotification --------------
'
);
};
Notification
.
requestEnable
dNotification
(
requestEnabled
NotificationCallback
);
Notification
.
requestEnable
Notification
(
requestEnable
NotificationCallback
);
```
...
...
@@ -2285,7 +2289,7 @@ function isDistributedEnabledCallback() {
console
.
log
(
'
----------- isDistributedEnabled ------------
'
);
};
Notification
.
enableDistribut
ed
(
isDistributedEnabledCallback
);
Notification
.
isDistributedEnabl
ed
(
isDistributedEnabledCallback
);
```
...
...
@@ -2404,7 +2408,7 @@ var bundle = {
bundle
:
"
bundleName1
"
,
}
Notification
.
enableDistribut
edByBundle
(
bundle
,
isDistributedEnabledByBundleCallback
);
Notification
.
isDistributedEnabl
edByBundle
(
bundle
,
isDistributedEnabledByBundleCallback
);
```
...
...
@@ -2534,7 +2538,7 @@ let notificationRequest = {
}
}
Notification
.
publishAsBundle
(
notificationRequest
,
representativeBundle
,
userId
,
publishCallback
);
Notification
.
publishAsBundle
(
notificationRequest
,
representativeBundle
,
userId
,
publish
AsBundle
Callback
);
```
## Notification.publishAsBundle<sup>9+</sup>
...
...
@@ -2609,7 +2613,7 @@ let representativeBundle = "com.example.demo"
// 接收通知的用户ID
let
userId
=
100
Notification
.
cancelAsBundle
(
0
,
representativeBundle
,
userId
,
publish
Callback
);
Notification
.
cancelAsBundle
(
0
,
representativeBundle
,
userId
,
cancelAsBundle
Callback
);
```
## Notification.cancelAsBundle<sup>9+</sup>
...
...
@@ -2676,12 +2680,12 @@ function onConsumeCallback(data) {
let
wantAgent
=
data
.
wantAgent
;
wantAgent
.
getWant
(
wantAgent
)
.
then
((
data1
)
=>
{
console
.
log
(
'
===> getWant success want:
'
+
JSON
.
stringfy
(
data1
));
console
.
log
(
'
===> getWant success want:
'
+
JSON
.
string
i
fy
(
data1
));
})
.
catch
((
err
)
=>
{
console
.
error
(
'
===> getWant failed because
'
+
JSON
.
stringfy
(
err
));
console
.
error
(
'
===> getWant failed because
'
+
JSON
.
string
i
fy
(
err
));
});
console
.
info
(
'
===> onConsume callback req.wantAgent:
'
+
JSON
.
stringfy
(
req
.
wantAgent
));
console
.
info
(
'
===> onConsume callback req.wantAgent:
'
+
JSON
.
string
i
fy
(
req
.
wantAgent
));
};
var
subscriber
=
{
...
...
@@ -2916,14 +2920,10 @@ function subscribeCallback(err) {
}
};
function
onEnabledNotificationChangedCallback
(
err
,
callbackData
)
{
if
(
err
.
code
)
{
console
.
info
(
"
subscribe failed
"
+
JSON
.
stringify
(
err
));
}
else
{
function
onEnabledNotificationChangedCallback
(
callbackData
)
{
console
.
info
(
"
bundle:
"
,
callbackData
.
bundle
);
console
.
info
(
"
uid:
"
,
callbackData
.
uid
);
console
.
info
(
"
enable:
"
,
callbackData
.
enable
);
}
};
var
subscriber
=
{
...
...
@@ -3212,7 +3212,7 @@ Notification.subscribe(subscriber, subscribeCallback);
| lightEnabled | 是 | 是 | boolean | 否 | 是否闪灯。 |
| lightColor | 是 | 是 | number | 否 | 通知灯颜色。 |
| vibrationValues | 是 | 是 | Array
\<
number
\>
| 否 | 通知振动样式。 |
| enabled
| 是 | 否 | boolean | 否 | 此通知插槽中的启停状态。 |
| enabled
<sup>
9+
</sup>
| 是 | 否 | boolean | 否 | 此通知插槽中的启停状态。 |
## NotificationSorting
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录