Last active
March 10, 2022 11:09
-
-
Save waylybaye/f0ba12d5f0959adcab998d2675b37760 to your computer and use it in GitHub Desktop.
Send Notification using Telegram when new IAP is purchased
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
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)) | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
这是云函数的代码,打开云函数就能看到了。