• Lv0
    粉丝0

积分186 / 贡献0

提问33答案被采纳3文章0

swiper loop属性如何生效?

星辰大海

沙发 发表于 2023-9-13 15:36:33

通过配置Notification.publish发布通知接口的参数NotificationRequest中wantAgent属性实现

import notificationManager from '@ohos.notificationManager';

import WantAgent from '@ohos.app.ability.wantAgent';


async function publishNotification() {

  let wantAgentInfo = {

    wants: [

      {

        bundleName: "com.example.webuseragent", // 自己应用的bundleName

        abilityName: "EntryAbility",

      }

    ],

    operationType: WantAgent.OperationType.START\_ABILITIES,

    requestCode: 1,

  }

  const wantAgent = await WantAgent.getWantAgent(wantAgentInfo)

  let contentType = notificationManager.ContentType.NOTIFICATION\_CONTENT\_BASIC\_TEXT;

  await notificationManager.publish({

    content: {

      contentType: contentType,

      normal: {

        title: "测试标题",

        text: "测试内容",

      }

    },

    id: 1,

    wantAgent: wantAgent

  })

}

Copyright   ©2023  OpenHarmony开发者论坛  京ICP备2020036654号-3 |技术支持 Discuz!

返回顶部