HarmonyOS鸿蒙Next中使用openlink拉起微信小程序

如题,大神们有没有试过在鸿蒙中使用openlink拉起微信小程序

4 回复

URL Scheme:在微信开放平台上指的是小程序链接,应用可根据URL Scheme去拉起微信小程序;

【解决方案】

  1. HTTPS请求方式获取access_token,具体HTTP请求方法可参考getAccessToken,如果是服务商获得其中之一权限集授权后,也可通过使用authorizer_access_token代商家进行调用;
  2. HTTPS请求方式获取generateScheme,请求成功后会返回openlinkopenlink即为生成的小程序scheme码;
  3. 通过Want方式拉起小程序,示例代码如下:
launchMiniProgram() {
  const want: Want = {
    uri: 'weixin://dl/business/?t=xxxx' // 通过步骤二获取到的openlink,即小程序scheme码
  }
  const context = getContext(this) as common.UIAbilityContext;
  context.startAbility(want).then(() => {
    // do something
    ...
    console.info(`launchMiniProgram success.`);
  }).catch(() => {
    // do something
    ...
    console.info(`launchMiniProgram failed.`);
  })
}

更多关于HarmonyOS鸿蒙Next中使用openlink拉起微信小程序的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html


实现过, 是已经支持了的.

在HarmonyOS鸿蒙Next中,使用openlink拉起微信小程序可以通过调用系统的Intent功能实现。首先,确保设备已安装微信。然后,使用Intent设置actionandroid.intent.action.VIEW,并将data设置为微信小程序的URL Scheme。例如:

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("weixin://dl/business/?t=小程序原始ID"));
startActivity(intent);

确保在config.json中声明了相应的权限。这样即可通过openlink拉起微信小程序。

回到顶部