React-Native firebase auth difficulties

Viewed 39

I am trying to log a user out and I am getting this error. I even tried to unsubscribe() but maybe I am doing it wrong because I am getting this error Uncaught Error in onSnapshot:, [FirebaseError: Missing or insufficient permissions.] Please can I get someone's help on how exactly to do this because I am really lost.

This is my code:

import { PURGE } from "redux-persist";

const Settings = () => {
  const currentUser = firebase.auth().currentUser.uid;

  const unsubscribeUser = firebase
    .firestore()
    .collection("Users")
    .doc(currentUser)
    .onSnapshot((doc) => {
      //do things
    });
    
  const unsubscribePosts = firebase
    .firestore()
    .collection("Posts")
    .doc(currentUser)
    .onSnapshot((doc) => {
      //do things
    });

  const SignOut = () => {
    unsubscribeUser();
    unsubscribePosts();
    dispatch(reset([]));
    dispatch({
      type: PURGE,
      key: "root",
      result: () => null,
    });
    firebase.auth().signOut();
  };

  return <Button onPress={SignOut} title="Delete and Logout" />;
};

export default Settings;
0 Answers
Related