import firebase_admin
from firebase_admin import credentials
from firebase_admin import messaging
from mama_care_api.settings import *

def send_push_notification_android(device_token, title, body):

    if not firebase_admin._apps:
        cred = credentials.Certificate(MEDIA_ROOT+'/key/mama-care-hub-7a96c-firebase-adminsdk-fbsvc-2957ac3525.json')
        firebase_admin.initialize_app(cred)

    #print(default_app.project_id)
    
    # This registration token comes from the client FCM SDKs.
    registration_token = device_token

    # See documentation on defining a message payload.
    message = messaging.Message(
        data={
            "title": title,
            "body": body,
        },
        token=registration_token,
    )

    # Send a message to the device corresponding to the provided
    # registration token.
    response = messaging.send(message)
    # Response is a message ID string.
    print('Successfully sent message:', response)