import React, { useState, useEffect } from 'react'; import {View, Alert } from 'react-native'; import messaging from '@react-native-firebase/messaging'; import Elements from './elements.js'; export default function Notification() { const [notification, setnotification] = useState(null) const [shownotification, setshownotification] = useState(false) useEffect(() => { const unsubscribe = messaging().onMessage(async remoteMessage => { PushNotification.localNotification({ title: remoteMessage.notification.title, message: remoteMessage.notification.body, playSound: false, soundName: "default" }) setnotification(null) setnotification(remoteMessage.notification) setshownotification(true) }); return unsubscribe; }, []); }