-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FCM 준비 #77
base: main
Are you sure you want to change the base?
Conversation
@@ -1,3 +1,5 @@ | |||
firebase-credential.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이것은 지웁시다
_cred = { | ||
"type": "service_account", | ||
"project_id": "postona-6bfc9", | ||
"private_key_id": os.environ.get('FIREBASE_PRIVATE_KEY_ID'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.env.template
에도 추가해주세요~
resp = messaging.send(message) | ||
return resp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit)
resp = messaging.send(message) | |
return resp | |
return messaging.send(message) |
@strawberry.type | ||
class Mutation: | ||
@strawberry.mutation | ||
def send_fcm(self, info: Info, token: str, title: str, body: str) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
알림 보내는 mutation 이 외부로 노출될 때, 우리가 내부적으로 FCM을 쓰는지 다른 방식을 쓰는지 알려줄 필요는 없으므로 이름을 바꾸면 좋을 것 같아요. 내부 구조를 노출하기 위해서가 아닌, 무엇을 하는 뮤테이션인지 설명하기 위해서요.
def send_fcm(self, info: Info, token: str, title: str, body: str) -> None: | |
def send_push_notification(self, info: Info, token: str, title: str, body: str) -> None: |
heroku 에 secret key base64 encode 시켜서 업데이트 해두었습니다. |
"type": "service_account", | ||
"project_id": "postona-6bfc9", | ||
"private_key_id": os.environ.get('FIREBASE_PRIVATE_KEY_ID'), | ||
"private_key": base64.decode(os.environ.get('FIREBASE_PRIVATE_KEY')), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"private_key": base64.decode(os.environ.get('FIREBASE_PRIVATE_KEY')), | |
"private_key": base64.b64decode(os.environ.get('FIREBASE_PRIVATE_KEY')).decode("UTF-8"), |
base64.b64decode
메소드를 사용해야할듯. 그러면 bytearray 가 응답됨. 그걸 다시 UTF-8 로 decode해줘야 정상적인 string이 나옴.
그냥 base64.decode
는 두 번째 인자로 output
이 들어가고, 파일로 결과가 써짐
다른건 다 되는데 private key 부분이 잘 안되네용,,
Pycharm에서 환경 변수 자동으로 넣어주는 기능을 써서 그런가,,?