HarmonyOS 使用action的方式链接ability

HarmonyOS
3天前
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
shlp

可参考:

{
  "module": {
  "name": "entry",
  "type": "entry",
  "description": "$string:module_desc",
  "mainElement": "EntryAbility",
  "deviceTypes": [
  "phone",
  "2in1"
  ],
  "metadata": [
  {
    "name": "client_id",
  "value": "109834877"
  }
  ],
  "deliveryWithInstall": true,
  "installationFree": false,
  "pages": "$profile:main_pages",
  "abilities": [
  {
    "name": "EntryAbility",
  "srcEntry": "./ets/entryability/EntryAbility.ets",
  "description": "$string:EntryAbility_desc",
  "icon": "$media:icon_json",
  "label": "$string:EntryAbility_label",
  "startWindowIcon": "$media:icon_json",
  "startWindowBackground": "$color:start_window_background",
  "exported": true,
  "skills": [
    // applink 的skills
    {
      "entities": [
      "entity.system.home",
      "entity.system.browsable"
      ],
      "actions": [
      "action.system.home",
      "ohos.want.action.viewData"
      ],
      "uris": [
      {
        "scheme": "sohunews",
      "host": "pr",
      },
      {
        "scheme": "https",
      "host": "test3g.k.sohu.com",
      }
      ],
      // domainVerify须设置为true
      "domainVerify": true
    },
    // push 的skills 设置uris参数完成点击消息进入应用内页示例
    // 设置完成后需要https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/push-send-alert-V5#section8794131614597 参照2 配置对应的clickAction
    {
      "actions": ["com.test.action"],

    }
    ]
  }
  ],

  "requestPermissions": [
  {
    "name": "ohos.permission.GET_BUNDLE_INFO"
  },
  {
    "name": "ohos.permission.INTERNET"
  }
  ]
}
}

// Request Body
{
  "payload": {
  "notification": {
    "category": "MARKETING",
    "title": "普通通知标题",
    "body": "普通通知内容",
    "clickAction": {
      "actionType": 1,
      "action": "com.test.action"
      "data": {"uri":"news://newsId=804516881&channelId=0&isfrompush=1&msgId=1337367441&pushType=4&bucket=1001&group=group_last&cfrFrom=4&layers=1_1_5_9_4_3&titleIndex=0"}
    }
  }
},
  "target": {
  "token": ["xxxxx"]
},
  "pushOptions": {
  "testMessage": true
}}

然后覆写 onCreat 与onNewWant方法 处理data数据

分享
微博
QQ
微信
回复
3天前
相关问题
有关 Ability 使用问题
334浏览 • 1回复 待解决
使用Ability Kit报错16000001
603浏览 • 1回复 待解决
HarmonyOS NodeContainer使用方式
19浏览 • 1回复 待解决
AsyncCallback使用方式
2450浏览 • 1回复 待解决
使用SaveButton保存图片方式
667浏览 • 1回复 待解决
使用request下载文件方式
827浏览 • 1回复 待解决
HarmonyOS App Linking测试链接
37浏览 • 1回复 待解决
能否创建透明ability
1794浏览 • 1回复 待解决
使用List组件设置多列布局方式
546浏览 • 1回复 待解决