HarmonyOS 使用action的方式链接ability?

如题:HarmonyOS 使用action的方式链接ability?

阅读 494
1 个回答

可参考:

{
  "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数据

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
logo
HarmonyOS
子站问答
访问
宣传栏