在线观看www成人影院-在线观看www日本免费网站-在线观看www视频-在线观看操-欧美18在线-欧美1级

0
  • 聊天消息
  • 系統消息
  • 評論與回復
登錄后你可以
  • 下載海量資料
  • 學習在線課程
  • 觀看技術視頻
  • 寫文章/發帖/加入社區
會員中心
电子发烧友
开通电子发烧友VIP会员 尊享10大特权
海量资料免费下载
精品直播免费看
优质内容免费畅学
课程9折专享价
創作中心

完善資料讓更多小伙伴認識你,還能領取20積分哦,立即完善>

3天內不再提示

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

jf_46214456 ? 來源:jf_46214456 ? 作者:jf_46214456 ? 2024-05-25 16:27 ? 次閱讀

后臺代理提醒

本模塊提供后臺代理提醒的能力。

開發應用時,開發者可以調用后臺提醒發布的接口創建定時提醒,包括倒計時、日歷、鬧鐘三種提醒類型。使用后臺代理提醒能力后,應用可以被凍結或退出,計時和彈出提醒的功能將被后臺系統服務代理。
說明: 本模塊首批接口從API version 7開始支持。后續版本的新增接口,采用上角標單獨標記接口的起始版本。

導入模塊

import reminderAgent from'@ohos.reminderAgent';

開發前請熟悉鴻蒙開發指導文檔 :[gitee.com/li-shizhen-skin/harmony-os/blob/master/README.md]點擊或者復制轉到。

reminderAgent.publishReminder

publishReminder(reminderReq: ReminderRequest, callback: AsyncCallback): void

發布一個后臺代理提醒,使用callback方式實現異步調用。

需要權限 : ohos.permission.PUBLISH_AGENT_REMINDER

系統能力 : SystemCapability.Notification.ReminderAgent

參數

參數名類型必填說明
reminderReq[ReminderRequest]需要發布的提醒實例。
callbackAsyncCallback異步回調,返回當前發布的提醒的reminderId。

示例

let timer = {
      reminderType: reminderAgent.ReminderType.REMINDER_TYPE_TIMER,
      triggerTimeInSeconds: 10
  }
  reminderAgent.publishReminder(timer, (err, reminderId) = > {
      console.log("callback, reminderId = " + reminderId);
  });

reminderAgent.publishReminder

publishReminder(reminderReq: ReminderRequest): Promise

發布一個后臺代理提醒,使用Promise方式實現異步調用。

需要權限 : ohos.permission.PUBLISH_AGENT_REMINDER

系統能力 : SystemCapability.Notification.ReminderAgent

參數

參數名類型必填說明
reminderReq[ReminderRequest]需要發布的提醒實例。

返回值

類型說明
Promise返回提醒的reminderId。

示例

let timer = {
      reminderType: reminderAgent.ReminderType.REMINDER_TYPE_TIMER,
      triggerTimeInSeconds: 10
  }
  reminderAgent.publishReminder(timer).then((reminderId) = > {
      console.log("promise, reminderId = " + reminderId);
  });

reminderAgent.cancelReminder

cancelReminder(reminderId: number, callback: AsyncCallback): void

取消指定id的提醒,使用callback方式實現異步調用。

系統能力 : SystemCapability.Notification.ReminderAgent

參數

參數名類型必填說明
reminderIdnumber目標reminder的id號。
callbackAsyncCallback異步回調。

示例

reminderAgent.cancelReminder(1, (err, data) = > {
    console.log("cancelReminder callback");
});

reminderAgent.cancelReminder

cancelReminder(reminderId: number): Promise

取消指定id的提醒,使用Promise方式實現異步調用。

系統能力 : SystemCapability.Notification.ReminderAgent

參數

參數名類型必填說明
reminderIdnumber目標reminder的id號。

返回值

類型說明
PromisePromise類型異步回調。

示例

reminderAgent.cancelReminder(1).then(() = > {
    console.log("cancelReminder promise");
});

reminderAgent.getValidReminders

getValidReminders(callback: AsyncCallback>): void

獲取當前應用已設置的所有有效(未過期)的提醒,使用callback方式實現異步調用。

系統能力 : SystemCapability.Notification.ReminderAgent

參數

參數名類型必填說明
callbackAsyncCallback>異步回調,返回當前應用已設置的所有有效(未過期)的提醒。

示例

reminderAgent.getValidReminders((err, reminders) = > {
    console.log("callback, getValidReminders length = " + reminders.length);
    for (let i = 0; i < reminders.length; i++) {
        console.log("getValidReminders = " + reminders[i]);
        console.log("getValidReminders, reminderType = " + reminders[i].reminderType);
        for (let j = 0; j < reminders[i].actionButton.length; j++) {
            console.log("getValidReminders, actionButton.title = " + reminders[i].actionButton[j].title);
            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);
    }
})

