91欧美超碰AV自拍|国产成年人性爱视频免费看|亚洲 日韩 欧美一厂二区入|人人看人人爽人人操aV|丝袜美腿视频一区二区在线看|人人操人人爽人人爱|婷婷五月天超碰|97色色欧美亚州A√|另类A√无码精品一级av|欧美特级日韩特级

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評(píng)論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會(huì)員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識(shí)你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

鴻蒙開(kāi)發(fā)接口公共事件與通知:【Notification模塊】

jf_46214456 ? 來(lái)源:jf_46214456 ? 作者:jf_46214456 ? 2024-05-21 17:04 ? 次閱讀
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

Notification模塊

說(shuō)明: 本模塊首批接口從API version 7開(kāi)始支持。后續(xù)版本的新增接口,采用上角標(biāo)單獨(dú)標(biāo)記接口的起始版本。

導(dǎo)入模塊

開(kāi)發(fā)前請(qǐng)熟悉鴻蒙開(kāi)發(fā)指導(dǎo)文檔:[gitee.com/li-shizhen-skin/harmony-os/blob/master/README.md]

import Notification from '@ohos.notification';

Notification.publish

publish(request: NotificationRequest, callback: AsyncCallback): void

發(fā)布通知(callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

參數(shù):

名稱可讀可寫類型必填描述
request[NotificationRequest]設(shè)置要發(fā)布通知內(nèi)容的NotificationRequest對(duì)象。
callbackAsyncCallback被指定的回調(diào)方法。

示例:

//publish回調(diào)
function publishCallback(err) {
	console.info("========================== >publishCallback======================= >");
}
//通知Request對(duì)象
var notificationRequest = {
    id: 1,
    content: {
        contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
        normal: {
            title: "test_title",
            text: "test_text",
            additionalText: "test_additionalText"
        }
    }
}
Notification.publish(notificationRequest, publishCallback)

Notification.publish

publish(request: NotificationRequest): Promise

發(fā)布通知(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

示例:

//通知Request對(duì)象
var notificationRequest = {
    notificationId: 1,
    content: {
        contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
        normal: {
            title: "test_title",
            text: "test_text",
            additionalText: "test_additionalText"
        }
    }
}
Notification.publish(notificationRequest).then(() = > {
	console.info("========================== >publishCallback======================= >");
});

Notification.publish8+

publish(request: NotificationRequest, userId: number, callback: AsyncCallback): void

發(fā)布通知(callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
request[NotificationRequest]設(shè)置要發(fā)布通知內(nèi)容的NotificationRequest對(duì)象。
userIdnumber接收通知用戶的Id。
callbackAsyncCallback被指定的回調(diào)方法。

示例:

//publish回調(diào)
function publishCallback(err) {
	console.info("========================== >publishCallback======================= >");
}
// 接收通知的用戶ID
var userId = 1
//通知Request對(duì)象
var notificationRequest = {
    id: 1,
    content: {
        contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
        normal: {
            title: "test_title",
            text: "test_text",
            additionalText: "test_additionalText"
        }
    }
}
Notification.publish(notificationRequest, userId, publishCallback);

Notification.publish8+

publish(request: NotificationRequest, userId: number): Promise

發(fā)布通知(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
request[NotificationRequest]設(shè)置要發(fā)布通知內(nèi)容的NotificationRequest對(duì)象。
userIdnumber接收通知用戶的Id。

示例:

var notificationRequest = {
    notificationId: 1,
    content: {
        contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
        normal: {
            title: "test_title",
            text: "test_text",
            additionalText: "test_additionalText"
        }
    }
}

var userId = 1

Notification.publish(notificationRequest, userId).then(() = > {
	console.info("========================== >publishCallback======================= >");
});

Notification.cancel

cancel(id: number, label: string, callback: AsyncCallback): void

取消與指定id和label相匹配的已發(fā)布通知(callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

參數(shù):

名稱可讀可寫類型必填描述
idnumber通知ID。
labelstring通知標(biāo)簽
callbackAsyncCallback表示被指定的回調(diào)方法。

示例:

//cancel回調(diào)
function cancelCallback(err) {
	console.info("========================== >cancelCallback======================= >");
}
Notification.cancel(0, "label", cancelCallback)

Notification.cancel

cancel(id: number, label?: string): Promise

取消與指定id相匹配的已發(fā)布通知,label可以指定也可以不指定(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

參數(shù):

名稱可讀可寫類型必填描述
idnumber通知ID。
labelstring通知標(biāo)簽。

示例:

Notification.cancel(0).then(() = > {
	console.info("========================== >cancelCallback======================= >");
});

Notification.cancel

cancel(id: number, callback: AsyncCallback): void

取消與指定id相匹配的已發(fā)布通知(callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

參數(shù):

名稱可讀可寫類型必填描述
idnumber通知ID。
callbackAsyncCallback表示被指定的回調(diào)方法。

示例:

//cancel回調(diào)
function cancelCallback(err) {
	console.info("========================== >cancelCallback======================= >");
}
Notification.cancel(0, cancelCallback)

Notification.cancelAll

cancelAll(callback: AsyncCallback): void

取消所有已發(fā)布的通知(callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

參數(shù):

名稱可讀可寫類型必填描述
callbackAsyncCallback表示被指定的回調(diào)方法。

示例:

//cancel回調(diào)
function cancelAllCallback(err) {
	console.info("========================== >cancelAllCallback======================= >");
}
Notification.cancelAll(cancelAllCallback)

Notification.cancelAll

cancelAll(): Promise

取消所有已發(fā)布的通知(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

示例:

Notification.cancelAll().then(() = > {
	console.info("========================== >cancelAllCallback======================= >");
});

Notification.addSlot

addSlot(slot: NotificationSlot, callback: AsyncCallback): void

創(chuàng)建通知通道(callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
slot[NotificationSlot]要?jiǎng)?chuàng)建的通知通道對(duì)象。
callbackAsyncCallback表示被指定的回調(diào)方法。

示例:

//addslot回調(diào)
function addSlotCallBack(err) {
	console.info("========================== >addSlotCallBack======================= >");
}
//通知slot對(duì)象
var notificationSlot = {
    type: Notification.SlotType.SOCIAL_COMMUNICATION
}
Notification.addSlot(notificationSlot, addSlotCallBack)

Notification.addSlot

addSlot(slot: NotificationSlot): Promise

創(chuàng)建通知通道(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
slot[NotificationSlot]要?jiǎng)?chuàng)建的通知通道對(duì)象。

示例:

//通知slot對(duì)象
var notificationSlot = {
    type: Notification.SlotType.SOCIAL_COMMUNICATION
}
Notification.addSlot(notificationSlot).then(() = > {
	console.info("========================== >addSlotCallback======================= >");
});

Notification.addSlot

addSlot(type: SlotType, callback: AsyncCallback): void

創(chuàng)建通知通道(callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

參數(shù):

名稱可讀可寫類型必填描述
type[SlotType]要?jiǎng)?chuàng)建的通知通道的類型。
callbackAsyncCallback表示被指定的回調(diào)方法。

示例:

//addslot回調(diào)
function addSlotCallBack(err) {
	console.info("========================== >addSlotCallBack======================= >");
}
Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION, addSlotCallBack)

Notification.addSlot

addSlot(type: SlotType): Promise

創(chuàng)建通知通道(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

參數(shù):

名稱可讀可寫類型必填描述
type[SlotType]要?jiǎng)?chuàng)建的通知通道的類型。

示例:

Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION).then(() = > {
	console.info("========================== >addSlotCallback======================= >");
});

Notification.addSlots

addSlots(slots: Array, callback: AsyncCallback): void

創(chuàng)建多個(gè)通知通道(callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
slotsArray<[NotificationSlot]>要?jiǎng)?chuàng)建的通知通道對(duì)象數(shù)組。
callbackAsyncCallback表示被指定的回調(diào)方法。

示例:

//addSlots回調(diào)
function addSlotsCallBack(err) {
	console.info("========================== >addSlotsCallBack======================= >");
}
//通知slot對(duì)象
var notificationSlot = {
    type: Notification.SlotType.SOCIAL_COMMUNICATION
}
//通知slot array 對(duì)象
var notificationSlotArray = new Array();
notificationSlotArray[0] = notificationSlot;

Notification.addSlots(notificationSlotArray, addSlotsCallBack)

Notification.addSlots

addSlots(slots: Array): Promise

創(chuàng)建多個(gè)通知通道(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
slotsArray<[NotificationSlot]>要?jiǎng)?chuàng)建的通知通道對(duì)象數(shù)組。

示例:

//通知slot對(duì)象
var notificationSlot = {
    type: Notification.SlotType.SOCIAL_COMMUNICATION
}
//通知slot array 對(duì)象
var notificationSlotArray = new Array();
notificationSlotArray[0] = notificationSlot;

Notification.addSlots(notificationSlotArray).then(() = > {
	console.info("========================== >addSlotCallback======================= >");
});

Notification.getSlot

getSlot(slotType: SlotType, callback: AsyncCallback): void

獲取一個(gè)通知通道(callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

參數(shù):

名稱可讀可寫類型必填描述
slotType[SlotType]通知渠道類型,目前分為社交通信、服務(wù)提醒、內(nèi)容咨詢和其他類型。
callbackAsyncCallback<[NotificationSlot]>表示被指定的回調(diào)方法。

示例:

//getSlot回調(diào)
function getSlotCallback(err,data) {
	console.info("========================== >getSlotCallback======================= >");
}
var slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
Notification.getSlot(slotType, getSlotCallback)

Notification.getSlot

getSlot(slotType: SlotType): Promise

獲取一個(gè)通知通道(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

參數(shù):

名稱可讀可寫類型必填描述
slotType[SlotType]通知渠道類型,目前分為社交通信、服務(wù)提醒、內(nèi)容咨詢和其他類型。

返回值:

類型說(shuō)明
Promise以Promise形式返回獲取一個(gè)通知通道。

示例:

var slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
Notification.getSlot(slotType).then((data) = > {
	console.info("========================== >getSlotCallback======================= >");
});

Notification.getSlots

getSlots(callback: AsyncCallback>): void

獲取此應(yīng)用程序的所有通知通道(callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

參數(shù):

名稱可讀可寫類型必填描述
callbackAsyncCallback<[NotificationSlot]>表示被指定的回調(diào)方法。

示例:

//getSlots回調(diào)
function getSlotsCallback(err,data) {
	console.info("========================== >getSlotsCallback======================= >");
}
Notification.getSlots(getSlotsCallback)

Notification.getSlots

getSlots(): Promise>

獲取此應(yīng)用程序的所有通知通道(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

返回值:

類型說(shuō)明
Promise>以Promise形式返回獲取此應(yīng)用程序的所有通知通道的結(jié)果。

示例:

Notification.getSlots().then((data) = > {
	console.info("========================== >getSlotsCallback======================= >");
});

Notification.removeSlot

removeSlot(slotType: SlotType, callback: AsyncCallback): void

根據(jù)通知通道類型刪除創(chuàng)建的通知通道(callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

參數(shù):

名稱可讀可寫類型必填描述
slotType[SlotType]通知渠道類型,目前分為社交通信、服務(wù)提醒、內(nèi)容咨詢和其他類型。
callbackAsyncCallback表示被指定的回調(diào)方法。

示例:

//removeSlot回調(diào)
function removeSlotCallback(err) {
	console.info("========================== >removeSlotCallback======================= >");
}
var slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
Notification.removeSlot(slotType,removeSlotCallback)

Notification.removeSlot

removeSlot(slotType: SlotType): Promise

根據(jù)通知通道類型刪除創(chuàng)建的通知通道(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

參數(shù):

名稱可讀可寫類型必填描述
slotType[SlotType]通知渠道類型,目前分為社交通信、服務(wù)提醒、內(nèi)容咨詢和其他類型。

示例:

var slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
Notification.removeSlot(slotType).then(() = > {
	console.info("========================== >removeSlotCallback======================= >");
});

Notification.removeAllSlots

removeAllSlots(callback: AsyncCallback): void

刪除所有通知通道(callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

參數(shù):

名稱可讀可寫類型必填描述
callbackAsyncCallback表示被指定的回調(diào)方法。

示例:

function removeAllCallBack(err) {
	console.info("================ >removeAllCallBack======================= >");
}
Notification.removeAllSlots(removeAllCallBack)

Notification.removeAllSlots

removeAllSlots(): Promise

刪除所有通知通道(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

示例:

Notification.removeAllSlots().then(() = > {
	console.info("========================== >removeAllCallBack======================= >");
});

Notification.subscribe

subscribe(subscriber: NotificationSubscriber, info: NotificationSubscribeInfo, callback: AsyncCallback): void

訂閱通知并指定訂閱信息(callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
subscriber[NotificationSubscriber]通知訂閱對(duì)象。
info[NotificationSubscribeInfo]訂閱信息。
callbackAsyncCallback訂閱動(dòng)作回調(diào)函數(shù)。

示例:

//subscribe回調(diào)
function subscribeCallback(err) {
	console.info("========================== >subscribeCallback======================= >");
}
function onConsumeCallback(data) {
	console.info("========================== >onConsumeCallback======================= >");
}
var subscriber = {
    onConsume: onConsumeCallback
}
var info = {
    bundleNames: ["bundleName1","bundleName2"]
}
Notification.subscribe(subscriber, info, subscribeCallback);

Notification.subscribe

subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback): void

訂閱通知并指定訂閱信息(callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
subscriber[NotificationSubscriber]通知訂閱對(duì)象。
callbackAsyncCallback訂閱動(dòng)作回調(diào)函數(shù)。

示例:

function subscribeCallback(err) {
	console.info("========================== >subscribeCallback======================= >");
}
function onConsumeCallback(data) {
	console.info("========================== >onConsumeCallback======================= >");
}
var subscriber = {
    onConsume: onConsumeCallback
}
Notification.subscribe(subscriber, subscribeCallback);

Notification.subscribe

subscribe(subscriber: NotificationSubscriber, info?: NotificationSubscribeInfo): Promise

訂閱通知并指定訂閱信息(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
subscriber[NotificationSubscriber]通知訂閱對(duì)象。
info[NotificationSubscribeInfo]訂閱信息。

示例:

function onConsumeCallback(data) {
	console.info("========================== >onConsumeCallback======================= >");
}
var subscriber = {
    onConsume: onConsumeCallback
};
Notification.subscribe(subscriber).then(() = > {
	console.info("========================== >subscribeCallback======================= >");
});

Notification.unsubscribe

unsubscribe(subscriber: NotificationSubscriber, callback: AsyncCallback): void

取消訂閱(callbcak形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
subscriber[NotificationSubscriber]通知訂閱對(duì)象。
callbackAsyncCallback取消訂閱動(dòng)作回調(diào)函數(shù)。

示例:

function unsubscribeCallback(err) {
	console.info("========================== >unsubscribeCallback======================= >");
}
function onConsumeCallback(data) {
	console.info("========================== >onConsumeCallback======================= >");
}
var subscriber = {
    onConsume: onConsumeCallback
}
Notification.unsubscribe(subscriber, unsubscribeCallback);

Notification.unsubscribe

unsubscribe(subscriber: NotificationSubscriber): Promise

取消訂閱(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
subscriber[NotificationSubscriber]通知訂閱對(duì)象。

示例:

function onConsumeCallback(data) {
	console.info("========================== >onConsumeCallback======================= >");
}
var subscriber = {
    onConsume: onConsumeCallback
};
Notification.unsubscribe(subscriber).then(() = > {
	console.info("========================== >unsubscribeCallback======================= >");
});

Notification.enableNotification

enableNotification(bundle: BundleOption, enable: boolean, callback: AsyncCallback): void

設(shè)定指定包的通知使能狀態(tài)(Callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
bundle[BundleOption]指定包信息。
enableboolean使能狀態(tài)。
callbackAsyncCallback設(shè)定通知使能回調(diào)函數(shù)。

示例:

function enableNotificationCallback(err) {
	console.info("========================== >enableNotificationCallback======================= >");
}
var bundle = {
    bundle: "bundleName1",
}
Notification.enableNotification(bundle, false, enableNotificationCallback);

Notification.enableNotification

enableNotification(bundle: BundleOption, enable: boolean): Promise

設(shè)定指定包的通知使能狀態(tài)(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
bundle[BundleOption]指定包信息。
enableboolean使能狀態(tài)。

示例:

var bundle = {
    bundle: "bundleName1",
}
Notification.enableNotification(bundle, false).then(() = > {
	console.info("========================== >enableNotificationCallback======================= >");
});

Notification.isNotificationEnabled

isNotificationEnabled(bundle: BundleOption, callback: AsyncCallback): void

獲取指定包的通知使能狀態(tài)(Callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
bundle[BundleOption]指定包信息。
callbackAsyncCallback獲取通知使能狀態(tài)回調(diào)函數(shù)。

示例:

function isNotificationEnabledCallback(err, data) {
	console.info("========================== >isNotificationEnabledCallback======================= >");
}
var bundle = {
    bundle: "bundleName1",
}
Notification.isNotificationEnabled(bundle, isNotificationEnabledCallback);

Notification.isNotificationEnabled

isNotificationEnabled(bundle: BundleOption): Promise

獲取指定包的通知使能狀態(tài)(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
bundle[BundleOption]指定包信息。

返回值:

類型說(shuō)明
Promise以Promise形式返回獲取指定包的通知使能狀態(tài)的結(jié)果。

示例:

var bundle = {
    bundle: "bundleName1",
}
Notification.isNotificationEnabled(bundle).then((data) = > {
	console.info("========================== >isNotificationEnabledCallback======================= >");
});

Notification.isNotificationEnabled

isNotificationEnabled(callback: AsyncCallback): void

獲取通知使能狀態(tài)(Callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
callbackAsyncCallback獲取通知使能狀態(tài)回調(diào)函數(shù)。

示例:

function isNotificationEnabledCallback(err, data) {
	console.info("========================== >isNotificationEnabledCallback======================= >");
}

Notification.isNotificationEnabled(isNotificationEnabledCallback);

Notification.isNotificationEnabled

isNotificationEnabled(): Promise

獲取通知使能狀態(tài)(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
bundle[BundleOption]指定包信息。

返回值:

類型說(shuō)明
Promise以Promise形式返回獲取通知使能狀態(tài)的結(jié)果。

示例:

Notification.isNotificationEnabled().then((data) = > {
	console.info("========================== >isNotificationEnabledCallback======================= >");
});

Notification.displayBadge

displayBadge(bundle: BundleOption, enable: boolean, callback: AsyncCallback): void

設(shè)定指定包的角標(biāo)使能狀態(tài)(Callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
bundle[BundleOption]指定包信息。
enableboolean使能狀態(tài)。
callbackAsyncCallback設(shè)定角標(biāo)使能回調(diào)函數(shù)。

示例:

function displayBadgeCallback(err) {
	console.info("========================== >displayBadgeCallback======================= >");
}
var bundle = {
    bundle: "bundleName1",
}
Notification.displayBadge(bundle, false, displayBadgeCallback);

Notification.displayBadge

displayBadge(bundle: BundleOption, enable: boolean): Promise

設(shè)定指定包的角標(biāo)使能狀態(tài)(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
bundle[BundleOption]指定包信息。
enableboolean使能狀態(tài)。

示例:

var bundle = {
    bundle: "bundleName1",
}
Notification.displayBadge(bundle, false).then(() = > {
	console.info("========================== >displayBadgeCallback======================= >");
});

Notification.isBadgeDisplayed

isBadgeDisplayed(bundle: BundleOption, callback: AsyncCallback): void

獲取指定包的角標(biāo)使能狀態(tài)(Callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
bundle[BundleOption]指定包信息。
callbackAsyncCallback獲取角標(biāo)使能狀態(tài)回調(diào)函數(shù)。

示例:

function isBadgeDisplayedCallback(err, data) {
	console.info("========================== >isBadgeDisplayedCallback======================= >");
}
var bundle = {
    bundle: "bundleName1",
}
Notification.isBadgeDisplayed(bundle, isBadgeDisplayedCallback);

Notification.isBadgeDisplayed

isBadgeDisplayed(bundle: BundleOption): Promise

獲取指定包的角標(biāo)使能狀態(tài)(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
bundle[BundleOption]指定包信息。

返回值:

類型說(shuō)明
Promise以Promise形式返回獲取指定包的角標(biāo)使能狀態(tài)。

示例:

var bundle = {
    bundle: "bundleName1",
}
Notification.isBadgeDisplayed(bundle).then((data) = > {
	console.info("========================== >isBadgeDisplayedCallback======================= >");
});

Notification.setSlotByBundle

setSlotByBundle(bundle: BundleOption, slot: NotificationSlot, callback: AsyncCallback): void

設(shè)定指定包的通知通道狀態(tài)(Callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
bundle[BundleOption]指定包信息。
slot[NotificationSlot]通知通道。
callbackAsyncCallback設(shè)定通知通道回調(diào)函數(shù)。

示例:

function setSlotByBundleCallback(err) {
	console.info("========================== >setSlotByBundleCallback======================= >");
}
var bundle = {
    bundle: "bundleName1",
}
var notificationSlot = {
    type: Notification.SlotType.SOCIAL_COMMUNICATION
}
Notification.setSlotByBundle(bundle, notificationSlot, setSlotByBundleCallback);

Notification.setSlotByBundle

setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise

設(shè)定指定包的通知通道狀態(tài)(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
bundle[BundleOption]指定包信息。
slot[NotificationSlot]使能狀態(tài)。

示例:

var bundle = {
    bundle: "bundleName1",
}
var notificationSlot = {
    type: Notification.SlotType.SOCIAL_COMMUNICATION
}
Notification.setSlotByBundle(bundle, notificationSlot).then(() = > {
	console.info("========================== >setSlotByBundleCallback======================= >");
});

Notification.getSlotsByBundle

getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback>): void

獲取指定包的通知通道(Callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
bundle[BundleOption]指定包信息。
callbackAsyncCallback>獲取通知通道回調(diào)函數(shù)。

示例:

function getSlotsByBundleCallback(err, data) {
	console.info("========================== >getSlotsByBundleCallback======================= >");
}
var bundle = {
    bundle: "bundleName1",
}
Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback);

Notification.getSlotsByBundle

getSlotsByBundle(bundle: BundleOption): Promise>

獲取指定包的通知通道(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
bundle[BundleOption]指定包信息。

返回值:

類型說(shuō)明
Promise>以Promise形式返回獲取指定包的通知通道。

示例:

var bundle = {
    bundle: "bundleName1",
}
Notification.getSlotsByBundle(bundle).then((data) = > {
	console.info("========================== >getSlotsByBundleCallback======================= >");
});

Notification.getSlotNumByBundle

getSlotNumByBundle(bundle: BundleOption, callback: AsyncCallback): void

獲取指定包的通知通道數(shù)(Callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
bundle[BundleOption]指定包信息。
callbackAsyncCallback獲取通知通道數(shù)回調(diào)函數(shù)。

示例:

function getSlotNumByBundleCallback(err, data) {
	console.info("========================== >getSlotNumByBundleCallback======================= >");
}
var bundle = {
    bundle: "bundleName1",
}
Notification.getSlotNumByBundle(bundle, getSlotNumByBundleCallback);

Notification.getSlotNumByBundle

getSlotNumByBundle(bundle: BundleOption): Promise

獲取指定包的通知通道數(shù)(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
bundle[BundleOption]指定包信息。

返回值:

類型說(shuō)明
Promise以Promise形式返回獲取指定包的通知通道數(shù)。

示例:

var bundle = {
    bundle: "bundleName1",
}
Notification.getSlotNumByBundle(bundle).then((data) = > {
	console.info("========================== >getSlotNumByBundleCallback======================= >");
});

Notification.remove

remove(bundle: BundleOption, notificationKey: NotificationKey, callback: AsyncCallback): void

刪除指定通知(Callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
bundle[BundleOption]指定包信息。
notificationKey[NotificationKey]通知鍵值。
callbackAsyncCallback刪除指定通知回調(diào)函數(shù)。

示例:

function removeCallback(err) {
	console.info("========================== >removeCallback======================= >");
}
var bundle = {
    bundle: "bundleName1",
}
var notificationKey = {
    id: 0,
    label: "label",
}
Notification.remove(bundle, notificationKey, removeCallback);

Notification.remove

remove(bundle: BundleOption, notificationKey: NotificationKey): Promise

刪除指定通知(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
bundle[BundleOption]指定包信息。
notificationKey[NotificationKey]通知鍵值。

示例:

var bundle = {
    bundle: "bundleName1",
}
var notificationKey = {
    id: 0,
    label: "label",
}
Notification.remove(bundle, notificationKey).then(() = > {
	console.info("========================== >removeCallback======================= >");
});

Notification.remove

remove(hashCode: string, callback: AsyncCallback): void

刪除指定通知(Callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
hashCodestring通知唯一ID。
callbackAsyncCallback刪除指定通知回調(diào)函數(shù)。

示例:

var hashCode = 'hashCode'

function removeCallback(err) {
	console.info("========================== >removeCallback======================= >");
}

Notification.remove(hashCode, removeCallback);

Notification.remove

remove(hashCode: string): Promise

刪除指定通知(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
hashCodestring通知唯一ID。

示例:

var hashCode = 'hashCode'

Notification.remove(hashCode).then(() = > {
	console.info("========================== >removeCallback======================= >");
});

Notification.removeAll

removeAll(bundle: BundleOption, callback: AsyncCallback): void

刪除指定包的所有通知(Callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
bundle[BundleOption]指定包信息。
callbackAsyncCallback刪除指定包的所有通知回調(diào)函數(shù)。

示例:

function removeAllCallback(err) {
	console.info("========================== >removeAllCallback======================= >");
}
var bundle = {
    bundle: "bundleName1",
}
Notification.removeAll(bundle, removeAllCallback);

Notification.removeAll

removeAll(callback: AsyncCallback): void

刪除所有通知(Callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
callbackAsyncCallback刪除所有通知回調(diào)函數(shù)。

示例:

function removeAllCallback(err) {
	console.info("========================== >removeAllCallback======================= >");
}

Notification.removeAll(removeAllCallback);

Notification.removeAll

removeAll(bundle?: BundleOption): Promise

刪除所有通知(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
bundle[BundleOption]指定包信息。

示例:

Notification.removeAll().then(() = > {
	console.info("========================== >removeAllCallback======================= >");
});

Notification.removeAll8+

removeAll(userId: number, callback: AsyncCallback): void

刪除所有通知(callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
userIdnumber接收通知用戶的Id。
callbackAsyncCallback刪除所有通知回調(diào)函數(shù)。

示例:

function removeAllCallback(err) {
	console.info("========================== >removeAllCallback======================= >");
}

var userId = 1

Notification.removeAll(userId, removeAllCallback);

Notification.removeAll8+

removeAll(userId: number): Promise

刪除所有通知(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
userIdnumber接收通知用戶的Id。

示例:

function removeAllCallback(err) {
	console.info("========================== >removeAllCallback======================= >");
}

var userId = 1

Notification.removeAll(userId, removeAllCallback);

[](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Beta1/zh-cn/application-dev/reference/apis/js-apis-notification.md#notificationgetallactivenotifications)Notification.getAllActiveNotifications

getAllActiveNotifications(callback: AsyncCallback>): void

獲取活動(dòng)通知(Callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
callbackAsyncCallback>獲取活動(dòng)通知回調(diào)函數(shù)。

示例:

function getAllActiveNotificationsCallback(err, data) {
	console.info("========================== >getAllActiveNotificationsCallback======================= >");
}

Notification.getAllActiveNotifications(getAllActiveNotificationsCallback);

Notification.getAllActiveNotifications

getAllActiveNotifications(): Promise>

獲取活動(dòng)通知(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。removeGroupByBundle

返回值:

類型說(shuō)明
Promise>以Promise形式返回獲取活動(dòng)通知。

示例:

Notification.getAllActiveNotifications().then((data) = > {
	console.info("========================== >getAllActiveNotificationsCallback======================= >");
});

Notification.getActiveNotificationCount

getActiveNotificationCount(callback: AsyncCallback): void

獲取當(dāng)前應(yīng)用的活動(dòng)通知數(shù)(Callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

參數(shù):

名稱可讀可寫類型必填描述
callbackAsyncCallback獲取活動(dòng)通知數(shù)回調(diào)函數(shù)。

示例:

function getActiveNotificationCountCallback(err, data) {
	console.info("========================== >getActiveNotificationCountCallback======================= >");
}

Notification.getActiveNotificationCount(getActiveNotificationCountCallback);

Notification.getActiveNotificationCount

getActiveNotificationCount(): Promise

獲取當(dāng)前應(yīng)用的活動(dòng)通知數(shù)(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

返回值:

類型說(shuō)明
Promise以Promise形式返回獲取當(dāng)前應(yīng)用的活動(dòng)通知數(shù)。

示例:

Notification.getActiveNotificationCount().then((data) = > {
	console.info("========================== >getActiveNotificationCountCallback======================= >");
});

Notification.getActiveNotifications

getActiveNotifications(callback: AsyncCallback>): void

獲取當(dāng)前應(yīng)用的活動(dòng)通知(Callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

參數(shù):

名稱可讀可寫類型必填描述
callbackAsyncCallback>獲取當(dāng)前應(yīng)用的活動(dòng)通知回調(diào)函數(shù)。

示例:

function getActiveNotificationsCallback(err, data) {
	console.info("========================== >getActiveNotificationsCallback======================= >");
}

Notification.getActiveNotifications(getActiveNotificationsCallback);

Notification.getActiveNotifications

getActiveNotifications(): Promise>

獲取當(dāng)前應(yīng)用的活動(dòng)通知(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

返回值:

類型說(shuō)明
Promise>以Promise形式返回獲取當(dāng)前應(yīng)用的活動(dòng)通知。

示例:

Notification.getActiveNotifications().then((data) = > {
	console.info("========================== >getActiveNotificationsCallback======================= >");
});

Notification.cancelGroup8+

cancelGroup(groupName: string, callback: AsyncCallback): void

取消本應(yīng)用指定組通知(Callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

參數(shù):

名稱可讀可寫類型必填描述
groupNamestring指定通知組名稱。
callbackAsyncCallback取消本應(yīng)用指定組通知回調(diào)函數(shù)。

示例:

function cancelGroupCallback(err) {
   console.info("========================== >cancelGroupCallback======================= >");
}

var groupName = "GroupName";

Notification.cancelGroup(groupName, cancelGroupCallback);

Notification.cancelGroup8+

cancelGroup(groupName: string): Promise

取消本應(yīng)用指定組通知(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

參數(shù):

名稱可讀可寫類型必填描述
groupNamestring指定通知組名稱。

示例:

var groupName = "GroupName";
Notification.cancelGroup(groupName).then(() = > {
	console.info("========================== >cancelGroupPromise======================= >");
});

Notification.removeGroupByBundle8+

removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCallback): void

刪除指定應(yīng)用指定組通知(Callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
bundle[BundleOption]指定包信息。
groupNamestring指定通知組名稱。
callbackAsyncCallback刪除本應(yīng)用指定組通知回調(diào)函數(shù)。

示例:

function removeGroupByBundleCallback(err) {
   console.info("========================== >removeGroupByBundleCallback======================= >");
}

var bundleOption = {bundle: "Bundle"};
var groupName = "GroupName";

Notification.removeGroupByBundle(bundleOption, groupName, removeGroupByBundleCallback);

Notification.removeGroupByBundle8+

removeGroupByBundle(bundle: BundleOption, groupName: string): Promise

刪除指定應(yīng)用指定組通知(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
bundle[BundleOption]指定包信息。
groupNamestring指定通知組名稱。

示例:

var bundleOption = {bundle: "Bundle"};
var groupName = "GroupName";
Notification.removeGroupByBundle(bundleOption, groupName).then(() = > {
	console.info("========================== >removeGroupByBundlePromise======================= >");
});

Notification.setDoNotDisturbDate8+

setDoNotDisturbDate(date: DoNotDisturbDate, callback: AsyncCallback): void

設(shè)置免打擾時(shí)間(Callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
date[DoNotDisturbDate]免打擾時(shí)間選項(xiàng)。
callbackAsyncCallback設(shè)置免打擾時(shí)間回調(diào)函數(shù)。

示例:

function setDoNotDisturbDateCallback(err) {
   console.info("========================== >setDoNotDisturbDateCallback======================= >");
}

var doNotDisturbDate = {
    type: Notification.DoNotDisturbType.TYPE_ONCE,
    begin: new Date(),
    end: new Date(2021, 11, 15, 18, 0)
}

Notification.setDoNotDisturbDate(doNotDisturbDate, setDoNotDisturbDateCallback);

Notification.setDoNotDisturbDate8+

setDoNotDisturbDate(date: DoNotDisturbDate): Promise

設(shè)置免打擾時(shí)間接口(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
date[DoNotDisturbDate]免打擾時(shí)間選項(xiàng)。

示例:

var doNotDisturbDate = {
    type: Notification.DoNotDisturbType.TYPE_ONCE,
    begin: new Date(),
    end: new Date(2021, 11, 15, 18, 0)
}
Notification.setDoNotDisturbDate(doNotDisturbDate).then(() = > {
	console.info("========================== >setDoNotDisturbDatePromise======================= >");
});

Notification.setDoNotDisturbDate8+

setDoNotDisturbDate(date: DoNotDisturbDate, userId: number, callback: AsyncCallback): void

指定用戶設(shè)置免打擾時(shí)間(Callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
date[DoNotDisturbDate]免打擾時(shí)間選項(xiàng)。
userIdnumber設(shè)置免打擾事件的用戶ID。
callbackAsyncCallback設(shè)置免打擾時(shí)間回調(diào)函數(shù)。

示例:

function setDoNotDisturbDateCallback(err) {
   console.info("========================== >setDoNotDisturbDateCallback======================= >");
}

var doNotDisturbDate = {
    type: Notification.DoNotDisturbType.TYPE_ONCE,
    begin: new Date(),
    end: new Date(2021, 11, 15, 18, 0)
}

var userId = 1

Notification.setDoNotDisturbDate(doNotDisturbDate, userId, setDoNotDisturbDateCallback);

Notification.setDoNotDisturbDate8+

setDoNotDisturbDate(date: DoNotDisturbDate, userId: number): Promise

指定用戶設(shè)置免打擾時(shí)間接口(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
date[DoNotDisturbDate]免打擾時(shí)間選項(xiàng)。
userIdnumber設(shè)置免打擾事件的用戶ID。

示例:

var doNotDisturbDate = {
    type: Notification.DoNotDisturbType.TYPE_ONCE,
    begin: new Date(),
    end: new Date(2021, 11, 15, 18, 0)
}

var userId = 1

Notification.setDoNotDisturbDate(doNotDisturbDate, userId).then(() = > {
	console.info("========================== >setDoNotDisturbDatePromise======================= >");
});

Notification.getDoNotDisturbDate8+

getDoNotDisturbDate(callback: AsyncCallback): void

查詢免打擾時(shí)間接口(Callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
callbackAsyncCallback<[DoNotDisturbDate]>查詢免打擾時(shí)間回調(diào)函數(shù)。

示例:

function getDoNotDisturbDateCallback(err,data) {
   console.info("========================== >getDoNotDisturbDateCallback======================= >");
}

Notification.getDoNotDisturbDate(getDoNotDisturbDateCallback);

Notification.getDoNotDisturbDate8+

getDoNotDisturbDate(): Promise

查詢免打擾時(shí)間接口(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

返回值:

類型說(shuō)明
Promise<[DoNotDisturbDate]>以Promise形式返回獲取查詢免打擾時(shí)間接口。

示例:

Notification.getDoNotDisturbDate().then((data) = > {
	console.info("========================== >getDoNotDisturbDatePromise======================= >");
});

Notification.getDoNotDisturbDate8+

getDoNotDisturbDate(userId: number, callback: AsyncCallback): void

指定用戶查詢免打擾時(shí)間接口(Callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
callbackAsyncCallback<[DoNotDisturbDate]>查詢免打擾時(shí)間回調(diào)函數(shù)。
userIdnumber設(shè)置免打擾事件的用戶ID。

示例:

function getDoNotDisturbDateCallback(err,data) {
   console.info("========================== >getDoNotDisturbDateCallback======================= >");
}

var userId = 1

Notification.getDoNotDisturbDate(userId, getDoNotDisturbDateCallback);

Notification.getDoNotDisturbDate8+

getDoNotDisturbDate(userId: number): Promise

指定用戶查詢免打擾時(shí)間接口(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
userIdnumber設(shè)置免打擾事件的用戶ID。

返回值:

類型說(shuō)明
Promise<[DoNotDisturbDate]>以Promise形式返回獲取查詢免打擾時(shí)間接口。

示例:

var userId = 1

Notification.getDoNotDisturbDate(userId).then((data) = > {
	console.info("========================== >getDoNotDisturbDatePromise======================= >");
});

Notification.supportDoNotDisturbMode8+

supportDoNotDisturbMode(callback: AsyncCallback): void

查詢是否支持勿擾模式功能(Callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

名稱可讀可寫類型必填描述
callbackAsyncCallback查詢是否支持勿擾模式功能回調(diào)函數(shù)。

示例:

function supportDoNotDisturbModeCallback(err,data) {
   console.info("========================== >supportDoNotDisturbModeCallback======================= >");
}

Notification.supportDoNotDisturbMode(supportDoNotDisturbModeCallback);

Notification.supportDoNotDisturbMode8+

supportDoNotDisturbMode(): Promise

查詢是否支持勿擾模式功能(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

返回值:

類型說(shuō)明
Promise以Promise形式返回獲取是否支持勿擾模式功能的結(jié)果。

示例:

Notification.supportDoNotDisturbMode().then((data) = > {
	console.info("========================== >supportDoNotDisturbModePromise======================= >");
});

Notification.isSupportTemplate8+

isSupportTemplate(templateName: string, callback: AsyncCallback): void

查詢模板是否存在(Callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

參數(shù):

參數(shù)名類型必填說(shuō)明
templateNamestring模板名稱。
callbackAsyncCallback查詢模板是否存在的回調(diào)函數(shù)。

示例:

var templateName = 'process';
function isSupportTemplateCallback(err, data) {
    console.info("isSupportTemplateCallback");
}

Notification.isSupportTemplate(templateName, isSupportTemplateCallback);

Notification.isSupportTemplate8+

isSupportTemplate(templateName: string): Promise

查詢模板是否存在(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

參數(shù):

參數(shù)名類型必填說(shuō)明
templateNamestring模板名稱。

返回值:

類型說(shuō)明
PromisePromise方式返回模板是否存在的結(jié)果。

示例:

var templateName = 'process';

Notification.isSupportTemplate(templateName).then((data) = > {
    console.info("isSupportTemplateCallback");
});

Notification.requestEnableNotification8+

requestEnableNotification(callback: AsyncCallback): void

應(yīng)用請(qǐng)求通知使能(Callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

參數(shù):

參數(shù)名類型必填說(shuō)明
callbackAsyncCallback應(yīng)用請(qǐng)求通知使能的回調(diào)函數(shù)。

示例:

function requestEnableNotificationCallback() {
    console.log('------------- requestEnabledNotification --------------');
};

Notification.requestEnableNotification(requestEnableNotificationCallback);

Notification.requestEnableNotification8+

requestEnableNotification(): Promise

應(yīng)用請(qǐng)求通知使能(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

示例:

Notification.requestEnableNotification()
    .then(() = > {
        console.info("requestEnableNotification ");
	});

Notification.enableDistributed8+

enableDistributed(enable: boolean, callback: AsyncCallback): void

設(shè)置設(shè)備是否支持分布式通知(Callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

參數(shù)名類型必填說(shuō)明
enableboolean是否支持。 true 支持。 false 不支持。
callbackAsyncCallback設(shè)置設(shè)備是否支持分布式通知的回調(diào)函數(shù)。

示例:

function enabledNotificationCallback() {
    console.log('----------- enableDistributed ------------');
};

var enable = true

Notification.enableDistributed(enable, enabledNotificationCallback);

Notification.enableDistributed8+

enableDistributed(enable: boolean): Promise

設(shè)置設(shè)備是否支持分布式通知(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

參數(shù)名類型必填說(shuō)明
enableboolean是否支持。 true 支持。 false 不支持。

示例:

var enable = true

Notification.enableDistributed(enable)
    .then(() = > {
        console.log('-------- enableDistributed ----------');
    });

Notification.isDistributedEnabled8+

isDistributedEnabled(callback: AsyncCallback): void

獲取設(shè)備是否支持分布式通知(Callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

參數(shù):

參數(shù)名類型必填說(shuō)明
callbackAsyncCallback設(shè)備是否支持分布式通知的回調(diào)函數(shù)。

示例:

function isDistributedEnabledCallback() {
    console.log('----------- isDistributedEnabled ------------');
};

Notification.isDistributedEnabled(isDistributedEnabledCallback);

Notification.isDistributedEnabled8+

isDistributedEnabled(): Promise

獲取設(shè)備是否支持分布式通知(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

返回值:

類型說(shuō)明
PromisePromise方式返回設(shè)備是否支持分布式通知的結(jié)果。 true 支持。 false 不支持。

示例:

Notification.isDistributedEnabled()
    .then((data) = > {
        console.log('-------- isDistributedEnabled ----------');
    });

Notification.enableDistributedByBundle8+

enableDistributedByBundle(bundle: BundleOption, enable: boolean, callback: AsyncCallback): void

根據(jù)應(yīng)用的包設(shè)置應(yīng)用程序是否支持分布式通知(Callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

參數(shù)名類型必填說(shuō)明
bundle[BundleOption]應(yīng)用的包。
enableboolean是否支持。
callbackAsyncCallback應(yīng)用程序是否支持分布式通知的回調(diào)函數(shù)。

示例:

function enableDistributedByBundleCallback() {
    console.log('----------- enableDistributedByBundle ------------');
};

var bundle = {
    bundle: "bundleName1",
}

var enable = true

Notification.enableDistributedByBundle(bundle, enable, enableDistributedByBundleCallback);

Notification.enableDistributedByBundle8+

根據(jù)bundleenableDistributedByBundle(bundle: BundleOption, enable: boolean): Promise

根據(jù)應(yīng)用的包設(shè)置應(yīng)用程序是否支持分布式通知(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

參數(shù)名類型必填說(shuō)明
bundle[BundleOption]應(yīng)用的包。
enableboolean是否支持。

示例:

var bundle = {
    bundle: "bundleName1",
}

var enable = true

Notification.enableDistributedByBundle(bundle, enable)
    .then(() = > {
        console.log('-------- enableDistributedByBundle ----------');
    });

Notification.isDistributedEnabledByBundle8+

isDistributedEnabledByBundle(bundle: BundleOption, callback: AsyncCallback): void

根據(jù)應(yīng)用的包獲取應(yīng)用程序是否支持分布式通知(Callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

參數(shù)名類型必填說(shuō)明
bundle[BundleOption]應(yīng)用的包。
callbackAsyncCallback應(yīng)用程序是否支持分布式通知的回調(diào)函數(shù)。

示例:

function isDistributedEnabledByBundleCallback(data) {
    console.log('----------- isDistributedEnabledByBundle ------------', data);
};

var bundle = {
    bundle: "bundleName1",
}

Notification.isDistributedEnabledByBundle(bundle, isDistributedEnabledByBundleCallback);

Notification.isDistributedEnabledByBundle8+

isDistributedEnabledByBundle(bundle: BundleOption): Promise

根據(jù)應(yīng)用的包獲取應(yīng)用程序是否支持分布式通知(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

參數(shù)名類型必填說(shuō)明
bundle[BundleOption]應(yīng)用的包。

返回值:

類型說(shuō)明
PromisePromise方式返回應(yīng)用程序是否支持分布式通知的結(jié)果。 true 支持。 false 不支持。

示例:

var bundle = {
    bundle: "bundleName1",
}

Notification.isDistributedEnabledByBundle(bundle)
    .then((data) = > {
        console.log('-------- isDistributedEnabledByBundle ----------', data);
    });

Notification.getDeviceRemindType8+

getDeviceRemindType(callback: AsyncCallback): void

獲取通知的提醒方式(Callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

參數(shù)名類型必填說(shuō)明
callbackAsyncCallback<[DeviceRemindType]>獲取通知的提醒方式的回調(diào)函數(shù)。

示例:

function getDeviceRemindTypeCallback(data) {
    console.log('----------- getDeviceRemindType ------------', data);
};

Notification.getDeviceRemindType(getDeviceRemindTypeCallback);

Notification.getDeviceRemindType8+

getDeviceRemindType(): Promise

獲取通知的提醒方式(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

返回值:

類型說(shuō)明
Promise<[DeviceRemindType]>Promise方式返回通知的提醒方式的結(jié)果。

示例:

Notification.getDeviceRemindType()
    .then((data) = > {
        console.log('-------- getDeviceRemindType ----------', data);
    });

Notification.enableNotificationSlot9+

enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean, callback: AsyncCallback): void

設(shè)置是否啟用應(yīng)用通道(callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

參數(shù)名類型必填說(shuō)明
bundle[BundleOption]指定的應(yīng)用的包的信息。
type[SlotType]通知渠道類型,目前分為社交通信、服務(wù)提醒、內(nèi)容咨詢和其他類型。
enableboolean是否啟用的標(biāo)記。true為啟用;false為禁用。
callbackAsyncCallback獲取啟用應(yīng)用通道的回調(diào)函數(shù)。

示例:

var bundleOption = {
    bundle: 'bundle',
    uid: 1
};

var type = Notification.SlotType.SOCIAL_COMMUNICATION;

var enable = true;

function enableNotificationSlotCallback(data) {
    console.log('-------- enableNotificationSlotCallback ---------', data);
}

Notification.enableNotificationSlot(bundleOption, type, enable, enableNotificationSlotCallback);

Notification.enableNotificationSlot9+

enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean): Promise

設(shè)置是否啟用應(yīng)用通道(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

參數(shù)名類型必填說(shuō)明
bundle[BundleOption]指定的應(yīng)用的包的信息。
type[SlotType]通知渠道類型,目前分為社交通信、服務(wù)提醒、內(nèi)容咨詢和其他類型。
enableboolean是否啟用的標(biāo)記。true為啟用;false為禁用。

示例:

var bundleOption = {
    bundle: 'bundle',
    uid: 1
};

var type = Notification.SlotType.SOCIAL_COMMUNICATION;

var enable = true;

Notification.enableNotificationSlot(bundleOption, type, enable)
    .then((data) = > {
        console.log('-------- enableNotificationSlotCallback success ---------', data);
    })
    .catch((err) = > {
        console.log('-------- enableNotificationSlotCallback fail ---------', err);
    });

Notification.isNotificationSlotEnabled9+

isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncCallback): void

獲取應(yīng)用通道是否啟用的結(jié)果(callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

參數(shù)名類型必填說(shuō)明
bundle[BundleOption]指定的應(yīng)用的包的信息。
type[SlotType]通知渠道類型,目前分為社交通信、服務(wù)提醒、內(nèi)容咨詢和其他類型。
callbackAsyncCallback獲取啟用應(yīng)用通道的回調(diào)函數(shù)。

示例:

var bundleOption = {
    bundle: 'bundle',
    uid: 1
};

var type = Notification.SlotType.SOCIAL_COMMUNICATION;

function isNotificationSlotEnabledCallback(data) {
    console.log('------------ isNotificationSlotEnabledCallback ------------', data);
}

Notification.isNotificationSlotEnabled(bundleOption, type, isNotificationSlotEnabledCallback);

Notification.isNotificationSlotEnabled9+

isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise

獲取應(yīng)用通道是否啟用的結(jié)果(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

參數(shù)名類型必填說(shuō)明
bundle[BundleOption]指定的應(yīng)用的包的信息。
type[SlotType]通知渠道類型,目前分為社交通信、服務(wù)提醒、內(nèi)容咨詢和其他類型。

返回值:

類型說(shuō)明
Promise以Promise形式返回應(yīng)用通道是否啟用的結(jié)果。true為啟用;false為禁用。

示例:

var bundleOption = {
    bundle: 'bundle',
    uid: 1
};

var type = Notification.SlotType.SOCIAL_COMMUNICATION;

Notification.isNotificationSlotEnabled(bundleOption, type)
    .then((data) = > {
        console.log('------------ isNotificationSlotEnabledCallback success ------------', data);
    })
    .catch((err) = > {
        console.log('------------ isNotificationSlotEnabledCallback fail ------------', err);
    });

Notification.publishAsBundle9+

publishAsBundle(request: NotificationRequest, representativeBundle: string, userId: number, callback: AsyncCallback): void

發(fā)布代理通知(callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER,ohos.permission.NOTIFICATION_AGENT_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

參數(shù)名類型必填說(shuō)明
request[NotificationRequest]設(shè)置要發(fā)布通知內(nèi)容的NotificationRequest對(duì)象。
representativeBundlestring被代理應(yīng)用的包名。
userIdnumber接收通知用戶的Id。
callbackAsyncCallback發(fā)布代理通知的回調(diào)方法。

示例:

//publishAsBundle回調(diào)
function publishAsBundleCallback(err) {
	console.info("========================== >publishAsBundleCallback======================= >");
}
// 被代理應(yīng)用的包名
let representativeBundle = "com.example.demo"
// 接收通知的用戶ID
let userId = 100
//通知Request對(duì)象
let notificationRequest = {
    id: 1,
    content: {
        contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
        normal: {
            title: "test_title",
            text: "test_text",
            additionalText: "test_additionalText"
        }
    }
}

Notification.publishAsBundle(notificationRequest, representativeBundle, userId, publishAsBundleCallback);

Notification.publishAsBundle9+

publishAsBundle(request: NotificationRequest, representativeBundle: string, userId: number): Promise

發(fā)布代理通知(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER,ohos.permission.NOTIFICATION_AGENT_CONTROLLER

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

參數(shù)名類型必填說(shuō)明
request[NotificationRequest]設(shè)置要發(fā)布通知內(nèi)容的NotificationRequest對(duì)象。
representativeBundlestring被代理應(yīng)用的包名。
userIdnumber接收通知用戶的Id。

示例:

// 被代理應(yīng)用的包名
let representativeBundle = "com.example.demo"
// 接收通知的用戶ID
let userId = 100
//通知Request對(duì)象
var notificationRequest = {
    id: 1,
    content: {
        contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
        normal: {
            title: "test_title",
            text: "test_text",
            additionalText: "test_additionalText"
        }
    }
}

Notification.publishAsBundle(notificationRequest, representativeBundle, userId).then(() = > {
	console.info("========================== >publishAsBundleCallback======================= >");
});

Notification.cancelAsBundle9+

cancelAsBundle(id: number, representativeBundle: string, userId: number, callback: AsyncCallback): void

取消代理通知(callback形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER,ohos.permission.NOTIFICATION_AGENT_CONTROLLER

參數(shù):

參數(shù)名類型必填說(shuō)明
idnumber通知ID。
representativeBundlestring被代理應(yīng)用的包名。
userIdnumber接收通知用戶的Id。
callbackAsyncCallback取消代理通知的回調(diào)方法。

示例:

//cancelAsBundle
function cancelAsBundleCallback(err) {
	console.info("========================== >cancelAsBundleCallback======================= >");
}
// 被代理應(yīng)用的包名
let representativeBundle = "com.example.demo"
// 接收通知的用戶ID
let userId = 100

Notification.cancelAsBundle(0, representativeBundle, userId, cancelAsBundleCallback);

Notification.cancelAsBundle9+

cancelAsBundle(id: number, representativeBundle: string, userId: number): Promise

發(fā)布代理通知(Promise形式)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

需要權(quán)限 : ohos.permission.NOTIFICATION_CONTROLLER,ohos.permission.NOTIFICATION_AGENT_CONTROLLER

參數(shù):

參數(shù)名類型必填說(shuō)明
idnumber通知ID。
representativeBundlestring被代理應(yīng)用的包名。
userIdnumber接收通知用戶的Id。

示例:

// 被代理應(yīng)用的包名
let representativeBundle = "com.example.demo"
// 接收通知的用戶ID
let userId = 100

Notification.cancelAsBundle(0, representativeBundle, userId).then(() = > {
	console.info("========================== >cancelAsBundleCallback======================= >");
});

NotificationSubscriber

onConsume

onConsume?: (data: [SubscribeCallbackData]) => void

接收通知回調(diào)函數(shù)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

參數(shù)名類型必填說(shuō)明
dataAsyncCallback<[SubscribeCallbackData]>回調(diào)返回接收到的通知信息。

示例:

function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};

function onConsumeCallback(data) {
    console.info('=== > onConsume in test');
    let req = data.request;
    console.info('=== > onConsume callback req.id:' + req.id);
    let wantAgent = data.wantAgent;
    wantAgent .getWant(wantAgent)
        .then((data1) = > {
            console.log('=== > getWant success want:' + JSON.stringify(data1));
        })
        .catch((err) = > {
            console.error('=== > getWant failed because' + JSON.stringify(err));
        });
    console.info('=== > onConsume callback req.wantAgent:' + JSON.stringify(req.wantAgent));
};

var subscriber = {
    onConsume: onConsumeCallback
};

Notification.subscribe(subscriber, subscribeCallback);

onCancel

onCancel?:(data: [SubscribeCallbackData]) => void

刪除通知回調(diào)函數(shù)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

參數(shù)名類型必填說(shuō)明
dataAsyncCallback<[SubscribeCallbackData]>回調(diào)返回接收到的通知信息。

示例:

function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};

function onCancelCallback(data) {
    console.info('=== > onCancel in test');
    let req = data.request;
    console.info('=== > onCancel callback req.id:' + req.id);
}

var subscriber = {
    onCancel: onCancelCallback
};

Notification.subscribe(subscriber, subscribeCallback);

onUpdate

onUpdate?:(data: [NotificationSortingMap]) => void

更新通知排序回調(diào)函數(shù)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

參數(shù)名類型必填說(shuō)明
data[NotificationSortingMap]回調(diào)返回接收到的通知信息。

示例:

function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};

function onUpdateCallback() {
    console.info('=== > onUpdate in test');
}

var subscriber = {
    onUpdate: onUpdateCallback
};

Notification.subscribe(subscriber, subscribeCallback);

onConnect

onConnect?:() => void

注冊(cè)訂閱回調(diào)函數(shù)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

示例:

function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};

function onConnectCallback() {
    console.info('=== > onConnect in test');
}

var subscriber = {
    onConnect: onConnectCallback
};

Notification.subscribe(subscriber, subscribeCallback);

onDisconnect

onDisconnect?:() => void

取消訂閱回調(diào)函數(shù)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

示例:

function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};

function onDisconnectCallback() {
    console.info('=== > onDisconnect in test');
}

var subscriber = {
    onDisconnect: onDisconnectCallback
};

Notification.subscribe(subscriber, subscribeCallback);

onDestroy

onDestroy?:() => void

服務(wù)失聯(lián)回調(diào)函數(shù)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

示例:

function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};

function onDestroyCallback() {
    console.info('=== > onDestroy in test');
}

var subscriber = {
    onDestroy: onDestroyCallback
};

Notification.subscribe(subscriber, subscribeCallback);

onDoNotDisturbDateChange8+

onDoNotDisturbDateChange?:(mode: notification.[DoNotDisturbDate]) => void

免打擾時(shí)間選項(xiàng)變更回調(diào)函數(shù)。

系統(tǒng)能力 :SystemCapability.Notification.Notification

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

參數(shù)名類型必填說(shuō)明
modenotification.[DoNotDisturbDate]回調(diào)返回免打擾時(shí)間選項(xiàng)變更。

示例:

function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};

function onDoNotDisturbDateChangeCallback() {
    console.info('=== > onDoNotDisturbDateChange in test');
}

var subscriber = {
    onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback
};

Notification.subscribe(subscriber, subscribeCallback);

onEnabledNotificationChanged8+

onEnabledNotificationChanged?:(callbackData: [EnabledNotificationCallbackData]) => void

監(jiān)聽(tīng)?wèi)?yīng)用通知使能變化。

系統(tǒng)能力 :SystemCapability.Notification.Notification

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

參數(shù):

參數(shù)名類型必填說(shuō)明
callbackAsyncCallback<[EnabledNotificationCallbackData]>回調(diào)返回監(jiān)聽(tīng)到的應(yīng)用信息。

示例:

function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};

function onEnabledNotificationChangedCallback(callbackData) {
    console.info("bundle: ", callbackData.bundle);
    console.info("uid: ", callbackData.uid);
    console.info("enable: ", callbackData.enable);
};

var subscriber = {
    onEnabledNotificationChanged: onEnabledNotificationChangedCallback
};

Notification.subscribe(subscriber, subscribeCallback);

SubscribeCallbackData

系統(tǒng)能力 :以下各項(xiàng)對(duì)應(yīng)的系統(tǒng)能力均為SystemCapability.Notification.Notification

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

名稱可讀可寫類型必填描述
request[NotificationRequest]通知內(nèi)容。
sortingMap[NotificationSortingMap]排序信息。
reasonnumber刪除原因。
soundstring通知聲音。
viationValuesArray通知震動(dòng)。

EnabledNotificationCallbackData8+

系統(tǒng)能力 :以下各項(xiàng)對(duì)應(yīng)的系統(tǒng)能力均為SystemCapability.Notification.Notification

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

名稱可讀可寫類型必填描述
bundlestring應(yīng)用的包名。
uidnumber應(yīng)用的uid。
enableboolean應(yīng)用通知使能狀態(tài)。

DoNotDisturbDate8+

系統(tǒng)能力 :以下各項(xiàng)對(duì)應(yīng)的系統(tǒng)能力均為SystemCapability.Notification.Notification

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

名稱可讀可寫類型描述
type[DoNotDisturbType]指定免打擾設(shè)置的時(shí)間類型。
beginDate指定免打擾設(shè)置的起點(diǎn)時(shí)間。
endDate指定免打擾設(shè)置的終點(diǎn)時(shí)間。

DoNotDisturbType8+

系統(tǒng)能力 :以下各項(xiàng)對(duì)應(yīng)的系統(tǒng)能力均為SystemCapability.Notification.Notification

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

名稱說(shuō)明
TYPE_NONEDoNotDisturbType非通知勿擾類型。
TYPE_ONCEDoNotDisturbType以設(shè)置時(shí)間段(只看小時(shí)和分鐘)一次執(zhí)行勿擾。
TYPE_DAILYDoNotDisturbType以設(shè)置時(shí)間段(只看小時(shí)和分鐘)每天執(zhí)行勿擾。
TYPE_CLEARLYDoNotDisturbType以設(shè)置時(shí)間段(明確年月日時(shí)分)執(zhí)行勿擾。

ContentType

系統(tǒng)能力 :以下各項(xiàng)對(duì)應(yīng)的系統(tǒng)能力均為SystemCapability.Notification.Notification

名稱說(shuō)明
NOTIFICATION_CONTENT_BASIC_TEXTContentType普通類型通知。
NOTIFICATION_CONTENT_LONG_TEXTContentType長(zhǎng)文本類型通知。
NOTIFICATION_CONTENT_PICTUREContentType圖片類型通知。
NOTIFICATION_CONTENT_CONVERSATIONContentType社交類型通知。
NOTIFICATION_CONTENT_MULTILINEContentType多行文本類型通知。

SlotLevel

系統(tǒng)能力 :以下各項(xiàng)對(duì)應(yīng)的系統(tǒng)能力均為SystemCapability.Notification.Notification

名稱說(shuō)明
LEVEL_NONE0表示關(guān)閉通知功能。
LEVEL_MIN1表示通知功能已啟用,但狀態(tài)欄中不顯示通知圖標(biāo),且沒(méi)有橫幅或提示音。
LEVEL_LOW2表示通知功能已啟用,且狀態(tài)欄中顯示通知圖標(biāo),但沒(méi)有橫幅或提示音。
LEVEL_DEFAULT3表示通知功能已啟用,狀態(tài)欄中顯示通知圖標(biāo),沒(méi)有橫幅但有提示音。
LEVEL_HIGH4表示通知功能已啟用,狀態(tài)欄中顯示通知圖標(biāo),有橫幅和提示音。

BundleOption

系統(tǒng)能力 :以下各項(xiàng)對(duì)應(yīng)的系統(tǒng)能力均為SystemCapability.Notification.Notification

名稱可讀可寫類型必填描述
bundlestring包名。
uidnumber用戶id。

NotificationKey

系統(tǒng)能力 :以下各項(xiàng)對(duì)應(yīng)的系統(tǒng)能力均為SystemCapability.Notification.Notification

名稱可讀可寫類型必填描述
idnumber通知ID。
labelstring通知標(biāo)簽。

SlotType

系統(tǒng)能力 :以下各項(xiàng)對(duì)應(yīng)的系統(tǒng)能力均為SystemCapability.Notification.Notification

名稱說(shuō)明
UNKNOWN_TYPESlotType未知類型。
SOCIAL_COMMUNICATIONSlotType社交類型。
SERVICE_INFORMATIONSlotType服務(wù)類型。
CONTENT_INFORMATIONSlotType內(nèi)容類型。
OTHER_TYPESSlotType其他類型。

NotificationActionButton

系統(tǒng)能力 :以下各項(xiàng)對(duì)應(yīng)的系統(tǒng)能力均為SystemCapability.Notification.Notification

名稱可讀可寫類型必填描述
titlestring按鈕標(biāo)題。
wantAgentWantAgent點(diǎn)擊按鈕時(shí)觸發(fā)的WantAgent。
extras{ [key: string]: any }按鈕擴(kuò)展信息。
userInput8+[NotificationUserInput]用戶輸入對(duì)象實(shí)例。

NotificationBasicContent

系統(tǒng)能力 :以下各項(xiàng)對(duì)應(yīng)的系統(tǒng)能力均為SystemCapability.Notification.Notification

名稱可讀可寫類型必填描述
titlestring通知標(biāo)題。
textstring通知內(nèi)容。
additionalTextstring通知次要內(nèi)容,是對(duì)通知內(nèi)容的補(bǔ)充。

NotificationLongTextContent

系統(tǒng)能力 :以下各項(xiàng)對(duì)應(yīng)的系統(tǒng)能力均為SystemCapability.Notification.Notification

名稱可讀可寫類型必填描述
titlestring通知標(biāo)題。
textstring通知內(nèi)容。
additionalTextstring通知次要內(nèi)容,是對(duì)通知內(nèi)容的補(bǔ)充。
longTextstring通知的長(zhǎng)文本。
iefTextstring通知概要內(nèi)容,是對(duì)通知內(nèi)容的總結(jié)。
expandedTitlestring通知展開(kāi)時(shí)的標(biāo)題。

NotificationMultiLineContent

系統(tǒng)能力 :以下各項(xiàng)對(duì)應(yīng)的系統(tǒng)能力均為SystemCapability.Notification.Notification

名稱可讀可寫類型必填描述
titlestring通知標(biāo)題。
textstring通知內(nèi)容。
additionalTextstring通知次要內(nèi)容,是對(duì)通知內(nèi)容的補(bǔ)充。
iefTextstring通知概要內(nèi)容,是對(duì)通知內(nèi)容的總結(jié)。
longTitlestring通知展開(kāi)時(shí)的標(biāo)題。
linesArray通知的多行文本。

NotificationPictureContent

系統(tǒng)能力 :以下各項(xiàng)對(duì)應(yīng)的系統(tǒng)能力均為SystemCapability.Notification.Notification

名稱可讀可寫類型必填描述
titlestring通知標(biāo)題。
textstring通知內(nèi)容。
additionalTextstring通知次要內(nèi)容,是對(duì)通知內(nèi)容的補(bǔ)充。
iefTextstring通知概要內(nèi)容,是對(duì)通知內(nèi)容的總結(jié)。
expandedTitlestring通知展開(kāi)時(shí)的標(biāo)題。
pictureimage.PixelMap通知的圖片內(nèi)容。

NotificationContent

系統(tǒng)能力 :以下各項(xiàng)對(duì)應(yīng)的系統(tǒng)能力均為SystemCapability.Notification.Notification

名稱可讀可寫類型必填描述
contentType[ContentType]通知內(nèi)容類型。
normal[NotificationBasicContent]基本類型通知內(nèi)容。
longText[NotificationLongTextContent]長(zhǎng)文本類型通知內(nèi)容。
multiLine[NotificationMultiLineContent]多行類型通知內(nèi)容。
picture[NotificationPictureContent]圖片類型通知內(nèi)容。

NotificationFlagStatus8+

系統(tǒng)能力 :以下各項(xiàng)對(duì)應(yīng)的系統(tǒng)能力均為SystemCapability.Notification.Notification

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

名稱描述
TYPE_NONE0默認(rèn)標(biāo)志。
TYPE_OPEN1通知標(biāo)志打開(kāi)。
TYPE_CLOSE2通知標(biāo)志關(guān)閉。

NotificationFlags8+

系統(tǒng)能力 :以下各項(xiàng)對(duì)應(yīng)的系統(tǒng)能力均為SystemCapability.Notification.Notification

名稱可讀可寫類型必填描述
soundEnabledNotificationFlagStatus是否啟用聲音提示。
viationEnabledNotificationFlagStatus是否啟用振動(dòng)提醒功能。

NotificationRequest

系統(tǒng)能力 :以下各項(xiàng)對(duì)應(yīng)的系統(tǒng)能力均為SystemCapability.Notification.Notification

名稱可讀可寫類型必填描述
content[NotificationContent]通知內(nèi)容。
idnumber通知ID。
slotType[SlotType]通道類型。
isOngoingboolean是否進(jìn)行時(shí)通知。
isUnremovableboolean是否可移除。
deliveryTimenumber通知發(fā)送時(shí)間。
tapDismissedboolean通知是否自動(dòng)清除。
autoDeletedTimenumber自動(dòng)清除的時(shí)間。
wantAgentWantAgent點(diǎn)擊跳轉(zhuǎn)的WantAgent。
extraInfo{[key: string]: any}擴(kuò)展參數(shù)。
colornumber通知背景顏色。
colorEnabledboolean通知背景顏色是否使能。
isAlertOnceboolean設(shè)置是否僅有一次此通知警報(bào)。
isStopwatchboolean是否顯示已用時(shí)間。
isCountDownboolean是否顯示倒計(jì)時(shí)時(shí)間。
isFloatingIconboolean是否顯示狀態(tài)欄圖標(biāo)。
labelstring通知標(biāo)簽。
badgeIconStylenumber通知角標(biāo)類型。
showDeliveryTimeboolean是否顯示分發(fā)時(shí)間。
actionButtonsArray<[NotificationActionButton]>通知按鈕,最多兩個(gè)按鈕。
smallIconPixelMap通知小圖標(biāo)。
largeIconPixelMap通知大圖標(biāo)。
creatorBundleNamestring創(chuàng)建通知的包名。
creatorUidnumber創(chuàng)建通知的UID。
creatorPidnumber創(chuàng)建通知的PID。
creatorUserId8+number創(chuàng)建通知的UserId。
hashCodestring通知唯一標(biāo)識(shí)。
classificationstring通知分類。 系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。
groupName8+string組通知名稱。
template8+[NotificationTemplate]通知模板。
isRemoveAllowed8+boolean通知是否能被移除。 系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。
source8+number通知源。 系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。
distributedOption8+[DistributedOptions]分布式通知的選項(xiàng)。
deviceId8+string通知源的deviceId。 系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。
notificationFlags8+[NotificationFlags]獲取NotificationFlags。

DistributedOptions8+

系統(tǒng)能力 :以下各項(xiàng)對(duì)應(yīng)的系統(tǒng)能力均為SystemCapability.Notification.Notification

名稱可讀可寫類型必填描述
isDistributedboolean是否為分布式通知。
supportDisplayDevicesArray可以同步通知到的設(shè)備類型。
supportOperateDevicesArray可以打開(kāi)通知的設(shè)備。
remindTypenumber通知的提醒方式。 系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

NotificationSlot

系統(tǒng)能力 :以下各項(xiàng)對(duì)應(yīng)的系統(tǒng)能力均為SystemCapability.Notification.Notification

名稱可讀可寫類型必填描述
typeSlotType通道類型。
levelnumber通知級(jí)別,不設(shè)置則根據(jù)通知渠道類型有默認(rèn)值。
descstring通知渠道描述信息。
badgeFlagboolean是否顯示角標(biāo)。
bypassDndboolean置是否在系統(tǒng)中繞過(guò)免打擾模式。
lockscreenVisibilityboolean在鎖定屏幕上顯示通知的模式。
viationEnabledboolean是否可振動(dòng)。
soundstring通知提示音。
lightEnabledboolean是否閃燈。
lightColornumber通知燈顏色。
viationValuesArray通知振動(dòng)樣式。
enabled9+boolean此通知插槽中的啟停狀態(tài)。

NotificationSorting

系統(tǒng)能力 :以下各項(xiàng)對(duì)應(yīng)的系統(tǒng)能力均為SystemCapability.Notification.Notification

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

名稱可讀可寫類型必填描述
slot[NotificationSlot]通知通道內(nèi)容。
hashCodestring通知唯一標(biāo)識(shí)。
rankingnumber通知排序序號(hào)。

NotificationSortingMap

系統(tǒng)能力 :以下各項(xiàng)對(duì)應(yīng)的系統(tǒng)能力均為SystemCapability.Notification.Notification

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

名稱可讀可寫類型必填描述
sortings{[key: string]: [NotificationSorting]}通知排序信息數(shù)組。
sortedHashCodeArray通知唯一標(biāo)識(shí)數(shù)組。

NotificationSubscribeInfo

系統(tǒng)能力 :以下各項(xiàng)對(duì)應(yīng)的系統(tǒng)能力均為SystemCapability.Notification.Notification

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

名稱可讀可寫類型必填描述
bundleNamesArray指定訂閱哪些包名的APP發(fā)來(lái)的通知。
userIdnumber指定訂閱哪個(gè)用戶下發(fā)來(lái)的通知。

NotificationTemplate8+

系統(tǒng)能力 :以下各項(xiàng)對(duì)應(yīng)的系統(tǒng)能力均為SystemCapability.Notification.Notification

名稱參數(shù)類型可讀可寫說(shuō)明
namestring模板名稱。
data{[key:string]: Object}模板數(shù)據(jù)。

NotificationUserInput8+

系統(tǒng)能力 :SystemCapability.Notification.Notification

名稱可讀可寫類型必填描述
inputKeystring用戶輸入時(shí)用于標(biāo)識(shí)此輸入的key。

DeviceRemindType8+

系統(tǒng)能力 :SystemCapability.Notification.Notification

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

名稱描述
IDLE_DONOT_REMIND0設(shè)備未被使用,無(wú)需提醒。
IDLE_REMIND1提醒設(shè)備未被使用。
ACTIVE_DONOT_REMIND2設(shè)備正在使用,無(wú)需提醒。
ACTIVE_REMIND3提醒設(shè)備正在使用。

SourceType8+

系統(tǒng)能力 :SystemCapability.Notification.Notification

系統(tǒng)API : 此接口為系統(tǒng)接口,三方應(yīng)用不支持調(diào)用。

搜狗高速瀏覽器截圖20240326151450.png

名稱HarmonyOS與OpenHarmony鴻蒙文檔籽料:mau123789是v直接拿描述
TYPE_NORMAL0一般通知。
TYPE_CONTINUOUS1連續(xù)通知。
TYPE_TIMER2計(jì)劃通知。

審核編輯 黃宇

聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點(diǎn)僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場(chǎng)。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問(wèn)題,請(qǐng)聯(lián)系本站處理。 舉報(bào)投訴
  • 接口
    +關(guān)注

    關(guān)注

    33

    文章

    9519

    瀏覽量

    157020
  • 鴻蒙
    +關(guān)注

    關(guān)注

    60

    文章

    2963

    瀏覽量

    45883
收藏 人收藏
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

    評(píng)論

    相關(guān)推薦
    熱點(diǎn)推薦

    鴻蒙開(kāi)發(fā)接口公共事件與通知:【@ohos.commonEvent (公共事模塊)】

    模塊首批接口從API version 7開(kāi)始支持。后續(xù)版本的新增接口,采用上角標(biāo)單獨(dú)標(biāo)記接口的起始版本。
    的頭像 發(fā)表于 05-21 11:13 ?2478次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>開(kāi)發(fā)</b><b class='flag-5'>接口</b><b class='flag-5'>公共事</b>件與<b class='flag-5'>通知</b>:【@ohos.commonEvent (<b class='flag-5'>公共事</b>件<b class='flag-5'>模塊</b>)】

    鴻蒙開(kāi)發(fā)接口公共事件與通知:【@ohos.events.emitter (Emitter)】

    模塊首批接口從API version 7開(kāi)始支持。
    的頭像 發(fā)表于 05-21 16:06 ?2347次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>開(kāi)發(fā)</b><b class='flag-5'>接口</b><b class='flag-5'>公共事</b>件與<b class='flag-5'>通知</b>:【@ohos.events.emitter (Emitter)】

    鴻蒙開(kāi)發(fā)接口公共事件與通知:【@ohos.reminderAgent (后臺(tái)代理提醒)】

    開(kāi)發(fā)應(yīng)用時(shí),開(kāi)發(fā)者可以調(diào)用后臺(tái)提醒發(fā)布的接口創(chuàng)建定時(shí)提醒,包括倒計(jì)時(shí)、日歷、鬧鐘三種提醒類型。使用后臺(tái)代理提醒能力后,應(yīng)用可以被凍結(jié)或退出,計(jì)時(shí)和彈出提醒的功能將被后臺(tái)系統(tǒng)服務(wù)代理。
    的頭像 發(fā)表于 05-25 16:27 ?1953次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>開(kāi)發(fā)</b><b class='flag-5'>接口</b><b class='flag-5'>公共事</b>件與<b class='flag-5'>通知</b>:【@ohos.reminderAgent (后臺(tái)代理提醒)】

    鴻蒙開(kāi)發(fā)接口公共事件與通知:【application/EventHub (EventHub)】

    EventHub模塊提供了事件中心,提供訂閱、取消訂閱、觸發(fā)事件的能力。
    的頭像 發(fā)表于 05-25 16:31 ?2061次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>開(kāi)發(fā)</b><b class='flag-5'>接口</b><b class='flag-5'>公共事</b>件與<b class='flag-5'>通知</b>:【application/EventHub (EventHub)】

    鴻蒙原生應(yīng)用/元服務(wù)開(kāi)發(fā)-通知添加行為意圖

    WantAgent提供了封裝行為意圖的能力,這里所說(shuō)的行為意圖主要是指拉起指定的應(yīng)用組件及發(fā)布公共事件等能力。HarmonyOS支持以通知的形式,將WantAgent從發(fā)布方傳遞至接收方,從而在接收
    發(fā)表于 01-05 15:07

    基于ArkTS語(yǔ)言的OpenHarmony APP應(yīng)用開(kāi)發(fā)公共事件的訂閱和發(fā)布

    /d05_CustomCommonEvent API接口:9 2、知識(shí)準(zhǔn)備 2.1、commonEvent模塊 OpenHarmony通過(guò)CES(Common Event Service,公共事件服務(wù))為
    發(fā)表于 09-18 13:16

    HarmonyOS NEXT應(yīng)用開(kāi)發(fā)-Notification Kit(用戶通知服務(wù))notificationManager.cancel

    , callback: AsyncCallback): void 通過(guò)通知ID和通知標(biāo)簽取消已發(fā)布的通知。使用callback異步回調(diào)。 系統(tǒng)能力
    發(fā)表于 04-29 17:40

    HarmonyOS NEXT應(yīng)用開(kāi)發(fā)-Notification Kit(用戶通知服務(wù))更多系統(tǒng)能力

    = _NotificationActionButton 描述通知中顯示的操作按鈕。 系統(tǒng)能力: SystemCapability.Notification.Notification 類型 說(shuō)明
    發(fā)表于 06-04 15:43

    HarmonyOS NEXT應(yīng)用開(kāi)發(fā)-Notification Kit(用戶通知服務(wù))通知類型、級(jí)別與渠道

    1. ContentType 支持設(shè)備Phone2in1TabletCarWearable 通知內(nèi)容類型。 元服務(wù)API: 從API version 12開(kāi)始,該接口支持在元服務(wù)中使用。 系統(tǒng)能力
    發(fā)表于 06-09 14:39

    HarmonyOS NEXT應(yīng)用開(kāi)發(fā)-Notification Kit(用戶通知服務(wù))概述與notificationManager.publish

    一、概述 本模塊提供通知管理的能力,包括發(fā)布、取消發(fā)布通知,創(chuàng)建、獲取、移除通知渠道,獲取通知的使能狀態(tài)、角標(biāo)使能狀態(tài),獲取
    發(fā)表于 06-13 15:38

    HarmonyOS應(yīng)用開(kāi)發(fā)-公共事件處理

    開(kāi)發(fā)過(guò)程中service想要控制多個(gè)ability時(shí),可以考慮使用公共事件處理。發(fā)布無(wú)序的公共事件: //發(fā)布公共事件 同步修改卡片與頁(yè)面public void subscribeE
    發(fā)表于 11-02 15:15

    鴻蒙開(kāi)發(fā)接口Ability框架:【@ohos.ability.wantConstant (wantConstant)】

    wantConstant模塊提供want中action和entity的權(quán)限列表的能力,包括系統(tǒng)公共事件宏,系統(tǒng)公共事件名稱等。
    的頭像 發(fā)表于 04-30 16:33 ?1361次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>開(kāi)發(fā)</b><b class='flag-5'>接口</b>Ability框架:【@ohos.ability.wantConstant (wantConstant)】

    鴻蒙開(kāi)發(fā)接口公共事件與通知:【FFI能力(Node-API)】

    Node-API是封裝底層JavaScript運(yùn)行時(shí)能力的一套Native接口。OpenHarmony的N-API組件對(duì)Node-API的接口進(jìn)行了重新實(shí)現(xiàn),ArkUI-X同樣擁有這部分能力,目前支持部分接口,支持列表。
    的頭像 發(fā)表于 05-21 16:38 ?1874次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>開(kāi)發(fā)</b><b class='flag-5'>接口</b><b class='flag-5'>公共事</b>件與<b class='flag-5'>通知</b>:【FFI能力(Node-API)】

    鴻蒙語(yǔ)言基礎(chǔ)類庫(kù):system.notification 通知消息

    以下各項(xiàng)對(duì)應(yīng)的系統(tǒng)能力均為SystemCapability.Notification.Notification
    的頭像 發(fā)表于 07-18 09:23 ?961次閱讀

    基于ArkTS語(yǔ)言的OpenHarmony APP應(yīng)用開(kāi)發(fā)公共事件的訂閱和發(fā)布

    1、程序介紹本示例主要展示了公共事件相關(guān)的功能,實(shí)現(xiàn)了一個(gè)檢測(cè)用戶部分行為的應(yīng)用。具體而言,本案例實(shí)現(xiàn)了如下幾個(gè)公共事件功能:通過(guò)訂閱系統(tǒng)公共事件,實(shí)現(xiàn)對(duì)用戶操作行為(亮滅屏、斷聯(lián)網(wǎng))的監(jiān)測(cè);通過(guò)
    的頭像 發(fā)表于 09-19 08:05 ?1620次閱讀
    基于ArkTS語(yǔ)言的OpenHarmony APP應(yīng)用<b class='flag-5'>開(kāi)發(fā)</b>:<b class='flag-5'>公共事</b>件的訂閱和發(fā)布