I have implemented MetaMask reactnative sdk, its working properly on ios, but on android the approve prompts doesnt come at all.
After debugging the issue I found that in android that the prompts are coming up when we call the methods from root file. And when called from some internal screens, the redirect is happenning, but the bottomsheet prompts aren’t coming up.
Are there any alternatives, and why is it only working from the root file, can anyone please help me with this. This is code of root file where it works, but when the button, connectmetamask function and MetaMaskSDK are moved to the internal screen then the prompts arent coming up, only the redirect is happenning.
import './shim';
import {AppRegistry, Button, Linking} from 'react-native';
global.btoa = global.btoa || require('base-64').encode;
global.atob = global.atob || require('base-64').decode;
import * as React from 'react';
import MetaMaskSDK from '@metamask/sdk';
import BackgroundTimer from 'react-native-background-timer';
const MMSDK = new MetaMaskSDK({
openDeeplink: link => {
Linking.openURL(link);
},
timer: BackgroundTimer,
dappMetadata: {
name: 'test',
url: 'test.com',
},
});
const ethereum = MMSDK.getProvider();
export const Applogic = () => {
const connectMetamask = async () => {
try {
const accounts = await ethereum.request({method: 'eth_requestAccounts'});
console.log(accounts);
} catch (e) {
console.log(e);
}
};
return <Button title="connect" onPress={connectMetamask} />;
};
AppRegistry.registerComponent("app", () => Applogic);