Ethereum React Native Chat Boilerplate Questions

Here is also the Cloud Function

//Get All Messages
Moralis.Cloud.define("getAllMessages", async function (request) {
  
  const query = new Moralis.Query("Messages");
  const result = await query.find();
  const userQuery = new Parse.Query("User");
  const userResult = await userQuery.find({ useMasterKey: true});

  logger.info("data", result);
  const messages = result.map((data) => {
    return userResult.map((rest) => {
      if (data.attributes.userId === rest.id) {
        return {
          data,
          userId: rest.id,
          userName: rest.attributes.username,
          ethAddress: rest.attributes.ethAddress,
          profilePicture: rest.attributes.profilePicture,
        }
      }
    }).filter(n => n);
  })
  return messages;
});
  
Moralis.Cloud.define("getTypingUser", async function (request) {
  const query = new Moralis.Query("UserTyping");
  query.equalTo("userId", request.params.userId);
  const result = await query.find();
  return result;
});

Hello,
How to let only owner of an nft collection to join the group chat ?
Thanks

You could use the API e.g. getTokenIdMetadata to find the owner_of address of a particular NFT and only allow access based on this ownership.

If you mean owner of the contract, you could call the owner function on the contract to get the owner address.

Hey,
How to turn it to a web version ?
Thanks

Hello could you add more details on what you mean.

So i don’t want an app, I want it working on a website

You can take the principles of this boilerplate (how the chat is set up, etc.), and apply it to a site/app with another framework e.g. with React (and react-moralis).

I have followed instructions in video but my ios simulator doesn’t have Metamask and is failing to open it. What can I do with it?

You’ll need to install the MetaMask app.

1 Like

Thanks for response! But I can’t install Metamask to iOS simulator. Maybe I’m doing smth wrong (

Do you get an error? You can look up some tutorials on how to install apps.

I have faced Error while connecting the wallet
Possible Unhandled promises Rejection (id:1):
Error: No wallets found

Please any one help me

Do you have a mobile wallet app installed e.g. MetaMask or Trust Wallet?

Yeah I have installed Meta Mask app in my mobile

Make sure you have added your serverUrl and appId here and renamed to .env.

Can you try installing another wallet like Trust Wallet. Are you using an emulator or physical device? Usually the boilerplate can pick up any wallets by default when you go to authenticate but it leads to other errors like this one.

The server URL and app id were added in .env file.
Am using a physical device. I will try to add trust wallet.

when i click Crypto wallet login in my moralis app its redirect to walletconnect.com/wallets page and that page got 404 Error.

For that issue, read this.

Thank you I resolved this problem and after that, I got another error

Unhandled promise Rejection
Error : Invalid function: “getAllMessages”

When does this error happen? Do you know where getAllMessages is in the boilerplate code or is this your own? If you’re trying to call a cloud function from your server, then it doesn’t exist.