-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feat]: Topic을 활용한 FCM push 로직 구성 (#124)
1. FCM push 활용을 위한 firebase-admin 설정 2. json도 불러올 수 있게끔 tsconfig.json 변경 3. pushJob을 모듈 단위로 설정할 수 있게끔 설정 4. 푸시 테스트를 위해 필요 로직 주석 처리
- Loading branch information
Showing
9 changed files
with
1,862 additions
and
54 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
*.env | ||
env_files/* | ||
db_data | ||
pog-adminsdk.json | ||
|
||
# compiled output | ||
/dist | ||
|
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
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { PushJobService } from './PushJobService'; | ||
|
||
@Module({ | ||
providers: [PushJobService], | ||
exports: [PushJobService], | ||
}) | ||
export class PushJobModule {} |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
|
||
import * as admin from 'firebase-admin'; | ||
import { ServiceAccount } from 'firebase-admin'; | ||
import * as serviceAccount from '../../../../../pog-adminsdk.json'; | ||
|
||
@Injectable() | ||
export class PushJobService { | ||
constructor() { | ||
admin.initializeApp({ | ||
credential: admin.credential.cert(serviceAccount as ServiceAccount), | ||
}); | ||
} | ||
|
||
async send(summonerId: string) { | ||
const message = { | ||
notification: { | ||
title: 'test', | ||
body: 'test', | ||
}, | ||
topic: summonerId, | ||
}; | ||
return Promise.all([await admin.messaging().send(message)]); | ||
} | ||
} |
Oops, something went wrong.