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

国内知名设计网站百度经验登录入口

国内知名设计网站,百度经验登录入口,可以做长页海报的网站,潍坊公司网站建设意图通知 获取router事件中传递参数并跳转 目前点击通知消息打开应用的指定页面,通过为通知添加行为意图的方式。也就是在wants的parameters中设置自定义参数,然后在UIAbility的onNewWant或者onCreate方法中 解析配置的自定义参数信息判断跳转不同页面&a…

意图通知
获取router事件中传递参数并跳转
目前点击通知消息打开应用的指定页面,通过为通知添加行为意图的方式。也就是在wants的parameters中设置自定义参数,然后在UIAbility的onNewWant或者onCreate方法中 解析配置的自定义参数信息判断跳转不同页面,参考文档:
https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/notification-with-wantagent-V5
在UIAbility根据传递的params不同,选择拉起不同的页面可参考:
https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/arkts-ui-widget-event-router-V5

import { NavBar } from '../component/NavBar';
import { notificationManager } from '@kit.NotificationKit';
import { common, wantAgent } from '@kit.AbilityKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
import { BusinessError } from '@kit.BasicServicesKit';@Component
@Entry
struct DemoNotification {@State TAG: string = '[PublishOperation]';@State DOMAIN_NUMBER: number = 0xFF00;@State wantAgentInfo: wantAgent.WantAgentInfo = {wants: [{bundleName: "com.example.yumi",abilityName: "EntryAbility"}],operationType: wantAgent.OperationType.START_ABILITY,requestCode: 100};onPageShow(): void {// 请求通知授权let context = getContext(this) as common.UIAbilityContext;notificationManager.isNotificationEnabled().then((data: boolean) => {hilog.info(this.DOMAIN_NUMBER, this.TAG, "isNotificationEnabled success, data: " + JSON.stringify(data));if (!data) {notificationManager.requestEnableNotification(context).then(() => {hilog.info(this.DOMAIN_NUMBER, this.TAG, `[ANS] requestEnableNotification success`);}).catch((err: BusinessError) => {if (1600004 == err.code) {hilog.error(this.DOMAIN_NUMBER, this.TAG,`[ANS] requestEnableNotification refused, code is ${err.code}, message is ${err.message}`);} else {hilog.error(this.DOMAIN_NUMBER, this.TAG,`[ANS] requestEnableNotification failed, code is ${err.code}, message is ${err.message}`);}});}}).catch((err: BusinessError) => {hilog.error(this.DOMAIN_NUMBER, this.TAG,`isNotificationEnabled fail, code is ${err.code}, message is ${err.message}`);});// 通知角标let badgeNumber: number = 10;notificationManager.setBadgeNumber(badgeNumber).then(() => {hilog.info(this.DOMAIN_NUMBER, this.TAG, `setBadgeNumber 10 success.`);badgeNumber = 11;notificationManager.setBadgeNumber(badgeNumber).then(() => {hilog.info(this.DOMAIN_NUMBER, this.TAG, `setBadgeNumber 11 success.`);});});}publishNotification() {let notificationRequest: notificationManager.NotificationRequest = {// 描述通知的请求id: 1, // 通知IDcontent: {// 通知内容notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, // 普通文本类型通知normal: {// 基本类型通知内容title: '通知内容标题',text: '通知内容详情'}}}// addslot回调let addSlotCallBack = (err: BusinessError): void => {if (err) {hilog.info(this.DOMAIN_NUMBER, this.TAG, `addSlot failed, code is ${err.code}, message is ${err.message}`);} else {hilog.info(this.DOMAIN_NUMBER, this.TAG, `addSlot success`);}}notificationManager.addSlot(notificationManager.SlotType.SOCIAL_COMMUNICATION, addSlotCallBack);notificationManager.publish(notificationRequest).then(() => { // 发布通知console.info('publish success');}).catch((err: Error) => {console.error(`publish failed,message is ${err}`);});}async publishNotificationWant() {let wantAgentInfo: wantAgent.WantAgentInfo = {wants: [{bundleName: "com.example.yumi", // 自己应用的bundleNameabilityName: "EntryAbility",parameters: { page: 'view/Car' } // 自己点击通知需要跳转的页面}],operationType: wantAgent.OperationType.START_ABILITIES,requestCode: 1,}const wantAgentObj = await wantAgent.getWantAgent(wantAgentInfo)await notificationManager.publish({content: {notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,normal: {title: "测试标题",text: "测试内容",}},id: 1,wantAgent: wantAgentObj})}build() {Column() {NavBar({ title: '通知' })Button('发送文本类型通知').onClick(() => {this.publishNotification()})Button('发送通知-为通知添加行为意图').onClick(() => {this.publishNotificationWant()})}}
}
import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
import { router, Router, window } from '@kit.ArkUI';
import { DialogHelper } from '@pura/harmony-dialog';
import { AppUtil } from '@pura/harmony-utils'export default class EntryAbility extends UIAbility {onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');AppUtil.init(this.context)}onDestroy(): void {hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');}onWindowStageCreate(windowStage: window.WindowStage): void {// Main window is created, set main page for this abilityhilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');windowStage.loadContent('pages/Splash')}onWindowStageDestroy(): void {// Main window is destroyed, release UI related resourceshilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');}onForeground(): void {// Ability has brought to foregroundhilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');}onBackground(): void {// Ability has back to backgroundhilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');}onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam): void {hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onNewWant');//点击Notification通知并打开App的具体页面let page = want?.parameters?.page  as stringrouter.pushUrl({url: page})console.log('want参数'+want?.parameters?.page)}
}
http://www.shuangfujiaoyu.com/news/35403.html

相关文章:

  • 做兼职推荐网站网站开发公司
  • 重庆网络公司网站建设百度贴吧官网
  • 快速建设网站精准引流的网络推广
  • 国外做ppt的网站有哪些网站优化要多少钱
  • 免费发布信息网有哪些网站常州seo关键词排名
  • 网站建设与管理提纲seo的名词解释
  • 从来没做过网站如何做淘宝搜索词排名查询
  • 做网站代理网络推广优化网站
  • 贵州华瑞网站建设有限公司淘宝权重查询
  • 如何建网站教程企业培训课程清单
  • django 做网站赚钱简述网络营销的特点及功能
  • 石家庄做手机网站推广网页设计个人主页
  • 网上做任务赚钱网站有哪些nba排名最新排名
  • 自己建网站可以赚钱吗哪家培训机构学校好
  • 电子政务 和网站建设总结南京seo网站管理
  • 空壳网站广告营销
  • 唐山网站建设外包公司重庆关键词搜索排名
  • 万网国际江北seo综合优化外包
  • 会展设计是什么专业安徽新站优化
  • 建设彩票网站需要哪些要求网站建设优化收费
  • 怎么做网站超市百度推广网站平台
  • 网站建设开发费用sem推广优化
  • 广州网站建设88百度快速收录网站
  • 最好的模板网站微信附近人推广引流
  • 中铁建设中南公司官方网站一手渠道推广平台
  • wordpress百度云盘插件沈阳seo排名优化推广
  • 上海网站建设的平台网站开发公司
  • 石家庄做网站的公司文件外链生成网站
  • 网站建设中倒计时模板下载优化
  • 牛商网网站后台关键词优化一年的收费标准