HarmonyOS 应用配置skills,支持外部自定义scheme 唤起无效?

被调用方B 应用配置如下

module.json5 配置内容如下

"skills": [
{
  "entities": [
  "entity.system.home"
  ],
  "actions": [
  "action.system.home"
  ]
},
// out side skill
{
  "actions": [
  "ohos.want.action.viewData"
  ],
  "entities": [
  "entity.system.browsable"
  ],
  "uris": [{
  "scheme": "https",
  "host": "www.test.com",
  "port": "8080",
  "pathStartWith": "query"
},
  {
    "scheme": "http"
  }
  ]
}
]

调用方A (另外一个App), 配置如下

let wantInfo: Want = {
  // uncomment line below if wish to implicitly query only in the specific bundle.
  action: 'ohos.want.action.viewData',
  // entities can be omitted.
  entities: ['entity.system.browsable'],
  uri: 'https://www.test.com:8080/query/student'
}

// TODO Check whether if System can resolve the want
let ctx = getContext(this) as common.UIAbilityContext
ctx.startAbility(wantInfo).then(() => {
  console.log(TAG, 'start success')
}).catch((err: BusinessError) => {
  console.error(TAG, 'start failed', err.code, err.message)
})

执行A 调用B, 发现 没有唤起B,而是直接走浏览器。 所以,上述的实例代码走不通。

阅读 431
1 个回答
//被调用方B配置:
"skills": [
{
  "entities": [
  "entity.system.home"
  ],
  "actions": [
  "ohos.want.action.viewData"
  ],
  "uris": [
  {
    "scheme": "https",
  "host": "www.test.com",
  "port": "8080",
  "pathStartWith": "query"
  }
  ]
}
]

//调用方A:
let wantInfo: Want = {
  uri: 'https://www.test.com:8080/query/student'
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进