reminderAgent.getValidReminders

getValidReminders(): Promise>

獲取當前應用已設置的所有有效(未過期)的提醒,使用Promise方式實現異步調用。

系統能力 : SystemCapability.Notification.ReminderAgent

返回值

類型說明
Promise>返回當前應用已設置的所有有效(未過期)的提醒。

示例

reminderAgent.getValidReminders().then((reminders) = > {
    console.log("promise, getValidReminders length = " + reminders.length);
    for (let i = 0; i < reminders.length; i++) {
        console.log("getValidReminders = " + reminders[i]);
        console.log("getValidReminders, reminderType = " + reminders[i].reminderType);
        for (let j = 0; j < reminders[i].actionButton.length; j++) {
            console.log("getValidReminders, actionButton.title = " + reminders[i].actionButton[j].title);
            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);
    }
})

reminderAgent.cancelAllReminders

cancelAllReminders(callback: AsyncCallback): void

取消當前應用所有的提醒,使用callback方式實現異步調用。

系統能力 : SystemCapability.Notification.ReminderAgent

參數

參數名類型必填說明
callbackAsyncCallback異步回調。

示例

reminderAgent.cancelAllReminders((err, data) = >{
    console.log("cancelAllReminders callback")
})

reminderAgent.cancelAllReminders

cancelAllReminders(): Promise

取消當前應用所有的提醒,使用Promise方式實現異步調用。

系統能力 : SystemCapability.Notification.ReminderAgent

返回值

類型說明
PromisePromise類型異步回調。

示例

reminderAgent.cancelAllReminders().then(() = > {
    console.log("cancelAllReminders promise")
})

reminderAgent.addNotificationSlot

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

添加一個NotificationSlot,使用callback方式實現異步調用。

系統能力 : SystemCapability.Notification.ReminderAgent

參數

參數名類型必填說明
slot[NotificationSlot]notification slot實例,僅支持設置其type屬性。
callbackAsyncCallback異步回調。

示例

import notification from '@ohos.notification'

let mySlot = {
    type: notification.SlotType.SOCIAL_COMMUNICATION
}
reminderAgent.addNotificationSlot(mySlot, (err, data) = > {
    console.log("addNotificationSlot callback");
});

reminderAgent.addNotificationSlot

addNotificationSlot(slot: NotificationSlot): Promise

添加一個NotificationSlot,使用Promise方式實現異步調用。

系統能力 : SystemCapability.Notification.ReminderAgent

參數

參數名類型必填說明
slot[NotificationSlot]notification slot實例,僅支持設置其type屬性。

返回值

類型說明
PromisePromise類型異步回調。

示例

import notification from '@ohos.notification'

let mySlot = {
    type: notification.SlotType.SOCIAL_COMMUNICATION
}
reminderAgent.addNotificationSlot(mySlot).then(() = > {
   console.log("addNotificationSlot promise");
});

reminderAgent.removeNotificationSlot

removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback): void

刪除目標NotificationSlot,使用callback方式實現異步調用。

系統能力 : SystemCapability.Notification.ReminderAgent

參數

參數名類型必填說明
slotType[notification.SlotType]目標notification slot的類型。
callbackAsyncCallback異步回調。

示例

import notification from '@ohos.notification'

reminderAgent.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION, (err, data) = > {
    console.log("removeNotificationSlot callback");
});

reminderAgent.removeNotificationSlot

removeNotificationSlot(slotType: notification.SlotType): Promise

刪除目標NotificationSlot,使用Promise方式實現異步調用。

系統能力 : SystemCapability.Notification.ReminderAgent

參數

參數名類型必填說明
slotType[notification.SlotType]目標notification slot的類型。

返回值

類型說明
PromisePromise類型異步回調。

示例

import notification from '@ohos.notification'

reminderAgent.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION).then(() = > {
    console.log("removeNotificationSlot promise");
});

ActionButtonType

按鈕的類型。

系統能力 :以下各項對應的系統能力均為SystemCapability.Notification.ReminderAgent

名稱默認值說明
ACTION_BUTTON_TYPE_CLOSE0表示關閉提醒的按鈕。
ACTION_BUTTON_TYPE_SNOOZE1表示延遲提醒的按鈕。

ReminderType

提醒的類型。

系統能力 :以下各項對應的系統能力均為SystemCapability.Notification.ReminderAgent

名稱默認值說明
REMINDER_TYPE_TIMER0表示提醒類型:倒計時。
REMINDER_TYPE_CALENDAR1表示提醒類型:日歷。
REMINDER_TYPE_ALARM2表示提醒類型:鬧鐘。

ActionButton

用于設置彈出的提醒通知信息上顯示的按鈕類型和標題。

系統能力 :以下各項對應的系統能力均為SystemCapability.Notification.ReminderAgent

名稱參數類型必填說明
titlestring按鈕顯示的標題。
type[ActionButtonType]按鈕的類型。

WantAgent

點擊提醒通知后跳轉的目標ability信息。

系統能力 :以下各項對應的系統能力均為SystemCapability.Notification.ReminderAgent

名稱參數類型必填說明
pkgNamestring指明點擊提醒通知欄后跳轉的目標hap包名。
abilityNamestring指明點擊提醒通知欄后跳轉的目標ability名稱。

MaxScreenWantAgent

提醒到達時自動拉起的目標ability信息。

系統能力 :以下各項對應的系統能力均為SystemCapability.Notification.ReminderAgent

名稱參數類型必填說明
pkgNamestring指明提醒到達時自動拉起的目標hap包名(如果設備在使用中,則只彈出通知橫幅框)。
abilityNamestring指明提醒到達時自動拉起的目標ability名(如果設備在使用中,則只彈出通知橫幅框)。

ReminderRequest

提醒實例對象,用于設置提醒類型、響鈴時長等具體信息。

系統能力 :以下各項對應的系統能力均為SystemCapability.Notification.ReminderAgent

名稱參數類型必填說明
reminderTypeReminderType指明提醒類型。
actionButton[ActionButton?, ActionButton?]彈出的提醒通知欄中顯示的按鈕(參數可選,支持0/1/2個按鈕)。
wantAgentWantAgent點擊通知后需要跳轉的目標ability信息。
maxScreenWantAgentMaxScreenWantAgent提醒到達時跳轉的目標包。如果設備正在使用中,則彈出一個通知框。
ringDurationnumber指明響鈴時長。
snoozeTimesnumber指明延遲提醒次數。
timeIntervalnumber執行延遲提醒間隔。
titlestring指明提醒標題。
contentstring指明提醒內容。
expiredContentstring指明提醒過期后需要顯示的內容。
snoozeContentstring指明延遲提醒時需要顯示的內容。
notificationIdnumber指明提醒使用的通知的id號,相同id號的提醒會覆蓋。
slotType[notification.SlotType]指明提醒的slot類型。

ReminderRequestCalendar

ReminderRequestCalendar extends ReminderRequest

日歷實例對象,用于設置提醒的時間。

系統能力 :以下各項對應的系統能力均為SystemCapability.Notification.ReminderAgent

名稱參數類型必填說明
dateTime[LocalDateTime]指明提醒的目標時間。
repeatMonthsArray指明重復提醒的月份。
repeatDaysArray指明重復提醒的日期。

ReminderRequestAlarm

ReminderRequestAlarm extends ReminderRequest

鬧鐘實例對象,用于設置提醒的時間。

系統能力 :以下各項對應的系統能力均為SystemCapability.Notification.ReminderAgent

名稱參數類型必填說明
hournumber指明提醒的目標時刻。
minutenumber指明提醒的目標分鐘。
daysOfWeekArray指明每周哪幾天需要重復提醒。

ReminderRequestTimer

ReminderRequestTimer extends ReminderRequest

倒計時實例對象,用于設置提醒的時間。

系統能力 :SystemCapability.Notification.ReminderAgent

名稱參數類型必填說明HarmonyOSOpenHarmony鴻蒙文檔籽料:mau123789是v直接拿
triggerTimeInSecondsnumber指明倒計時的秒數。

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

LocalDateTime

用于日歷類提醒設置時指定時間信息。

系統能力 :以下各項對應的系統能力均為SystemCapability.Notification.ReminderAgent

名稱參數類型必填說明
yearnumber
monthnumber
daynumber
hournumber
minutenumber
secondnumber
聲明:本文內容及配圖由入駐作者撰寫或者入駐合作網站授權轉載。文章觀點僅代表作者本人,不代表電子發燒友網立場。文章及其配圖僅供工程師學習之用,如有內容侵權或者其他違規問題,請聯系本站處理。 舉報投訴
  • HarmonyOS
    +關注

    關注

    79

    文章

    2005

    瀏覽量

    31691
  • OpenHarmony
    +關注

    關注

    26

    文章

    3795

    瀏覽量

    17661
  • 鴻蒙OS
    +關注

    關注

    0

    文章

    190

    瀏覽量

    4811
