How can I use Firebase Functions to send FCM to user?

前端 未结 1 664
灰色年华
灰色年华 2020-11-30 12:56

Firebase currently rolled out Firebase Functions to add server side code

Firebase Functions

I was wondering if there could be a way to call

相关标签:
1条回答
  • 2020-11-30 13:33

    Firebase SDK for Cloud Functions includes the Firebase Admin SDK, you can find an example that we made here Send Firebase Cloud Messaging notifications for new followers

    In brief:

    const functions = require('firebase-functions');
    const admin = require('firebase-admin');
    admin.initializeApp(functions.config().firebase);
    
    exports.foo = functions.database.ref('/bar').onWrite(event => {
      const tokens = ...;
      const payload = ...;
      return admin.messaging().sendToDevice(tokens, payload);  
    })
    
    0 讨论(0)
提交回复
热议问题