提交 d837c42d 编写于 作者: zyjhandsome's avatar zyjhandsome

NotificationManager修改为notificationManager,与命名空间保持一致。

Signed-off-by: zyjhandsome's avatarzyjhandsome <zyjhandsome@126.com>
上级 1c8a7c53
......@@ -34,13 +34,13 @@
1. 导入NotificationManager模块。
```ts
import NotificationManager from '@ohos.notificationManager';
import notificationManager from '@ohos.notificationManager';
```
2. 请求发送通知的许可。
```ts
NotificationManager.requestEnableNotification().then(() => {
notificationManager.requestEnableNotification().then(() => {
console.info(`[ANS] requestEnableNotification success`);
}).catch((err) => {
console.error(`[ANS] requestEnableNotification failed, errCode[${err}]`);
......
......@@ -29,7 +29,7 @@
2. 导入模块。
```typescript
import NotificationManager from '@ohos.notificationManager';
import notificationManager from '@ohos.notificationManager';
import wantAgent from '@ohos.app.ability.wantAgent';
```
......@@ -98,7 +98,7 @@
// 构造NotificationRequest对象
let notificationRequest = {
content: {
contentType: NotificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: 'Test_Title',
text: 'Test_Text',
......@@ -110,7 +110,7 @@
wantAgent: wantAgentObj,
}
NotificationManager.publish(notificationRequest, (err) => {
notificationManager.publish(notificationRequest, (err) => {
if (err) {
console.error(`[ANS] failed to publish, error[${err}]`);
return;
......
......@@ -25,13 +25,13 @@
2. 导入模块。
```ts
import NotificationManager from '@ohos.notificationManager';
import notificationManager from '@ohos.notificationManager';
```
3. 查询系统是否支持进度条模板,查询结果为支持downloadTemplate模板类通知。
```ts
NotificationManager.isSupportTemplate('downloadTemplate').then((data) => {
notificationManager.isSupportTemplate('downloadTemplate').then((data) => {
console.info(`[ANS] isSupportTemplate success`);
let isSupportTpl: boolean = data; // isSupportTpl的值为true表示支持支持downloadTemplate模板类通知,false表示不支持
// ...
......@@ -49,7 +49,7 @@
let notificationRequest = {
id: 1,
content: {
contentType: NotificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: 'test_title',
text: 'test_text',
......@@ -64,7 +64,7 @@
}
// 发布通知
NotificationManager.publish(notificationRequest, (err) => {
notificationManager.publish(notificationRequest, (err) => {
if (err) {
console.error(`[ANS] failed to publish, error[${err}]`);
return;
......
......@@ -22,7 +22,7 @@
## 接口说明
通知发布接口如下表所示,不同发布类型通知由[NotificationRequest](../reference/apis/js-apis-notification.md#notificationrequest)的字段携带不同的信息。
通知发布接口如下表所示,不同发布类型通知由[NotificationRequest](../reference/apis/js-apis-notificationManager.md#notificationrequest)的字段携带不同的信息。
| **接口名** | **描述** |
| -------- | -------- |
......@@ -38,7 +38,7 @@
2. 导入模块。
```ts
import NotificationManager from '@ohos.notificationManager';
import notificationManager from '@ohos.notificationManager';
```
3. 构造NotificationRequest对象,并发布通知。
......@@ -48,7 +48,7 @@
let notificationRequest = {
id: 1,
content: {
contentType: NotificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, // 普通文本类型通知
contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, // 普通文本类型通知
normal: {
title: 'test_title',
text: 'test_text',
......@@ -57,7 +57,7 @@
}
}
NotificationManager.publish(notificationRequest, (err) => {
notificationManager.publish(notificationRequest, (err) => {
if (err) {
console.error(`[ANS] failed to publish, error[${err}]`);
return;
......@@ -75,7 +75,7 @@
let notificationRequest = {
id: 1,
content: {
contentType: NotificationManager.ContentType.NOTIFICATION_CONTENT_LONG_TEXT, // 长文本类型通知
contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_LONG_TEXT, // 长文本类型通知
longText: {
title: 'test_title',
text: 'test_text',
......@@ -88,7 +88,7 @@
}
// 发布通知
NotificationManager.publish(notificationRequest, (err) => {
notificationManager.publish(notificationRequest, (err) => {
if (err) {
console.error(`[ANS] failed to publish, error[${err}]`);
return;
......@@ -105,7 +105,7 @@
let notificationRequest = {
id: 1,
content: {
contentType: NotificationManager.ContentType.NOTIFICATION_CONTENT_MULTILINE, // 多行文本类型通知
contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_MULTILINE, // 多行文本类型通知
multiLine: {
title: 'test_title',
text: 'test_text',
......@@ -117,7 +117,7 @@
}
// 发布通知
NotificationManager.publish(notificationRequest, (err) => {
notificationManager.publish(notificationRequest, (err) => {
if (err) {
console.error(`[ANS] failed to publish, error[${err}]`);
return;
......@@ -135,7 +135,7 @@
let notificationRequest = {
id: 1,
content: {
contentType: NotificationManager.ContentType.NOTIFICATION_CONTENT_PICTURE,
contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_PICTURE,
picture: {
title: 'test_title',
text: 'test_text',
......@@ -148,7 +148,7 @@
}
// 发布通知
NotificationManager.publish(notificationRequest, (err) => {
notificationManager.publish(notificationRequest, (err) => {
if (err) {
console.error(`[ANS] failed to publish, error[${err}]`);
return;
......
......@@ -27,7 +27,7 @@
```js
import reminderAgentManager from '@ohos.reminderAgentManager';
import NotificationManager from '@ohos.notificationManager';
import notificationManager from '@ohos.notificationManager';
```
4. 定义目标提醒代理。开发者根据实际需要,选择定义如下类型的提醒。
......@@ -55,7 +55,7 @@
content: 'this is content', // 指明提醒内容
expiredContent: 'this reminder has expired', // 指明提醒过期后需要显示的内容
notificationId: 100, // 指明提醒使用的通知的ID号,相同ID号的提醒会覆盖
slotType: NotificationManager.SlotType.SOCIAL_COMMUNICATION // 指明提醒的Slot类型
slotType: notificationManager.SlotType.SOCIAL_COMMUNICATION // 指明提醒的Slot类型
}
```
- 定义日历实例。
......@@ -99,7 +99,7 @@
expiredContent: 'this reminder has expired', // 指明提醒过期后需要显示的内容
snoozeContent: 'remind later', // 指明延迟提醒时需要显示的内容
notificationId: 100, // 指明提醒使用的通知的ID号,相同ID号的提醒会覆盖
slotType: NotificationManager.SlotType.SOCIAL_COMMUNICATION // 指明提醒的Slot类型
slotType: notificationManager.SlotType.SOCIAL_COMMUNICATION // 指明提醒的Slot类型
}
```
- 定义闹钟实例。
......@@ -136,7 +136,7 @@
expiredContent: 'this reminder has expired', // 指明提醒过期后需要显示的内容
snoozeContent: 'remind later', // 指明延迟提醒时需要显示的内容
notificationId: 99, // 指明提醒使用的通知的ID号,相同ID号的提醒会覆盖
slotType: NotificationManager.SlotType.SOCIAL_COMMUNICATION // 指明提醒的Slot类型
slotType: notificationManager.SlotType.SOCIAL_COMMUNICATION // 指明提醒的Slot类型
}
```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册