chinese直男口爆体育生外卖, 99久久er热在这里只有精品99, 又色又爽又黄18禁美女裸身无遮挡, gogogo高清免费观看日本电视,私密按摩师高清版在线,人妻视频毛茸茸,91论坛 兴趣闲谈,欧美 亚洲 精品 8区,国产精品久久久久精品免费

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

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

3天內不再提示

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

jf_46214456 ? 來源:jf_46214456 ? 作者:jf_46214456 ? 2024-05-25 16:27 ? 次閱讀
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

后臺代理提醒

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

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

導入模塊

import reminderAgent from'@ohos.reminderAgent';

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

reminderAgent.publishReminder

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

發(fā)布一個后臺代理提醒,使用callback方式實現(xiàn)異步調用。

需要權限 : ohos.permission.PUBLISH_AGENT_REMINDER

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

參數(shù)

參數(shù)名類型必填說明
reminderReq[ReminderRequest]需要發(fā)布的提醒實例。
callbackAsyncCallback異步回調,返回當前發(fā)布的提醒的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

發(fā)布一個后臺代理提醒,使用Promise方式實現(xiàn)異步調用。

需要權限 : ohos.permission.PUBLISH_AGENT_REMINDER

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

參數(shù)

參數(shù)名類型必填說明
reminderReq[ReminderRequest]需要發(fā)布的提醒實例。

返回值

類型說明
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方式實現(xiàn)異步調用。

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

參數(shù)

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

示例

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

reminderAgent.cancelReminder

cancelReminder(reminderId: number): Promise

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

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

參數(shù)

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

返回值

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

示例

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

reminderAgent.getValidReminders

getValidReminders(callback: AsyncCallback>): void

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

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

參數(shù)

參數(shù)名類型必填說明
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方式實現(xiàn)異步調用。

系統(tǒng)能力 : 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方式實現(xiàn)異步調用。

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

參數(shù)

參數(shù)名類型必填說明
callbackAsyncCallback異步回調。

示例

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

reminderAgent.cancelAllReminders

cancelAllReminders(): Promise

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

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

返回值

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

示例

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

reminderAgent.addNotificationSlot

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

添加一個NotificationSlot,使用callback方式實現(xiàn)異步調用。

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

參數(shù)

參數(shù)名類型必填說明
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方式實現(xiàn)異步調用。

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

參數(shù)

參數(shù)名類型必填說明
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方式實現(xiàn)異步調用。

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

參數(shù)

參數(shù)名類型必填說明
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方式實現(xiàn)異步調用。

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

參數(shù)

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

返回值

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

示例

import notification from '@ohos.notification'

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

ActionButtonType

按鈕的類型。

系統(tǒng)能力 :以下各項對應的系統(tǒng)能力均為SystemCapability.Notification.ReminderAgent

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

ReminderType

提醒的類型。

系統(tǒng)能力 :以下各項對應的系統(tǒng)能力均為SystemCapability.Notification.ReminderAgent

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

ActionButton

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

系統(tǒng)能力 :以下各項對應的系統(tǒng)能力均為SystemCapability.Notification.ReminderAgent

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

WantAgent

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

系統(tǒng)能力 :以下各項對應的系統(tǒng)能力均為SystemCapability.Notification.ReminderAgent

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

MaxScreenWantAgent

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

系統(tǒng)能力 :以下各項對應的系統(tǒng)能力均為SystemCapability.Notification.ReminderAgent

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

ReminderRequest

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

系統(tǒng)能力 :以下各項對應的系統(tǒng)能力均為SystemCapability.Notification.ReminderAgent

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

ReminderRequestCalendar

ReminderRequestCalendar extends ReminderRequest

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

系統(tǒng)能力 :以下各項對應的系統(tǒng)能力均為SystemCapability.Notification.ReminderAgent

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

ReminderRequestAlarm

ReminderRequestAlarm extends ReminderRequest

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

系統(tǒng)能力 :以下各項對應的系統(tǒng)能力均為SystemCapability.Notification.ReminderAgent

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

ReminderRequestTimer

ReminderRequestTimer extends ReminderRequest

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

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

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

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

LocalDateTime

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

系統(tǒng)能力 :以下各項對應的系統(tǒng)能力均為SystemCapability.Notification.ReminderAgent

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

    關注

    80

    文章

    2126

    瀏覽量

    33100
  • OpenHarmony
    +關注

    關注

    29

    文章

    3854

    瀏覽量

    18633
  • 鴻蒙OS
    +關注

    關注

    0

    文章

    191

    瀏覽量

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

掃碼添加小助手

加入工程師交流群

    評論

    相關推薦
    熱點推薦

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

    本模塊首批接口從API version 7開始支持。后續(xù)版本的新增接口,采用上角標單獨標記接口的起始版本。
    的頭像 發(fā)表于 05-21 11:13 ?1809次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>開發(fā)</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>件模塊)】

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

    本模塊首批接口從API version 7開始支持。
    的頭像 發(fā)表于 05-21 16:06 ?1859次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>開發(fā)</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)】

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

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

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

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

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

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

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

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

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

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

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

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

    HarmonyOS應用開發(fā)-公共事件處理

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

    請問鴻蒙智能穿戴設備如何保持后臺任務定時獲取網(wǎng)絡數(shù)據(jù)?

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

    HarmonyOS后臺任務管理開發(fā)指南上線!

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

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

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

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

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

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

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

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

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