使用功能(分析)观众发送的火力地堡推送通知(Send push notifications in F

2019-09-29 08:41发布

我已经使用由火力地堡功能触发火力地堡云端通讯(FCM)成功发送通知:

const functions = require('firebase-functions');
const admin = require('firebase-admin');
const fs = require('fs');

admin.initializeApp();


exports.testNotif = functions.https.onRequest((request, response) => {

    const mySecretNumber = getRandomInt(147)

    var payload = {
      notification: {
        title: `You got a new Message`,
        body: `My highest break ${mySecretNumber}`,
        badge: mySecretNumber.toString(),
        sound: `notif1.aiff`,
      }
    };
 const ackString = `All done ${mySecretNumber}`;
 console.log(ackString)
 response.send(ackString);
 //send to all topic
 admin.messaging().sendToTopic(`all`, payload)
});


function getRandomInt(max) {
  return Math.floor(Math.random() * Math.floor(max));
}

正如你可以看到我发送通知到一个名为“所有”的话题。

在火力控制台,您可以发送通知给观众,你可以创建。 在我来说,我已经创建了基于来自分析模块的用户属性不同的受众。

是否有可能也可以通过火力地堡功能发送通知给观众?

Answer 1:

没有Analytics(分析)API检索陷入具体分析受众用户。 也没有一个FCM API将通知发送到这样的听众。

如果您想将通知发送给观众,你必须创建自己的定义,这些观众的方式。 最直接的办法就是谷歌Analytics(分析)的火力地堡连接至BigQuery,然后定义您收到那里的分析事件的观众。



文章来源: Send push notifications in Firebase using functions to (analytics) audiences