收藏 0人收藏

    評論

    相關推薦

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

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

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

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

    鴻蒙開發接口公共事件與通知:【Notification模塊】

    本模塊首批接口從API version 7開始支持。后續版本的新增接口,采用上角標單獨標記接口的起始版本。
    的頭像 發表于 05-21 17:04 ?2631次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>開發</b><b class='flag-5'>接口</b><b class='flag-5'>公共事</b>件與<b class='flag-5'>通知</b>:【Notification模塊】

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

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

    鴻蒙原生應用/元服務開發-通知添加行為意圖

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

    鴻蒙原生應用/元服務開發-代理提醒說明(一)

    的本應用。 三、接口說明 表1 主要接口 以下是代理提醒的相關接口,下表均以Promise形式為例。 本文根據HarmonyOS官方
    發表于 01-12 09:49

    鴻蒙原生應用/元服務開發-代理提醒開發步驟(二)

    1.申請ohos.permission.PUBLISH_AGENT_REMINDER權限。 2.使能通知開關。獲得用戶授權后,才能使用代理提醒功能。 3.導入模塊。 import
    發表于 01-15 14:14

    基于ArkTS語言的OpenHarmony APP應用開發公共事件的訂閱和發布

    監聽特定系統公共事件,應用退出后該選項將自動調整為“從不”。 返回值應用菜單頁面,點擊“關于”可查看應用版本信息及本示例的說明。 本案例已在OpenHarmony凌蒙派-RK3568開發板驗證通過
    發表于 09-18 13:16

    HarmonyOS應用開發-公共事件處理

    開發過程中service想要控制多個ability時,可以考慮使用公共事件處理。發布無序的公共事件: //發布公共事件 同步修改卡片與頁面public void subscribeE
    發表于 11-02 15:15

    請問鴻蒙智能穿戴設備如何保持后臺任務定時獲取網絡數據?

    ;ohos.permission.SET_WIFI_INFO"},{ "name": "ohos.permission.GET_WIFI_INFO"}]無法滿足業務業務要求:應用退后臺后,間隔
    發表于 04-25 10:19

    HarmonyOS后臺任務管理開發指南上線!

    為應用進程分配 CPU 資源,同時對應的公共事件等不再發給應用進程)和進程終止。 為了保障后臺音樂播放、日歷提醒等功能的正常使用,系統提供了規范內受約束的后臺任務,擴展應用在
    發表于 11-29 09:58

    鴻蒙原生應用/元服務開發-Stage模型能力接口(四)

    一、說明 AbilityStage是HAP的運行時類。AbilityStage類提供在HAP加載的時候,通知開發者,可以在此進行該HAP的初始化(如資源預加載,線程創建等)能力。 本模塊首批接口
    發表于 12-14 15:39

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

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

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

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

    基于ArkTS語言的OpenHarmony APP應用開發公共事件的訂閱和發布

    1、程序介紹本示例主要展示了公共事件相關的功能,實現了一個檢測用戶部分行為的應用。具體而言,本案例實現了如下幾個公共事件功能:通過訂閱系統公共事件,實現對用戶操作行為(亮滅屏、斷聯網)的監測;通過
    的頭像 發表于 09-19 08:05 ?779次閱讀
    基于ArkTS語言的OpenHarmony APP應用<b class='flag-5'>開發</b>:<b class='flag-5'>公共事</b>件的訂閱和發布
    主站蜘蛛池模板: 四虎影院免费观看视频 | 精品xxxxxbbbb欧美中文 | 国模在线观看 | 一级欧美一级日韩 | 欧美高清一区二区三 | 欧美三级免费观看 | 男女爱爱爽爽福利免费视频 | 久久精品国波多野结衣 | 美女黄色在线看 | 99久在线| 一本大道一卡二卡 | h网站在线观看 | 亚洲免费一区二区 | 手机看片福利视频 | 日韩三级免费 | 香港三级在线视频 | 中文字幕一区二区三区视频在线 | 成人综合在线观看 | 手机在线完整视频免费观看 | 婷婷天堂| video另类蛇交 | avtt加勒比手机版天堂网 | 又粗又硬又爽又黄毛片 | www.丁香.com| 人人爽人人澡 | 国产一级特黄老妇女大片免费 | 日本成本人三级在线观看2018 | 国产精品yy9299在线观看 | 午夜福利国产一级毛片 | 韩国电影天堂网 | 久青草国产手机在线视频 | 国产又粗又大又爽又免费 | 美女网站一区二区三区 | 国内一区二区 | 亚洲视频在线观看一区 | 亚洲成人777 | 妹子干综合网 | 国产高清色视频免费看的网址 | 精品成人网| 欧美人与z0zoxxxx特 | 国产婷婷色|

    電子發燒友

    中國電子工程師最喜歡的網站

    • 2931785位工程師會員交流學習
    • 獲取您個性化的科技前沿技術信息
    • 參加活動獲取豐厚的禮品