【问题标题】:Moralis Integration in Ionic Angular (typescript)Ionic Angular 中的 Moralis 集成(打字稿)
【发布时间】:2022-08-18 18:13:37
【问题描述】:

我正在用离子角度(打字稿)创建一个应用程序。此应用程序将在 android 和 iOS 设备上运行。 我正在集成 Moralis SDK,以便可以连接到 Metamask 钱包。

这是我到目前为止所做的,我被困住了

  1. 创建了一个新的离子项目
  2. 通过 npm 安装了moralis 包
  3. 使用应用程序 ID 和服务器 URL 初始化 Moralis
  4. 使用以下代码进行身份验证:
       
    this.user = await Moralis.authenticate({
            signingMessage: \"Log in using Moralis\",
          })
            .then(function (user) {
              console.log(\"logged in user:\", user);
              console.log(user.get(\"ethAddress\"));
            })
            .catch(function (error) {
              console.log(error);
            });
    
    

    我收到一个错误,上面写着

    错误:未启用以太坊的浏览器

    我还尝试通过 ionic serve 运行该项目,当我单击登录按钮时它会打开 Metamask 扩展,然后对应用程序进行身份验证。

    当我单击登录按钮进行身份验证时,我希望 Metamask 钱包应用程序在我的 android 设备中打开。

    谁能帮我吗?或者告诉我是否有现有的 ionic 样板项目?

    标签: angular typescript metamask moralis


    【解决方案1】:

    通用汽车在那里!

    对于 ionic mobile,您不应期望 Metamask 按钮与 Metamask mobile 一起使用,因为 Metamask 身份验证旨在工作只要在桌面浏览器上使用 Metamask 浏览器扩展。

    这就是 Metamask 身份验证在浏览器环境之外不起作用的原因。

    对于移动设备,可以通过 WalletConnect(Metamask 移动设备与 WC 兼容)或使用 Metamask 移动应用程序中的应用内浏览器访问 Metamask 移动设备。

    干杯~

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-07-30
      • 2018-09-25
      • 1970-01-01
      • 2021-09-09
      • 2017-06-22
      • 2016-09-02
      • 1970-01-01
      • 2022-07-06
      相关资源
      最近更新 更多