Hi I am trying to connect metamask with my react native app using moralis but I don’t know why it does not open my metamask app, there is no error
const {
authenticate,
authError,
isAuthenticating,
isAuthenticated,
user,
logout,
Moralis,
} = useMoralis();
const login = async () => {
if (!isAuthenticated) {
await authenticate()
.then(function (user) {
console.log(user?.get("ethAddress"));
})
.catch(function (error) {
console.log(error);
});
}
}
my app.js file
import 'react-native-gesture-handler';
import './shim.js'
import React, { useEffect, useState, useRef } from 'react';
import { StatusBar, LogBox } from 'react-native';
import { COLORS } from './src/global/theme';
import { createStackNavigator } from '@react-navigation/stack';
import { NavigationContainer } from '@react-navigation/native';
import { MoralisProvider } from "react-moralis";
import Moralis from "moralis/react-native";
import RNBootSplash from "react-native-bootsplash";
import AsyncStorage from '@react-native-async-storage/async-storage';
import { MoralisDappProvider } from './src/Moralis/providers/MoralisDappProvider/MoralisDappProvider';
import {
SafeAreaProvider,
initialWindowSafeAreaInsets,
} from 'react-native-safe-area-context';
import {
useBackButtonHandler,
RootNavigator,
canExit,
setRootNavigation,
useNavigationPersistence,
} from './src/navigation';
// Initialize Moralis with AsyncStorage to support react-native storage
Moralis.setAsyncStorage(AsyncStorage);
const App = () => {
const navigationRef = useRef(null);
setRootNavigation(navigationRef);
useBackButtonHandler(navigationRef, canExit);
useEffect(() => {
RNBootSplash.hide({ fade: true });
}, [])
return (
<MoralisProvider
appId="IkcVaeRwm*******************cJ"
serverUrl="https://*****************:2053/server"
environment="native">
<StatusBar backgroundColor={COLORS.secondary} barStyle='dark-content' />
<SafeAreaProvider initialSafeAreaInsets={initialWindowSafeAreaInsets}>
<RootNavigator ref={navigationRef} />
</SafeAreaProvider>
</MoralisProvider>
)
}
export default App;
my packages.json file:
"dependencies": {
"@babel/preset-env": "^7.18.2",
"@babel/preset-flow": "^7.17.12",
"@babel/preset-react": "^7.17.12",
"@eva-design/eva": "^2.1.1",
"@fortawesome/fontawesome-svg-core": "^6.1.1",
"@fortawesome/free-regular-svg-icons": "^6.1.1",
"@fortawesome/free-solid-svg-icons": "^6.1.1",
"@fortawesome/react-native-fontawesome": "^0.3.0",
"@react-native-async-storage/async-storage": "^1.17.6",
"@react-native-clipboard/clipboard": "^1.10.0",
"@react-native-community/cli-debugger-ui": "^8.0.0",
"@react-native-community/slider": "^4.2.2",
"@react-navigation/bottom-tabs": "^6.3.1",
"@react-navigation/drawer": "^6.4.1",
"@react-navigation/native": "^6.0.10",
"@react-navigation/stack": "^6.2.1",
"@tradle/react-native-http": "^2.0.1",
"@ui-kitten/components": "^5.1.2",
"@walletconnect/client": "^1.7.8",
"@walletconnect/react-native-dapp": "^1.7.8",
"@walletconnect/types": "^1.7.8",
"@walletconnect/web3-provider": "^1.7.8",
"assert": "^2.0.0",
"base-64": "^1.0.0",
"buffer": "^6.0.3",
"crypto-browserify": "^3.12.0",
"env": "^0.0.2",
"eth-lib": "^0.1.29",
"event-emitter": "^0.3.5",
"events": "^1.1.1",
"https": "^1.0.0",
"https-browserify": "^1.0.0",
"keyvaluestorage": "^0.7.1",
"localstorage-polyfill": "^1.0.1",
"lottie-ios": "^3.2.3",
"lottie-react-native": "^5.1.3",
"mobx": "^6.5.0",
"mobx-react": "^7.3.0",
"moralis": "^0.0.99",
"node-libs-browser": "^2.2.1",
"os": "^0.1.2",
"parse": "^3.4.1",
"patch-package": "^6.4.7",
"path-browserify": "^1.0.1",
"postinstall-postinstall": "^2.1.0",
"react": "17.0.2",
"react-blockies": "^1.4.1",
"react-dom": "^18.1.0",
"react-moralis": "^0.2.7",
"react-native": "^0.68.2",
"react-native-bootsplash": "^4.1.3",
"react-native-crypto": "^2.2.0",
"react-native-document-picker": "^8.1.0",
"react-native-dotenv": "^3.3.1",
"react-native-emoji-selector": "^0.2.0",
"react-native-gesture-handler": "^2.4.2",
"react-native-get-random-values": "^1.8.0",
"react-native-image-picker": "^1.1.0",
"react-native-localhost": "^1.0.0",
"react-native-modal": "^13.0.1",
"react-native-navbar-color": "^1.0.3",
"react-native-orientation": "^3.1.3",
"react-native-os": "^1.2.6",
"react-native-paper": "^4.12.1",
"react-native-qrcode-svg": "^6.1.2",
"react-native-randombytes": "^3.6.1",
"react-native-reanimated": "^2.8.0",
"react-native-safe-area-context": "^4.2.4",
"react-native-screens": "^3.13.1",
"react-native-slider": "^0.11.0",
"react-native-sound-player": "^0.12.1",
"react-native-splash-screen": "^3.3.0",
"react-native-stream": "^0.1.9",
"react-native-unimodules": "^0.14.10",
"react-native-vector-icons": "^6.6.0",
"react-native-video": "^2.3.1",
"react-native-video-player": "^0.12.0",
"react-native-web": "^0.17.7",
"react-native-webview": "^11.18.2",
"react-native-youtube-iframe": "^2.2.2",
"react-native-yt-player": "^1.1.0",
"readable-stream": "^3.6.0",
"scrypt-js": "^3.0.1",
"stream": "^0.0.2",
"stream-browserify": "^3.0.0",
"url": "^0.11.0",
"use-deep-compare-effect": "^1.8.1",
"uuid": "^8.3.2",
"web3": "^1.7.3",
"web3-core": "^1.7.3",
"web3-core-helpers": "^1.7.3",
"web3-core-method": "^1.7.3",
"web3-eth-accounts": "^1.7.3",
"web3-utils": "^1.7.3"
},
"devDependencies": {
"@babel/core": "^7.12.9",
"@babel/runtime": "^7.12.5",
"@react-native-community/eslint-config": "^2.0.0",
"babel-jest": "^26.6.3",
"eslint": "^7.32.0",
"jest": "^26.6.3",
"metro-react-native-babel-preset": "^0.67.0",
"react-test-renderer": "17.0.2",
"rn-nodeify": "^10.3.0"
},
"jest": {
"preset": "react-native"
},
"react-native": {
"crypto": "react-native-crypto",
"http": "@tradle/react-native-http",
"https": "https-browserify",
"os": "react-native-os",
"_stream_transform": "readable-stream/transform",
"_stream_readable": "readable-stream/readable",
"_stream_writable": "readable-stream/writable",
"_stream_duplex": "readable-stream/duplex",
"_stream_passthrough": "readable-stream/passthrough",
"stream": "stream-browserify"
},
"browser": {
"crypto": "react-native-crypto",
"http": "@tradle/react-native-http",
"https": "https-browserify",
"os": "react-native-os",
"_stream_transform": "readable-stream/transform",
"_stream_readable": "readable-stream/readable",
"_stream_writable": "readable-stream/writable",
"_stream_duplex": "readable-stream/duplex",
"_stream_passthrough": "readable-stream/passthrough",
"stream": "stream-browserify"
}
}
I have been searching for its solution for 3 days. I would really be thankful if anyone can help