Removes a Firebase Cloud Messaging (FCM) token from the user’s registered devices. Call this when user logs out or disables notifications.
cURL
curl --request POST \ --url http://localhost:3000/api/notifications/remove-fcm-token \ --header 'Content-Type: application/json' \ --data ' { "deviceId": "device_abc123" } '
{ "success": true, "message": "FCM token removed successfully" }
import * as Device from "expo-device"; // On logout async function handleLogout() { // Remove FCM token await fetch("/api/notifications/remove-fcm-token", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ deviceId: Device.deviceId, }), }); // Continue with logout... }
import { useRemoveFCMToken } from '@/hooks/notifications/useFCMTokenRegistration'; function LogoutButton() { const { mutate: removeToken } = useRemoveFCMToken(); const handleLogout = () => { removeToken(Device.deviceId, { onSuccess: () => { console.log('Token removed successfully'); // Continue with logout }, }); }; return <Button onPress={handleLogout}>Logout</Button>; }
fcmTokens
Unique identifier for the device to remove
"device_abc123"
FCM token removed successfully
Whether the operation was successful
true
Success message
"FCM token removed successfully"