1

I'm trying to create a searchable field that searches the registered users in the Firebase application and return a list of all close matches. The reason for this is I need to find the searched users uid to invite them to a game, and then deliver a push notification to alert them that an invite has been received. I don't know if this is possible as the documentation seems to suggest it has to be a 1 to 1 match against the email address for it to be returned.

The problem I'm experiencing is the admin.auth() from firebase-admin requires node modules to perform the related work. So I'm wondering if there is another SDK that allows you to do so or can this functionality be produced using the standard firebase import in a React Native expo application.

Unfortunately, I have no code as nothing seems to work and all point to using the firebase-admin package in a node-based project to do the dirty work of the query.

halfer
  • 19,824
  • 17
  • 99
  • 186
Chris Marshall
  • 740
  • 1
  • 9
  • 25

1 Answers1

1

There is no way to search across all Firebase Authentication users with just a client-side SDK like the one for React Native. Allowing that would be a pretty big security risk.

There are two common approaches to allow searching the users in a secure way:

  1. Write information about each user to a database (such as Cloud Firestore or the Realtime Database) when they register, and then search the database when needed. That way your code controls what data gets written and thus is searchable.

  2. Firebase has Admin SDKs that run in trusted environments, such as your development machine, a server you control, or Cloud Functions. These SDKs have options to list users, which means you can search them. If you wrap one of the Admin SDKs in a custom API that you build and secure yourself, you can then call that from your application code.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807