提交 85886b61 编写于 作者: 廖康康

arkTs语法整改

Signed-off-by: N廖康康 <liaokangkang@huawei.com>
上级 32c6e7a8
...@@ -40,14 +40,14 @@ publishReminder(reminderReq: ReminderRequest, callback: AsyncCallback\<number>): ...@@ -40,14 +40,14 @@ publishReminder(reminderReq: ReminderRequest, callback: AsyncCallback\<number>):
**示例** **示例**
```ts ```ts
let timer = { let timer:reminderAgent.ReminderRequestTimer = {
reminderType: reminderAgent.ReminderType.REMINDER_TYPE_TIMER, reminderType: reminderAgent.ReminderType.REMINDER_TYPE_TIMER,
triggerTimeInSeconds: 10 triggerTimeInSeconds: 10
} }
reminderAgent.publishReminder(timer, (err, reminderId) => { reminderAgent.publishReminder(timer, (err: BusinessError, reminderId: number) => {
console.log("callback, reminderId = " + reminderId); console.log("callback, reminderId = " + reminderId);
}); });
``` ```
...@@ -76,14 +76,14 @@ publishReminder(reminderReq: ReminderRequest): Promise\<number> ...@@ -76,14 +76,14 @@ publishReminder(reminderReq: ReminderRequest): Promise\<number>
**示例** **示例**
```ts ```ts
let timer = { let timer:reminderAgent.ReminderRequestTimer = {
reminderType: reminderAgent.ReminderType.REMINDER_TYPE_TIMER, reminderType: reminderAgent.ReminderType.REMINDER_TYPE_TIMER,
triggerTimeInSeconds: 10 triggerTimeInSeconds: 10
} }
reminderAgent.publishReminder(timer).then((reminderId) => { reminderAgent.publishReminder(timer).then((reminderId: number) => {
console.log("promise, reminderId = " + reminderId); console.log("promise, reminderId = " + reminderId);
}); });
``` ```
...@@ -108,8 +108,8 @@ cancelReminder(reminderId: number, callback: AsyncCallback\<void>): void ...@@ -108,8 +108,8 @@ cancelReminder(reminderId: number, callback: AsyncCallback\<void>): void
**示例** **示例**
```ts ```ts
reminderAgent.cancelReminder(1, (err, data) => { reminderAgent.cancelReminder(1, (err: BusinessError, data: void) => {
console.log("cancelReminder callback"); console.log("cancelReminder callback");
}); });
``` ```
...@@ -165,29 +165,29 @@ getValidReminders(callback: AsyncCallback\<Array\<ReminderRequest>>): void ...@@ -165,29 +165,29 @@ getValidReminders(callback: AsyncCallback\<Array\<ReminderRequest>>): void
**示例** **示例**
```ts ```ts
reminderAgent.getValidReminders((err, reminders) => { reminderAgent.getValidReminders((err: BusinessError, reminders: Array<reminderAgent.ReminderRequest>) => {
console.log("callback, getValidReminders length = " + reminders.length); console.log("callback, getValidReminders length = " + reminders.length);
for (let i = 0; i < reminders.length; i++) { for (let i = 0; i < reminders.length; i++) {
console.log("getValidReminders = " + reminders[i]); console.log("getValidReminders = " + reminders[i]);
console.log("getValidReminders, reminderType = " + reminders[i].reminderType); console.log("getValidReminders, reminderType = " + reminders[i].reminderType);
for (let j = 0; j < reminders[i].actionButton.length; j++) { for (let j = 0; j < reminders[i].actionButton.length; j++) {
console.log("getValidReminders, actionButton.title = " + reminders[i].actionButton[j].title); console.log("getValidReminders, actionButton.title = " + reminders[i].actionButton[j].title);
console.log("getValidReminders, actionButton.type = " + reminders[i].actionButton[j].type); console.log("getValidReminders, actionButton.type = " + reminders[i].actionButton[j].type);
}
console.log("getValidReminders, wantAgent.pkgName = " + reminders[i].wantAgent.pkgName);
console.log("getValidReminders, wantAgent.abilityName = " + reminders[i].wantAgent.abilityName);
console.log("getValidReminders, maxScreenWantAgent.pkgName = " + reminders[i].maxScreenWantAgent.pkgName);
console.log("getValidReminders, maxScreenWantAgent.abilityName = " + reminders[i].maxScreenWantAgent.abilityName);
console.log("getValidReminders, ringDuration = " + reminders[i].ringDuration);
console.log("getValidReminders, snoozeTimes = " + reminders[i].snoozeTimes);
console.log("getValidReminders, timeInterval = " + reminders[i].timeInterval);
console.log("getValidReminders, title = " + reminders[i].title);
console.log("getValidReminders, content = " + reminders[i].content);
console.log("getValidReminders, expiredContent = " + reminders[i].expiredContent);
console.log("getValidReminders, snoozeContent = " + reminders[i].snoozeContent);
console.log("getValidReminders, notificationId = " + reminders[i].notificationId);
console.log("getValidReminders, slotType = " + reminders[i].slotType);
} }
console.log("getValidReminders, wantAgent.pkgName = " + reminders[i].wantAgent.pkgName);
console.log("getValidReminders, wantAgent.abilityName = " + reminders[i].wantAgent.abilityName);
console.log("getValidReminders, maxScreenWantAgent.pkgName = " + reminders[i].maxScreenWantAgent.pkgName);
console.log("getValidReminders, maxScreenWantAgent.abilityName = " + reminders[i].maxScreenWantAgent.abilityName);
console.log("getValidReminders, ringDuration = " + reminders[i].ringDuration);
console.log("getValidReminders, snoozeTimes = " + reminders[i].snoozeTimes);
console.log("getValidReminders, timeInterval = " + reminders[i].timeInterval);
console.log("getValidReminders, title = " + reminders[i].title);
console.log("getValidReminders, content = " + reminders[i].content);
console.log("getValidReminders, expiredContent = " + reminders[i].expiredContent);
console.log("getValidReminders, snoozeContent = " + reminders[i].snoozeContent);
console.log("getValidReminders, notificationId = " + reminders[i].notificationId);
console.log("getValidReminders, slotType = " + reminders[i].slotType);
}
}) })
``` ```
...@@ -212,30 +212,31 @@ getValidReminders(): Promise\<Array\<ReminderRequest>> ...@@ -212,30 +212,31 @@ getValidReminders(): Promise\<Array\<ReminderRequest>>
**示例** **示例**
```ts ```ts
reminderAgent.getValidReminders().then((reminders) => { reminderAgent.getValidReminders().then((reminders: Array<reminderAgent.ReminderRequest>) => {
console.log("promise, getValidReminders length = " + reminders.length); console.log("promise, getValidReminders length = " + reminders.length);
for (let i = 0; i < reminders.length; i++) { for (let i = 0; i < reminders.length; i++) {
console.log("getValidReminders = " + reminders[i]); console.log("getValidReminders = " + reminders[i]);
console.log("getValidReminders, reminderType = " + reminders[i].reminderType); console.log("getValidReminders, reminderType = " + reminders[i].reminderType);
for (let j = 0; j < reminders[i].actionButton.length; j++) { for (let j = 0; j < reminders[i].actionButton.length; j++) {
console.log("getValidReminders, actionButton.title = " + reminders[i].actionButton[j].title); console.log("getValidReminders, actionButton.title = " + reminders[i].actionButton[j].title);
console.log("getValidReminders, actionButton.type = " + reminders[i].actionButton[j].type); console.log("getValidReminders, actionButton.type = " + reminders[i].actionButton[j].type);
}
console.log("getValidReminders, wantAgent.pkgName = " + reminders[i].wantAgent.pkgName);
console.log("getValidReminders, wantAgent.abilityName = " + reminders[i].wantAgent.abilityName);
console.log("getValidReminders, maxScreenWantAgent.pkgName = " + reminders[i].maxScreenWantAgent.pkgName);
console.log("getValidReminders, maxScreenWantAgent.abilityName = " + reminders[i].maxScreenWantAgent.abilityName);
console.log("getValidReminders, ringDuration = " + reminders[i].ringDuration);
console.log("getValidReminders, snoozeTimes = " + reminders[i].snoozeTimes);
console.log("getValidReminders, timeInterval = " + reminders[i].timeInterval);
console.log("getValidReminders, title = " + reminders[i].title);
console.log("getValidReminders, content = " + reminders[i].content);
console.log("getValidReminders, expiredContent = " + reminders[i].expiredContent);
console.log("getValidReminders, snoozeContent = " + reminders[i].snoozeContent);
console.log("getValidReminders, notificationId = " + reminders[i].notificationId);
console.log("getValidReminders, slotType = " + reminders[i].slotType);
} }
console.log("getValidReminders, wantAgent.pkgName = " + reminders[i].wantAgent.pkgName);
console.log("getValidReminders, wantAgent.abilityName = " + reminders[i].wantAgent.abilityName);
console.log("getValidReminders, maxScreenWantAgent.pkgName = " + reminders[i].maxScreenWantAgent.pkgName);
console.log("getValidReminders, maxScreenWantAgent.abilityName = " + reminders[i].maxScreenWantAgent.abilityName);
console.log("getValidReminders, ringDuration = " + reminders[i].ringDuration);
console.log("getValidReminders, snoozeTimes = " + reminders[i].snoozeTimes);
console.log("getValidReminders, timeInterval = " + reminders[i].timeInterval);
console.log("getValidReminders, title = " + reminders[i].title);
console.log("getValidReminders, content = " + reminders[i].content);
console.log("getValidReminders, expiredContent = " + reminders[i].expiredContent);
console.log("getValidReminders, snoozeContent = " + reminders[i].snoozeContent);
console.log("getValidReminders, notificationId = " + reminders[i].notificationId);
console.log("getValidReminders, slotType = " + reminders[i].slotType);
}
}) })
``` ```
...@@ -259,8 +260,8 @@ cancelAllReminders(callback: AsyncCallback\<void>): void ...@@ -259,8 +260,8 @@ cancelAllReminders(callback: AsyncCallback\<void>): void
**示例** **示例**
```ts ```ts
reminderAgent.cancelAllReminders((err, data) =>{ reminderAgent.cancelAllReminders((err: BusinessError, data: void) =>{
console.log("cancelAllReminders callback") console.log("cancelAllReminders callback")
}) })
``` ```
...@@ -311,13 +312,13 @@ addNotificationSlot(slot: NotificationSlot, callback: AsyncCallback\<void>): voi ...@@ -311,13 +312,13 @@ addNotificationSlot(slot: NotificationSlot, callback: AsyncCallback\<void>): voi
**示例** **示例**
```ts ```ts
import notification from '@ohos.notification' import notification from '@ohos.notificationManager'
let mySlot = { let mySlot:notification.NotificationSlot = {
type: notification.SlotType.SOCIAL_COMMUNICATION type: notification.SlotType.SOCIAL_COMMUNICATION
} }
reminderAgent.addNotificationSlot(mySlot, (err, data) => { reminderAgent.addNotificationSlot(mySlot, (err: BusinessError, data: void) => {
console.log("addNotificationSlot callback"); console.log("addNotificationSlot callback");
}); });
``` ```
...@@ -348,13 +349,13 @@ addNotificationSlot(slot: NotificationSlot): Promise\<void> ...@@ -348,13 +349,13 @@ addNotificationSlot(slot: NotificationSlot): Promise\<void>
**示例** **示例**
```ts ```ts
import notification from '@ohos.notification' import notification from '@ohos.notificationManager'
let mySlot = { let mySlot:notification.NotificationSlot = {
type: notification.SlotType.SOCIAL_COMMUNICATION type: notification.SlotType.SOCIAL_COMMUNICATION
} }
reminderAgent.addNotificationSlot(mySlot).then(() => { reminderAgent.addNotificationSlot(mySlot).then(() => {
console.log("addNotificationSlot promise"); console.log("addNotificationSlot promise");
}); });
``` ```
...@@ -382,8 +383,8 @@ removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback\ ...@@ -382,8 +383,8 @@ removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback\
```ts ```ts
import notification from '@ohos.notification' import notification from '@ohos.notification'
reminderAgent.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION, (err, data) => { reminderAgent.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION, (err: BusinessError, data: void) => {
console.log("removeNotificationSlot callback"); console.log("removeNotificationSlot callback");
}); });
``` ```
......
...@@ -45,22 +45,18 @@ publishReminder(reminderReq: ReminderRequest, callback: AsyncCallback\<number>): ...@@ -45,22 +45,18 @@ publishReminder(reminderReq: ReminderRequest, callback: AsyncCallback\<number>):
**示例** **示例**
```ts ```ts
let timer = { let timer: reminderAgentManager.ReminderRequestTimer = {
reminderType: reminderAgentManager.ReminderType.REMINDER_TYPE_TIMER, reminderType: reminderAgentManager.ReminderType.REMINDER_TYPE_TIMER,
triggerTimeInSeconds: 10 triggerTimeInSeconds: 10
} }
try { reminderAgentManager.publishReminder(timer, (err: BusinessError, reminderId: number) => {
reminderAgentManager.publishReminder(timer, (err, reminderId) => { if (err) {
if (err) { console.log("callback err code:" + err.code + " message:" + err.message);
console.log("callback err code:" + err.code + " message:" + err.message); } else {
} else { console.log("callback, reminderId = " + reminderId);
console.log("callback, reminderId = " + reminderId); }
} });
});
} catch (error) {
console.log("publishReminder code:" + error.code + " message:" + error.message);
};
``` ```
## reminderAgentManager.publishReminder ## reminderAgentManager.publishReminder
...@@ -98,20 +94,16 @@ publishReminder(reminderReq: ReminderRequest): Promise\<number> ...@@ -98,20 +94,16 @@ publishReminder(reminderReq: ReminderRequest): Promise\<number>
**示例** **示例**
```ts ```ts
let timer = { let timer: reminderAgentManager.ReminderRequestTimer = {
reminderType: reminderAgentManager.ReminderType.REMINDER_TYPE_TIMER, reminderType: reminderAgentManager.ReminderType.REMINDER_TYPE_TIMER,
triggerTimeInSeconds: 10 triggerTimeInSeconds: 10
} }
try { reminderAgentManager.publishReminder(timer).then((reminderId: number) => {
reminderAgentManager.publishReminder(timer).then((reminderId) => { console.log("promise, reminderId = " + reminderId);
console.log("promise, reminderId = " + reminderId); }).catch((err: BusinessError) => {
}).catch(err => { console.log("promise err code:" + err.code + " message:" + err.message);
console.log("promise err code:" + err.code + " message:" + err.message); });
});
} catch (error) {
console.log("publishReminder code:" + error.code + " message:" + error.message);
};
``` ```
...@@ -142,17 +134,14 @@ cancelReminder(reminderId: number, callback: AsyncCallback\<void>): void ...@@ -142,17 +134,14 @@ cancelReminder(reminderId: number, callback: AsyncCallback\<void>): void
**示例** **示例**
```ts ```ts
try { let reminderId: number = 1;
reminderAgentManager.cancelReminder(1, (err, data) => { reminderAgentManager.cancelReminder(reminderId, (err: BusinessError, data: void) => {
if (err) { if (err) {
console.log("callback err code:" + err.code + " message:" + err.message); console.log("callback err code:" + err.code + " message:" + err.message);
} else { } else {
console.log("cancelReminder callback"); console.log("cancelReminder callback");
} }
}); });
} catch (error) {
console.log("cancelReminder code:" + error.code + " message:" + error.message);
};
``` ```
## reminderAgentManager.cancelReminder ## reminderAgentManager.cancelReminder
...@@ -187,15 +176,12 @@ cancelReminder(reminderId: number): Promise\<void> ...@@ -187,15 +176,12 @@ cancelReminder(reminderId: number): Promise\<void>
**示例** **示例**
```ts ```ts
try { let reminderId: number = 1;
reminderAgentManager.cancelReminder(1).then(() => { reminderAgentManager.cancelReminder(reminderId).then(() => {
console.log("cancelReminder promise"); console.log("cancelReminder promise");
}).catch(err => { }).catch((err: BusinessError) => {
console.log("promise err code:" + err.code + " message:" + err.message); console.log("promise err code:" + err.code + " message:" + err.message);
}); });
} catch (error) {
console.log("cancelReminder code:" + error.code + " message:" + error.message);
};
``` ```
## reminderAgentManager.getValidReminders ## reminderAgentManager.getValidReminders
...@@ -223,38 +209,34 @@ getValidReminders(callback: AsyncCallback<Array\<ReminderRequest>>): void ...@@ -223,38 +209,34 @@ getValidReminders(callback: AsyncCallback<Array\<ReminderRequest>>): void
**示例** **示例**
```ts ```ts
try { reminderAgentManager.getValidReminders((err: BusinessError, reminders: Array<reminderAgentManager.ReminderRequest>) => {
reminderAgentManager.getValidReminders((err, reminders) => { if (err) {
if (err) { console.log("callback err code:" + err.code + " message:" + err.message);
console.log("callback err code:" + err.code + " message:" + err.message); } else {
} else { console.log("callback, getValidReminders length = " + reminders.length);
console.log("callback, getValidReminders length = " + reminders.length); for (let i = 0; i < reminders.length; i++) {
for (let i = 0; i < reminders.length; i++) { console.log("getValidReminders = " + reminders[i]);
console.log("getValidReminders = " + reminders[i]); console.log("getValidReminders, reminderType = " + reminders[i].reminderType);
console.log("getValidReminders, reminderType = " + reminders[i].reminderType); for (let j = 0; j < reminders[i].actionButton.length; j++) {
for (let j = 0; j < reminders[i].actionButton.length; j++) { console.log("getValidReminders, actionButton.title = " + reminders[i].actionButton[j].title);
console.log("getValidReminders, actionButton.title = " + reminders[i].actionButton[j].title); console.log("getValidReminders, actionButton.type = " + reminders[i].actionButton[j].type);
console.log("getValidReminders, actionButton.type = " + reminders[i].actionButton[j].type); }
} console.log("getValidReminders, wantAgent.pkgName = " + reminders[i].wantAgent.pkgName);
console.log("getValidReminders, wantAgent.pkgName = " + reminders[i].wantAgent.pkgName); console.log("getValidReminders, wantAgent.abilityName = " + reminders[i].wantAgent.abilityName);
console.log("getValidReminders, wantAgent.abilityName = " + reminders[i].wantAgent.abilityName); console.log("getValidReminders, maxScreenWantAgent.pkgName = " + reminders[i].maxScreenWantAgent.pkgName);
console.log("getValidReminders, maxScreenWantAgent.pkgName = " + reminders[i].maxScreenWantAgent.pkgName); console.log("getValidReminders, maxScreenWantAgent.abilityName = " + reminders[i].maxScreenWantAgent.abilityName);
console.log("getValidReminders, maxScreenWantAgent.abilityName = " + reminders[i].maxScreenWantAgent.abilityName); console.log("getValidReminders, ringDuration = " + reminders[i].ringDuration);
console.log("getValidReminders, ringDuration = " + reminders[i].ringDuration); console.log("getValidReminders, snoozeTimes = " + reminders[i].snoozeTimes);
console.log("getValidReminders, snoozeTimes = " + reminders[i].snoozeTimes); console.log("getValidReminders, timeInterval = " + reminders[i].timeInterval);
console.log("getValidReminders, timeInterval = " + reminders[i].timeInterval); console.log("getValidReminders, title = " + reminders[i].title);
console.log("getValidReminders, title = " + reminders[i].title); console.log("getValidReminders, content = " + reminders[i].content);
console.log("getValidReminders, content = " + reminders[i].content); console.log("getValidReminders, expiredContent = " + reminders[i].expiredContent);
console.log("getValidReminders, expiredContent = " + reminders[i].expiredContent); console.log("getValidReminders, snoozeContent = " + reminders[i].snoozeContent);
console.log("getValidReminders, snoozeContent = " + reminders[i].snoozeContent); console.log("getValidReminders, notificationId = " + reminders[i].notificationId);
console.log("getValidReminders, notificationId = " + reminders[i].notificationId); console.log("getValidReminders, slotType = " + reminders[i].slotType);
console.log("getValidReminders, slotType = " + reminders[i].slotType); }
} }
} });
})
} catch (error) {
console.log("getValidReminders code:" + error.code + " message:" + error.message);
};
``` ```
## reminderAgentManager.getValidReminders ## reminderAgentManager.getValidReminders
...@@ -282,36 +264,32 @@ getValidReminders(): Promise\<Array\<ReminderRequest>> ...@@ -282,36 +264,32 @@ getValidReminders(): Promise\<Array\<ReminderRequest>>
**示例** **示例**
```ts ```ts
try { reminderAgentManager.getValidReminders().then((reminders: Array<reminderAgentManager.ReminderRequest>) => {
reminderAgentManager.getValidReminders().then((reminders) => { console.log("promise, getValidReminders length = " + reminders.length);
console.log("promise, getValidReminders length = " + reminders.length); for (let i = 0; i < reminders.length; i++) {
for (let i = 0; i < reminders.length; i++) { console.log("getValidReminders = " + reminders[i]);
console.log("getValidReminders = " + reminders[i]); console.log("getValidReminders, reminderType = " + reminders[i].reminderType);
console.log("getValidReminders, reminderType = " + reminders[i].reminderType); for (let j = 0; j < reminders[i].actionButton.length; j++) {
for (let j = 0; j < reminders[i].actionButton.length; j++) { console.log("getValidReminders, actionButton.title = " + reminders[i].actionButton[j].title);
console.log("getValidReminders, actionButton.title = " + reminders[i].actionButton[j].title); console.log("getValidReminders, actionButton.type = " + reminders[i].actionButton[j].type);
console.log("getValidReminders, actionButton.type = " + reminders[i].actionButton[j].type); }
} console.log("getValidReminders, wantAgent.pkgName = " + reminders[i].wantAgent.pkgName);
console.log("getValidReminders, wantAgent.pkgName = " + reminders[i].wantAgent.pkgName); console.log("getValidReminders, wantAgent.abilityName = " + reminders[i].wantAgent.abilityName);
console.log("getValidReminders, wantAgent.abilityName = " + reminders[i].wantAgent.abilityName); console.log("getValidReminders, maxScreenWantAgent.pkgName = " + reminders[i].maxScreenWantAgent.pkgName);
console.log("getValidReminders, maxScreenWantAgent.pkgName = " + reminders[i].maxScreenWantAgent.pkgName); console.log("getValidReminders, maxScreenWantAgent.abilityName = " + reminders[i].maxScreenWantAgent.abilityName);
console.log("getValidReminders, maxScreenWantAgent.abilityName = " + reminders[i].maxScreenWantAgent.abilityName); console.log("getValidReminders, ringDuration = " + reminders[i].ringDuration);
console.log("getValidReminders, ringDuration = " + reminders[i].ringDuration); console.log("getValidReminders, snoozeTimes = " + reminders[i].snoozeTimes);
console.log("getValidReminders, snoozeTimes = " + reminders[i].snoozeTimes); console.log("getValidReminders, timeInterval = " + reminders[i].timeInterval);
console.log("getValidReminders, timeInterval = " + reminders[i].timeInterval); console.log("getValidReminders, title = " + reminders[i].title);
console.log("getValidReminders, title = " + reminders[i].title); console.log("getValidReminders, content = " + reminders[i].content);
console.log("getValidReminders, content = " + reminders[i].content); console.log("getValidReminders, expiredContent = " + reminders[i].expiredContent);
console.log("getValidReminders, expiredContent = " + reminders[i].expiredContent); console.log("getValidReminders, snoozeContent = " + reminders[i].snoozeContent);
console.log("getValidReminders, snoozeContent = " + reminders[i].snoozeContent); console.log("getValidReminders, notificationId = " + reminders[i].notificationId);
console.log("getValidReminders, notificationId = " + reminders[i].notificationId); console.log("getValidReminders, slotType = " + reminders[i].slotType);
console.log("getValidReminders, slotType = " + reminders[i].slotType); }
} }).catch((err: BusinessError) => {
}).catch(err => { console.log("promise err code:" + err.code + " message:" + err.message);
console.log("promise err code:" + err.code + " message:" + err.message); });
});
} catch (error) {
console.log("getValidReminders code:" + error.code + " message:" + error.message);
};
``` ```
## reminderAgentManager.cancelAllReminders ## reminderAgentManager.cancelAllReminders
...@@ -339,17 +317,13 @@ cancelAllReminders(callback: AsyncCallback\<void>): void ...@@ -339,17 +317,13 @@ cancelAllReminders(callback: AsyncCallback\<void>): void
**示例** **示例**
```ts ```ts
try { reminderAgentManager.cancelAllReminders((err: BusinessError, data: void) =>{
reminderAgentManager.cancelAllReminders((err, data) =>{ if (err) {
if (err) { console.log("callback err code:" + err.code + " message:" + err.message);
console.log("callback err code:" + err.code + " message:" + err.message); } else {
} else { console.log("cancelAllReminders callback")
console.log("cancelAllReminders callback") }
} });
})
} catch (error) {
console.log("cancelAllReminders code:" + error.code + " message:" + error.message);
};
``` ```
## reminderAgentManager.cancelAllReminders ## reminderAgentManager.cancelAllReminders
...@@ -377,15 +351,11 @@ cancelAllReminders(): Promise\<void> ...@@ -377,15 +351,11 @@ cancelAllReminders(): Promise\<void>
**示例** **示例**
```ts ```ts
try { reminderAgentManager.cancelAllReminders().then(() => {
reminderAgentManager.cancelAllReminders().then(() => { console.log("cancelAllReminders promise")
console.log("cancelAllReminders promise") }).catch((err: BusinessError) => {
}).catch(err => { console.log("promise err code:" + err.code + " message:" + err.message);
console.log("promise err code:" + err.code + " message:" + err.message); });
});
} catch (error) {
console.log("cancelAllReminders code:" + error.code + " message:" + error.message);
};
``` ```
...@@ -407,22 +377,19 @@ addNotificationSlot(slot: NotificationSlot, callback: AsyncCallback\<void>): voi ...@@ -407,22 +377,19 @@ addNotificationSlot(slot: NotificationSlot, callback: AsyncCallback\<void>): voi
**示例** **示例**
```ts ```ts
import notification from '@ohos.notification' import notification from '@ohos.notificationManager'
let mySlot = { let mySlot: notification.NotificationSlot = {
type: notification.SlotType.SOCIAL_COMMUNICATION type: notification.SlotType.SOCIAL_COMMUNICATION
} }
try {
reminderAgentManager.addNotificationSlot(mySlot, (err, data) => { reminderAgentManager.addNotificationSlot(mySlot, (err: BusinessError, data: void) => {
if (err) { if (err) {
console.log("callback err code:" + err.code + " message:" + err.message); console.log("callback err code:" + err.code + " message:" + err.message);
} else { } else {
console.log("addNotificationSlot callback"); console.log("addNotificationSlot callback");
} }
}); });
} catch (error) {
console.log("addNotificationSlot code:" + error.code + " message:" + error.message);
};
``` ```
...@@ -449,20 +416,16 @@ addNotificationSlot(slot: NotificationSlot): Promise\<void> ...@@ -449,20 +416,16 @@ addNotificationSlot(slot: NotificationSlot): Promise\<void>
**示例** **示例**
```ts ```ts
import notification from '@ohos.notification' import notification from '@ohos.notificationManager'
let mySlot = { let mySlot: notification.NotificationSlot = {
type: notification.SlotType.SOCIAL_COMMUNICATION type: notification.SlotType.SOCIAL_COMMUNICATION
} }
try { reminderAgentManager.addNotificationSlot(mySlot).then(() => {
reminderAgentManager.addNotificationSlot(mySlot).then(() => { console.log("addNotificationSlot promise");
console.log("addNotificationSlot promise"); }).catch((err: BusinessError) => {
}).catch(err => { console.log("promise err code:" + err.code + " message:" + err.message);
console.log("promise err code:" + err.code + " message:" + err.message); });
});
} catch (error) {
console.log("addNotificationSlot code:" + error.code + " message:" + error.message);
};
``` ```
...@@ -484,19 +447,16 @@ removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback\ ...@@ -484,19 +447,16 @@ removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback\
**示例** **示例**
```ts ```ts
import notification from '@ohos.notification' import notification from '@ohos.notificationManager'
try { reminderAgentManager.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION,
reminderAgentManager.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION, (err, data) => { (err: BusinessError, data: void) => {
if (err) { if (err) {
console.log("callback err code:" + err.code + " message:" + err.message); console.log("callback err code:" + err.code + " message:" + err.message);
} else { } else {
console.log("removeNotificationSlot callback"); console.log("removeNotificationSlot callback");
} }
}); });
} catch (error) {
console.log("removeNotificationSlot code:" + error.code + " message:" + error.message);
};
``` ```
...@@ -523,17 +483,13 @@ removeNotificationSlot(slotType: notification.SlotType): Promise\<void> ...@@ -523,17 +483,13 @@ removeNotificationSlot(slotType: notification.SlotType): Promise\<void>
**示例** **示例**
```ts ```ts
import notification from '@ohos.notification' import notification from '@ohos.notificationManager'
try { reminderAgentManager.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION).then(() => {
reminderAgentManager.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION).then(() => { console.log("removeNotificationSlot promise");
console.log("removeNotificationSlot promise"); }).catch((err: BusinessError) => {
}).catch(err => { console.log("promise err code:" + err.code + " message:" + err.message);
console.log("promise err code:" + err.code + " message:" + err.message); });
});
} catch (error) {
console.log("removeNotificationSlot code:" + error.code + " message:" + error.message);
};
``` ```
## ActionButtonType ## ActionButtonType
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册