HarmonyOS App Linking测试链接

sdk需要支持App Linking跳转,是否能提供一些线上的链接用于测试。

HarmonyOS
2024-12-23 15:18:01
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
Heiang
import common from '@ohos.app.ability.common';
import { BusinessError } from '@ohos.base';

@Entry
@Component
struct Index {
  build() {
    Button('start link', { type: ButtonType.Capsule, stateEffect: true })
      .width('87%')
      .height('5%')
      .margin({ bottom: '12vp' })
      .onClick(() => {
        let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
        let link: string = "https://saas.matetrip.cn/?from=failed"; // HarmonyOS应用 趣南浔
        // 仅以App Linking的方式打开应用
        context.openLink(link, { appLinkingOnly: true })
          .then(() => {
            console.info('openlink success.');
          })
          .catch((error: BusinessError) => {
            console.error(`openlink failed. error:${JSON.stringify(error)}`);
          });
      })
  }
}

将appLinkingOnly参数设为false或者默认,则为App Linking优先的方式打开应用。若有App Linking匹配的应用,则直接打开目标应用。若无App Linking匹配的应用,则尝试以Deep Linking的方式打开应用。

appLinkingOnly链接:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-app-ability-openlinkoptions-V5#属性

App Linking Kit开发指南:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/app-linking-startup-V5

分享
微博
QQ
微信
回复
2024-12-23 17:16:57
相关问题
HarmonyOS 如何安装测试app
366浏览 • 1回复 待解决
HarmonyOS浏览器scheme链接唤起APP问题
1551浏览 • 1回复 待解决
HarmonyOS APP无法链接数据线安装9568289
633浏览 • 1回复 待解决
HarmonyOS 测试时如何安装app
496浏览 • 1回复 待解决
HarmonyOS APP上架前测试验收
388浏览 • 1回复 待解决
测试脚本运行时安装app报错
751浏览 • 1回复 待解决