Last active
January 9, 2020 01:30
-
-
Save elzup/66d33599362f232dfeb6f6c802718679 to your computer and use it in GitHub Desktop.
Cloud Functions から Firebase Cloud Messaging を呼び出す最小構成
This file contains hidden or 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
| import * as functions from 'firebase-functions' | |
| import * as admin from 'firebase-admin' | |
| admin.initializeApp({ | |
| credential: admin.credential.applicationDefault(), | |
| // databaseURL: 'https://hoge.firebaseio.com/', | |
| }) | |
| export const api = functions.https.onRequest(async (req, res) => { | |
| const message = { | |
| topic: 'TOPIC_NAME', | |
| notification: { | |
| title: '通知デモです', | |
| body: `サーバーは${new Date().getHours()}時です。`, | |
| }, | |
| // priority: 'high', | |
| } | |
| admin.messaging().send(message) | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment