import firebase_admin
from firebase_admin import messaging


def send_firebase_notification(firebase_token, title, body):
    message = messaging.Message(
        notification=messaging.Notification(title=title, body=body),
        token=firebase_token,
    )
    response = messaging.send(message)
    return response


def send_notification_to_all_customers_firebase(title, body):
    message = messaging.Message(
        notification=messaging.Notification(
            title=title,
            body=body
        ),
        topic="all",
    )

    response = messaging.send(message)
    print(response)
    return response



def subscribe_to_topic(token):
    try:
        response = messaging.subscribe_to_topic([token], "all")
        print("Subscribed:", response.success_count)
    except:
        print("Topic subscribe error")




