
回复
1.notificationManager.cancelAll
支持设备Phone2in1TabletCarWearable
cancelAll(callback: AsyncCallback<void>): void
取消当前应用所有已发布的通知。使用callback异步回调。
系统能力:SystemCapability.Notification.Notification
示例:
import { BusinessError } from '@kit.BasicServicesKit';
// cancel回调
let cancelAllCallback = (err: BusinessError): void => {
if (err) {
console.error(`Failed to cancel all notification. Code is ${err.code}, message is ${err.message}`);
} else {
console.info(`Succeeded in canceling all notification.`);
}
}
notificationManager.cancelAll(cancelAllCallback);
2.notificationManager.cancelAll
支持设备Phone2in1TabletCarWearable
cancelAll(): Promise<void>
取消当前应用所有已发布的通知。使用Promise异步回调。
系统能力:SystemCapability.Notification.Notification
示例:
import { BusinessError } from '@kit.BasicServicesKit';
notificationManager.cancelAll().then(() => {
console.info(`Succeeded in canceling all notification.`);
}).catch((err: BusinessError) => {
console.error(`Failed to cancel all notification. Code is ${err.code}, message is ${err.message}`);
本文主要参考引用自HarmonyOS官方网站