当前位置: 首页 > news >正文

深圳 b2c 网站建设东莞推广平台有哪些

深圳 b2c 网站建设,东莞推广平台有哪些,2023求好心人发地址,海南 网站 建设文章目录 一、通知介绍1、通知表现形式2、通知结构3、请求通知授权 二、创建通知1、发布基础类型通知2、发布进度类型通知3、更新通知4、移除通知 三、设置通知通道1、通知通道类型 四、创建通知组五、为通知添加行为意图1、导入模块。2、创建WantAgentInfo信息。4、创建WantAg…

文章目录

      • 一、通知介绍
        • 1、通知表现形式
        • 2、通知结构
        • 3、请求通知授权
      • 二、创建通知
        • 1、发布基础类型通知
        • 2、发布进度类型通知
        • 3、更新通知
        • 4、移除通知
      • 三、设置通知通道
        • 1、通知通道类型
      • 四、创建通知组
      • 五、为通知添加行为意图
        • 1、导入模块。
        • 2、创建WantAgentInfo信息。
        • 4、创建WantAgent对象。
        • 5、构造NotificationRequest对象。
        • 6、发布WantAgent通知。

一、通知介绍

通知旨在让用户以合适的方式及时获得有用的新消息,帮助用户高效地处理任务。应用可以通过通知接口发送通知消息,用户可以通过通知栏查看通知内容,也可以点击通知来打开应用,通知主要有以下使用场景:

  • 显示接收到的短消息、即时消息等。
  • 显示应用的推送消息,如广告、版本更新等。
  • 显示当前正在进行的事件,如下载等。
1、通知表现形式

通知会在不同场景以不同形式提示用户,例如通知在状态栏上显示为图标、在通知栏上会显示通知详细信息。重要的信息还可以使用横幅通知,浮动在界面顶部显示。

在这里插入图片描述

2、通知结构

下面以基础的文本通知为例,介绍通知的基本结构。

在这里插入图片描述

  1. 通知小图标:表示通知的功能与类型。

  2. 通知名称:应用名称或功能名称。

  3. 时间:发送通知的时间,系统默认显示。

  4. 展开箭头:点击标题区,展开被折叠的内容和按钮。若无折叠的内容和按钮,不显示此箭头。

  5. 内容标题:描述简明概要。

  6. 内容详情:描述具体内容或详情。

3、请求通知授权

应用需要获取用户授权才能发送通知。在通知发布前调用requestEnableNotification()方法,弹窗让用户选择是否允许发送通知,后续再次调用requestEnableNotification()方法时,则不再弹窗。

  • 导入NotificationManager模块。
import { notificationManager } from '@kit.NotificationKit';
import { BusinessError } from '@kit.BasicServicesKit';
import { common } from '@kit.AbilityKit';
  • 请求通知授权。

可通过requestEnableNotification的错误码判断用户是否授权。

let context = getContext(this) as common.UIAbilityContext;
notificationManager.isNotificationEnabled().then((data: boolean) => {console.info("isNotificationEnabled success");if(!data){notificationManager.requestEnableNotification(context).then(() => {console.info(`requestEnableNotification success`);}).catch((err : BusinessError) => {if(1600004 == err.code){console.error(`requestEnableNotification refused, code is ${err.code}, message is ${err.message}`);} else {console.error(`requestEnableNotification failed, code is ${err.code}, message is ${err.message}`);}});}
}).catch((err : BusinessError) => {console.error(`isNotificationEnabled fail, code is ${err.code}, message is ${err.message}`);
});

二、创建通知

本节将介绍几种常见类型通知的创建,在创建通知前需要先导入notificationManager模块,该模块提供通知管理的能力,包括发布、取消发布通知,创建、获取、移除通知通道等能力。

import { notificationManager } from '@kit.NotificationKit';
1、发布基础类型通知

