Skip to content

Instantly share code, notes, and snippets.

@waylybaye
Last active March 10, 2022 11:09
Show Gist options
  • Save waylybaye/f0ba12d5f0959adcab998d2675b37760 to your computer and use it in GitHub Desktop.
Save waylybaye/f0ba12d5f0959adcab998d2675b37760 to your computer and use it in GitHub Desktop.
Send Notification using Telegram when new IAP is purchased
const functions = require('firebase-functions');
const TelegramBot = require('node-telegram-bot-api');
const token = "***"
const chatID = 1024 // your telegram id, you must first send a message to your bot
exports.notifyIAP = functions.analytics.event('in_app_purchase').onLog((event) => {
const purchaseValue = event.valueInUSD;
if (purchaseValue > 0) {
const bot = new TelegramBot(token, {polling: false});
return bot.sendMessage(chatID, "苹果宝到账: $" + (purchaseValue * 0.7).toFixed(2))
}
});
@waylybaye
Copy link
Author

你好,如何才能得到 firebase events,一个event被出发,firebase console里面好像没有可以指定后续动作的地方,谢谢

这是云函数的代码,打开云函数就能看到了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment