Incorporating Moralis into Ionic Angular with TypeScript

I'm currently developing an app using Ionic Angular (TypeScript) that will be compatible with both Android and iOS devices. I've decided to incorporate the Moralis SDK to establish a connection with the Metamask wallet.

Here's a summary of the steps I've taken so far and the obstacle I'm facing:

  1. Created a new Ionic project
  2. Installed the Moralis package using npm
  3. Initialized Moralis with the application ID and server URL
  4. Attempted to authenticate using the following code:
   
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);
        });

Unfortunately, I encountered an error message:

Error: Non ethereum enabled browser

I also tried running the project through Ionic serve, which successfully opened the Metamask extension upon clicking the login button and authenticated the application.

My goal is to have the Metamask wallet application open on my Android device when I click the login button for authentication.

If anyone has any solutions or recommendations, or if there are existing boilerplate projects for Ionic that I can refer to, I would greatly appreciate the assistance.

Answer №1

Good day!

When it comes to using the Ionic mobile platform, it's important to note that the Metamask button functionality is not compatible with Metamask mobile. This is because the Metamask authentication system is specifically designed to work exclusively with the Metamask browser extension on desktop browsers.

As a result, the Metamask authentication feature will not work outside of a browser environment.

For mobile usage, Metamask mobile can be accessed through WalletConnect (as it is compatible with WalletConnect) or by utilizing the in-app browser within the Metamask Mobile App.

Here's to smooth sailing ahead~

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Executing one controller function from another controller in Typescript

There are two typescript controllers in my project Controller A { public methodOfA() {//perform some action} } Controller B { public methodOfB() {//perform some action} } I am trying to implement the following functionality Controller B { ...

Can type safety be ensured for generic abstract methods without the use of superclass generics?

I am currently dealing with a situation where I have an abstract class that contains generic types for internal purposes only: public abstract class ParentClass<T, U> { // Some common code to prevent code duplication in child classes protect ...

Navigating through React with Typescript often involves managing the process of waiting for an API call to finish

My interface structure is as follows: export interface Chapter{ id: string, code: string } Within a component, I am making an API call in the following manner: componentDidMount() { fetch("https://someapi/getchapter") .then(r ...

Is there a way to help my KafkaJS consumer stay patient while waiting for a broker to become available?

My KafkaJS consumer setup looks like this: // Create the kafka client const kafka = new Kafka({ clientId, brokers, }); // Create the consumer const consumer = this.kafka.consumer({ groupId, heartbeatInterval: 3000, sessionTimeout: 30000, }); // ...

Optimal scenarios for implementing computed/observables in mobx

I understand most of mobx, but I have a question regarding my store setup. In my store, I have an array of objects as observables using TypeScript: class ClientStore { constructor() { this.loadClients(); } @observable private _clients ...

Can the NgModule objects be imported from an external file?

One of my goals is to streamline the organization of my app by putting everything into logical files. I frequently do this in C#. Is there a way to extract declarations into a separate file and then assign the value to the declarations variable on NgModule ...

Problem with Angular Slider

I'm in the process of creating a carousel component in Angular, but I'm facing an issue where the carousel is not appearing as it should. Below is the code for my carousel component. carousel.component.html: <div class="carousel"> ...

Is it possible for a d3 chart to render twice in one area if it's rendered in two different places?

When attempting to showcase two distinct d3 pie charts on my webpage within individual mat-cards, they both end up displaying in the svg tag of the first d3 chart in my code. This is what my code looks like: <section class="three"> <! ...

Angular router link circles back to its originator

I've been working on a basic login page that transitions to a homepage once the user successfully logs in. So far, I've focused solely on the HTML structure of the login component without implementing any code in the corresponding TypeScript file ...

What is the best approach to implementing a blur function for a specific input within a parent component?

I have created a custom input field as a separate component. I want to include multiple input fields in the parent component using directives: <app-input ...></app-input> My goal is to pass the blur event/function to the parent component speci ...

Exploring potential arrays within a JSON file using TypeScript

Seeking guidance on a unique approach to handling array looping in TypeScript. Rather than the usual methods, my query pertains to a specific scenario which I will elaborate on. The structure of my JSON data is as follows: { "forename": "Maria", ...

What could be causing the TypeScript type error within this Effector effect subscriber?

Working on a front-end application utilizing React, Typescript, Effector, FetchAPI, and other technologies. Created an Effector effect to delete an item in the backend: export const deleteItemFX = createEffect({ handler: (id: string) => { return ...

What is the best way to add all IDs to an array, except for the very first one

Is there a way to push all response IDs into the idList array, excluding the first ID? Currently, the code below pushes all IDs to the list. How can it be modified to exclude the first ID? const getAllId = async () => { let res = await axios({ m ...

Removing spaces within brackets on dynamic properties for objects can be achieved by utilizing various methods such as

I've encountered an issue with my code that involves getting spaces within square brackets for the dynamic properties of an object. Even after searching through Code Style/Typescript/Spaces, I couldn't find any settings to adjust this. Could thes ...

Having trouble initiating an application using a component other than the AppComponent

In my Angular project, I am trying to initiate the Application with FleshScreenComponent instead of AppComponent. Even after replacing appComponent with FleshScreenComponent in the bootstrap of module.ts file, I am encountering an error: The selector " ...

The button values fail to adhere to the specified input length in the Point of Sale application built with Angular

Having an issue with my Point of Sale app. When I enter values using the keyboard, it respects the maxLength limit, but when I enter values using the buttons, it does not respect the limit. Any ideas on how to solve this? <div mat-dialog-content> < ...

`In TypeScript Angular, encountering challenges with accessing object properties`

My TypeScript object looks like this const playlist: { tracks: Array<Track> } = { tracks: new Array<Track>() }; This is the Track interface I am working with interface Track { title?: string; album?: string; artists?: string; duration? ...

Issue with exporting member in VS Code but not in console

I currently have a NestJS project (project A) with one module that utilizes the @nestjs/typeorm and typeorm packages. In my other NestJS project (project B), I plan to use this module. However, there is a potential issue. Project B contains entities that ...

The Angular router outlet is seamlessly activating without any manual intervention

Within the main view, a mat-button-toggle-group is used to toggle between a grid and list layout. The grid layout utilizes router-outlet to display the child component <router-outlet></router-outlet>, while the list layout directly implements t ...

The most efficient method for distributing code between TypeScript, nodejs, and JavaScript

I am looking to create a mono repository that includes the following elements: shared: a collection of TypeScript classes that are universally applicable WebClient: a react web application in JavaScript (which requires utilizing code from the shared folde ...