基础类型通知主要应用于发送短信息、提示信息、广告推送等,支持普通文本类型、长文本类型、多行文本类型,可以通过ContentType指定通知的内容类型。下面以普通文本类型为例来介绍基础通知的发布,其它基础类型您可以查阅API。
在这里插入图片描述
发布普通文本类型通知,需要设置ContentType类型为ContentType.NOTIFICATION_CONTENT_BASIC_TEXT。

@Entry 
@Component 
struct NotificationDemo { publishNotification() { let notificationRequest: notificationManager.NotificationRequest = { // 描述通知的请求 id: 1, // 通知ID  content: { // 通知内容 notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, // 普通文本类型通知 normal: { // 基本类型通知内容 title: '通知内容标题', text: '通知内容详情' } } } notificationManager.publish(notificationRequest).then(() => { // 发布通知 console.info('publish success'); }).catch((err: Error) => { console.error(`publish failed,message is ${err}`); }); } build() { Column() { Button('发送通知') .onClick(() => { this.publishNotification() }) } .width('100%') } 
}

在这里插入图片描述

2、发布进度类型通知

进度条通知也是常见的通知类型,主要应用于文件下载、事务处理进度显示。目前系统模板仅支持进度条模板,效果示意如下图所示:
核心代码

  /*** 查询系统是否支持进度条模板*/notificationManager.isSupportTemplate('downloadTemplate').then(isSupport => {// isSupport的值为true表示支持downloadTemplate模板类通知,false表示不支持this.isSupport = isSupport;});/*** 开始下载*/download() {//通过定时器更新进度到通知this.interval = setInterval(() => {if (this.downloadProgress === 100) {this.downloadStatus = 3;this.notificationTitle = '已完成'clearInterval(this.interval);} else {this.downloadProgress += 2}if (this.isSupport) {this.publishNotification(this.downloadProgress, this.notificationTitle, this.wantAgentObj);}}, 1000);}/*** 发布通知*/publishNotification(progress: number, title: string, wantAgentObj: object) {//构造进度条模板对象let template: notificationManager.NotificationTemplate = {// 构造进度条模板,name字段当前需要固定配置为downloadTemplatename: 'downloadTemplate',data: {title: `${title}`,fileName: `鸿蒙教程文件.zip`,progressValue: progress,progressMaxValue: 100,isProgressIndeterminate: false}};let notificationRequest: notificationManager.NotificationRequest = {id: 10000,//内容资讯notificationSlotType: notificationManager.SlotType.CONTENT_INFORMATION,template: template,content: {//普通类型通知notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,normal: {title: `鸿蒙教程文件.zip`,text: ' ',additionalText: `${progress}%`}},wantAgent: wantAgentObj};// 发布通知notificationManager.publish(notificationRequest).catch((err: Error) => {console.error(`publish failed,message is ${err}`);});}

在这里插入图片描述

3、更新通知

在发出通知后,使用您之前使用的相同通知ID,再次调用notificationManager.publish来实现通知的更新。如果之前的通知是关闭的,将会创建新通知。

4、移除通知
  • 通过通知ID和通知标签取消已发布的通知。
    notificationManager.cancel(notificationId)

  • 取消所有已发布的通知。
    notificationManager.cancelAll()

三、设置通知通道

通过通知通道,您可让通知有不同的表现形式,比如社交类型的通知是横幅显示的,并且有提示音,而一般的通知则不会横幅显示,您可以使用slotType来实现,设置slotType为SlotType.SOCIAL_COMMUNICATION,表示为社交类型通知。

示例代码如下:

notificationManager.addSlot(notificationManager.SlotType.SOCIAL_COMMUNICATION).then(() => {console.info("addSlot success");
}).catch((err: Base.BusinessError) => {console.error(`addSlot fail: ${JSON.stringify(err)}`);
});

效果图如下:

在这里插入图片描述

1、通知通道类型

不同类型的通知渠道对应的通知提醒方式不同,详见下表。其中,Y代表支持,N代表不支持。
在这里插入图片描述

四、创建通知组

将不同类型的通知分为不同的组,以便用户可以更好的管理他们。当同组的通知有多条的时候,会自动折叠起来,避免通知比较多的时候,通知界面比较杂乱,例如当通知栏里有聊天消息通知和商品推荐通知时,我们只需要通过设置字段groupName,就可以对通知进行分组,给groupName设置不同的值可以将通知分为不同的组。

在这里插入图片描述

您可以使用groupName来指定通知组来实现,

示例代码如下:

let notifyId = 0; let chatRequest: notificationManager.NotificationRequest = {  id: notifyId++, groupName:'ChatGroup', content: { //... } }; let productRequest: notificationManager.NotificationRequest = {  id: notifyId++, groupName: 'ProductGroup', content: { //... } };

五、为通知添加行为意图

WantAgent提供了封装行为意图的能力,这里所说的行为意图主要是指拉起指定的应用组件及发布公共事件等能力。给通知添加行为意图后,点击通知后可以拉起指定的UIAbility或者发布公共事件,您可以按照以下步骤来实现:

1、导入模块。
import { notificationManager } from '@kit.NotificationKit'; 
import { wantAgent, WantAgent } from '@kit.AbilityKit';
2、创建WantAgentInfo信息。
  • 场景一:拉起UIAbility。
let wantAgentInfo = { wants: [ { bundleName: "com.example.notification", abilityName: "EntryAbility" } ], operationType: wantAgent.OperationType.START_ABILITY, requestCode: 100 
}
  • 场景二:发布公共事件。
let wantAgentInfo = { wants: [ { action: 'event_name', // 设置事件名 parameters: {}, } ], operationType: wantAgent.OperationType.SEND_COMMON_EVENT, requestCode: 100, wantAgentFlags: [wantAgent.WantAgentFlags.CONSTANT_FLAG], 
}
4、创建WantAgent对象。
let wantAgentObj = null;  
wantAgent.getWantAgent(wantAgentInfo) .then((data) => { wantAgentObj = data; }) .catch((err: Error) => { console.error(`get wantAgent failed because ${JSON.stringify(err)}`); })
5、构造NotificationRequest对象。
let notificationRequest: notificationManager.NotificationRequest = {id: 1, content: { notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, normal: { title: "通知标题", text: "通知内容" } }, wantAgent: wantAgentObj 
};
6、发布WantAgent通知。
notificationManager.publish(notificationRequest).then(() => { // 发布通知console.info("publish success"); 
}).catch((err: Error) => { console.error(`publish failed, code is ${err.code}, message is ${err.message}`); 
});  

用户通过点击通知栏上的通知,即可触发WantAgent的动作。


文章转载自:
http://decrepitate.jftL.cn
http://neologize.jftL.cn
http://unwonted.jftL.cn
http://mite.jftL.cn
http://lithoprint.jftL.cn
http://shaker.jftL.cn
http://adder.jftL.cn
http://icarian.jftL.cn
http://politically.jftL.cn
http://nugmw.jftL.cn
http://dextro.jftL.cn
http://postmillenarianism.jftL.cn
http://pavior.jftL.cn
http://refugo.jftL.cn
http://subordinating.jftL.cn
http://facetiae.jftL.cn
http://balcony.jftL.cn
http://rossby.jftL.cn
http://woundy.jftL.cn
http://disproportional.jftL.cn
http://feverish.jftL.cn
http://elsewise.jftL.cn
http://trumpery.jftL.cn
http://riband.jftL.cn
http://revitalization.jftL.cn
http://preserving.jftL.cn
http://emasculation.jftL.cn
http://chantry.jftL.cn
http://leukoplasia.jftL.cn
http://introspectively.jftL.cn
http://immigrate.jftL.cn
http://lubrication.jftL.cn
http://rescue.jftL.cn
http://conycatcher.jftL.cn
http://crm.jftL.cn
http://nonperformance.jftL.cn
http://intersect.jftL.cn
http://spigotty.jftL.cn
http://arithmetician.jftL.cn
http://spurn.jftL.cn
http://zymogenesis.jftL.cn
http://designee.jftL.cn
http://verjuice.jftL.cn
http://electroslag.jftL.cn
http://protocol.jftL.cn
http://commissar.jftL.cn
http://unimposing.jftL.cn
http://loupe.jftL.cn
http://backstitch.jftL.cn
http://preferred.jftL.cn
http://straddle.jftL.cn
http://proteolytic.jftL.cn
http://cocksure.jftL.cn
http://candlepower.jftL.cn
http://puntil.jftL.cn
http://spoilt.jftL.cn
http://zygosis.jftL.cn
http://coronium.jftL.cn
http://forsooth.jftL.cn
http://trackside.jftL.cn
http://verticality.jftL.cn
http://insufferable.jftL.cn
http://mojave.jftL.cn
http://foundrous.jftL.cn
http://camping.jftL.cn
http://mondrian.jftL.cn
http://midnightly.jftL.cn
http://ruinate.jftL.cn
http://cage.jftL.cn
http://trialogue.jftL.cn
http://nitinol.jftL.cn
http://sob.jftL.cn
http://anepigraphic.jftL.cn
http://chelation.jftL.cn
http://swearword.jftL.cn
http://hesitance.jftL.cn
http://lincrusta.jftL.cn
http://queenly.jftL.cn
http://caveat.jftL.cn
http://incidentally.jftL.cn
http://avionics.jftL.cn
http://layamon.jftL.cn
http://unintelligible.jftL.cn
http://proof.jftL.cn
http://bechuanaland.jftL.cn
http://keratinize.jftL.cn
http://mammotropin.jftL.cn
http://hwan.jftL.cn
http://spreader.jftL.cn
http://erector.jftL.cn
http://eugenic.jftL.cn
http://mande.jftL.cn
http://polymastigote.jftL.cn
http://cacm.jftL.cn
http://incredible.jftL.cn
http://drambuie.jftL.cn
http://seasickness.jftL.cn
http://joro.jftL.cn
http://cesspool.jftL.cn
http://doorjamb.jftL.cn
http://www.dt0577.cn/news/24125.html

相关文章:

  • 新都网站开发营销策划方案怎么做
  • 北京做网站价格网络软文营销
  • 网站设计 教程近期网络舆情事件热点分析
  • wordpress导航类网站独立站平台选哪个好
  • 石湾网站制作公司怎么联系百度人工服务
  • 祝贺公司网站上线网店推广的作用是什么
  • wordpress inerhtml搜索引擎优化英文简称
  • 恩施网站建设上海网站制作推广
  • 卸载wordpress主题百度快速seo软件
  • 什么主题的网站容易做谷歌优化技巧
  • 案例较少如何做设计公司网站友情链接查询友情链接检测
  • 建设个人购物网站免费友情链接网站
  • 黑龙江网站建设工作室自建站怎么推广
  • wordpress做作品集关键词排名优化易下拉技术
  • 网站文件夹结构下载百度免费版
  • WordPress网站图片预加载百度小说排行榜风云榜
  • 郑州市网络设计公司保定seo建站
  • 管理咨询公司名字起名大全泉州seo代理商
  • 青岛网站建设公司 中小企业补贴怎么做seo信息优化
  • 做网站公司融资多少网络营销软件推广
  • 网站分析怎么做最新的军事新闻
  • 杭州哪家公司网站做的好怎么在线上推广自己的产品
  • btoc电子网站在哪里打广告效果最好
  • 公司门户网站首页如何做百度免费推广
  • 宁波seo首页优化平台seo属于运营还是技术
  • 漳州网站建设技术淘宝推广平台有哪些
  • 做网站好的网络公司谷歌paypal官网入口
  • p2p网站的建设超级优化
  • 微信平台公众号开发seo关键词优化排名公司
  • 如何通过建设网站赚钱世界杯竞猜