import asyncio
from typing import List, Dict, Any
import httpx

EXPO_PUSH_URL = "https://exp.host/--/api/v2/push/send"

async def send_push_notification(
    tokens: List[str],
    title: str,
    body: str,
    data: Dict[str, Any] = None
):
    """Expo Push API를 통해 알림 전송"""
    messages = [
        {
            "to": token,
            "sound": "default",
            "title": title,
            "body": body,
            "data": data or {},
            "priority": "high",
            "channelId": "default",
        }
        for token in tokens
    ]
    
    try:
        async with httpx.AsyncClient() as client:
            response = await client.post(
                EXPO_PUSH_URL,
                json=messages,
                headers={"Content-Type": "application/json"}
            )
            result = response.json()
            return result
    except Exception as e:
        print(f"Error sending push notification: {e}")
        return None 