Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

支付宝小程序 Taro.canIUse('getDeviceInfo') 返回 true,但是 Taro.getDeviceInfo() 返回的信息不正确 #17309

Open
shushu2013 opened this issue Feb 9, 2025 · 2 comments

Comments

@shushu2013
Copy link
Contributor

Taro 环境

👽 Taro v3.6.21


  Taro CLI 3.6.21 environment info:
    System:
      OS: macOS 15.1.1
      Shell: 5.9 - /bin/zsh
    Binaries:
      Node: 16.20.0 - ~/.nvm/versions/node/v16.20.0/bin/node
      Yarn: 1.22.22 - ~/.nvm/versions/node/v16.20.0/bin/yarn
      npm: 8.19.4 - ~/.nvm/versions/node/v16.20.0/bin/npm
    npmPackages:
      @tarojs/components: 3.6.21 => 3.6.21
      @tarojs/helper: 3.6.21 => 3.6.21
      @tarojs/mini-runner: 3.6.21 => 3.6.21
      @tarojs/plugin-framework-react: 3.6.21 => 3.6.21
      @tarojs/plugin-html: 3.6.21 => 3.6.21
      @tarojs/plugin-platform-alipay: 3.6.21 => 3.6.21
      @tarojs/plugin-platform-h5: 3.6.21 => 3.6.21
      @tarojs/plugin-platform-jd: 3.6.21 => 3.6.21
      @tarojs/plugin-platform-qq: 3.6.21 => 3.6.21
      @tarojs/plugin-platform-swan: 3.6.21 => 3.6.21
      @tarojs/plugin-platform-tt: 3.6.21 => 3.6.21
      @tarojs/plugin-platform-weapp: 3.6.21 => 3.6.21
      @tarojs/react: 3.6.21 => 3.6.21
      @tarojs/runtime: 3.6.21 => 3.6.21
      @tarojs/shared: 3.6.21 => 3.6.21
      @tarojs/taro: 3.6.21 => 3.6.21
      @tarojs/webpack-runner: 3.6.21 => 3.6.21
      babel-preset-taro: 3.6.21 => 3.6.21
      eslint-config-taro: 3.6.21 => 3.6.21
      react: ^18.0.0 => 18.0.0

这个特性解决了什么问题?

支付宝小程序 Taro.canIUse('getDeviceInfo') 返回 true,但是 Taro.getDeviceInfo() 返回的信息不正确

my.getDeviceBaseInfo:https://opendocs.alipay.com/mini/071680?pathHash=92d76c0e

支付宝小程序提供的是 my.getDeviceBaseInfo

方案1、Taro.getDeviceInfo() 在支付宝小程序上,底层应该是要调用支付宝的 getDeviceBaseInfo 获取对应的信息
方案2、如果不支持第一种方案,则 Taro.canIUse('getDeviceInfo') 在支付宝小程序上应该返回 false

这个 API 长什么样?

Taro.canIUse('getDeviceInfo') 或 Taro.getDeviceInfo() 在支付宝小程序上,表现正常

@TheKonka
Copy link
Member

除非有一些api会特殊处理,默认的api调用都是直接换成my.来调用的,你也可以直接在代码里面用my.来调用试下

@shushu2013
Copy link
Contributor Author

shushu2013 commented Feb 10, 2025

my.canIUse('getDeviceInfo') 返回了 true
my.getDeviceInfo() 返回的也不是设备信息
那应该是支付宝接口的问题,有这个 getDeviceInfo,但是不能直接获取设备信息,所以官方 api 换了个名字 my.getDeviceBaseInfo

Taro 这边是否特殊处理下支付宝的这种情况

This was referenced Feb 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants