Skip to content

Commit

Permalink
fix: fcm HTTP -> HTTP v1으로 버전 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin0409 committed Jun 20, 2024
1 parent f6d8395 commit 6c1bdc1
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions backend/fastapi/app/fcm_notification.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,34 @@
from pyfcm import FCMNotification
import firebase_admin
from firebase_admin import credentials
from firebase_admin import messaging

from .config import Config

push_service = FCMNotification(Config.fcm_server_key)
cred_path = Config.cred_path
cred = credentials.Certificate(cred_path)
firebase_admin.initialize_app(cred)



async def send_push_notification(token, title, body, data):

result = push_service.notify_single_device(
'''result = push_service.notify_single_device(
registration_id=token,
message_title=title,
message_body=body,
data_message=data
)'''

message = messaging.Message(
notification=messaging.Notification(
title=title,
body=body
),
data=data,
token=token
)
print("[INFO] push notification sent")

return result
response = messaging.send(message)

print('Successfully sent message:', response)

0 comments on commit 6c1bdc1

Please sign in to comment.