import React, { useEffect, useState } from 'react'; import { StyleSheet, Alert } from 'react-native'; import { ThemedText } from '@/components/theme/Theme'; import { Colors } from '@/constants/Colors'; import { useColorScheme } from '@/hooks/useColorScheme'; import FontAwesome from '@expo/vector-icons/FontAwesome'; import Button from '@/components/theme/buttons/DefaultButton'; import { getUser } from '@/components/services/SecureStore'; import { sendPushNotification } from '@/components/services/notifications/PushNotificationManager'; import type { NotificationMessage } from '@/constants/Types'; const TestPush = () => { const scheme = useColorScheme() ?? 'dark'; const [pushToken, setPushToken] = useState(null); useEffect(() => { const fetchUserData = async () => { const user = await getUser(); if (user) { setPushToken(user.pushToken); } }; fetchUserData(); }, []); const message: NotificationMessage = { sound: 'default', title: 'Test push notification', body: 'This is a test push notification', data: { test: 'test', }, }; const handleSendPushNotification = async () => { try { await sendPushNotification(pushToken, message); Alert.alert('Success', 'Push notification sent successfully.'); } catch (error) { Alert.alert('Error', 'Failed to send push notification.'); } }; return ( ); }; export default TestPush; const styles = StyleSheet.create({ buttonLabel: { fontSize: 16, }, buttonIcon: { paddingRight: 8, }, });