Get user's token

app.js

import { fetchToken, onMessageListener } from '../App/Configs/firebase';
import { useToast } from '@chakra-ui/react';

function App(){
const [tokenId, setTokenId] = useState("")
const toast = useToast()
    
const getNotif = async () => {
        try {
            onMessageListener(toast)
        } catch (error) {
            toast({
                title: error,
                description: error,
                position: 'top-right',
                isClosable: true,
            })
        }
    }
    
    useEffect(() => {
        getNotif()
        fetchToken(setTokenId);
    }, [])

    return(
        <YourApp/>
        )
}

Last updated

Was this helpful?