-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop_back' into develop
- Loading branch information
Showing
9 changed files
with
1,608 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +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( | ||
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 | ||
) | ||
|
||
def send_push_notification(token, body, title): | ||
|
||
result = push_service.notify_single_device(registration_id=token, message_title=title, message_body=body) | ||
response = messaging.send(message) | ||
|
||
return result | ||
print('Successfully sent message:', response) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.