I'm using a free trial of Google Cloud and I'm almost halfway through the free credit. I don't know if I'm doing something wrong or if it just costs more than I expected, so I was looking at the pricing and realized I don't understand most of it. I'm just learning and having fun so I don't actually want to spend money (or at least not that much), so anything to help make the free credits last the year would be great :)
https://firebase.google.com/pricing/
What I did with my function is get information from Firebase Database for notifications and then send the notification using Firebase Messaging. Here's the code, if it helps.
'use strict';
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.sendNotifications = functions.database.ref('/Notifications/{pushID}/title')
.onWrite(event => {
if (!event.data.exists())
return;
event.data.ref.parent.once('value').then(function(dataSnapshot){
// Grab the eventName and the message
const title = dataSnapshot.child('title').val();
const message = dataSnapshot.child('message').val();
const recipients = dataSnapshot.child('recipients').val();
const tag = dataSnapshot.child('tag').val();
const payload = {
notification:{
title: title,
body: message,
tag: tag,
color: "#51E0F5",
sound: 'default'
},
};
const options = {
priority: 'high',
collapseKey: 'chat',
timeToLive: 3600 // 6 days
};
// Get rid of this Notification in Firebase
event.data.ref.parent.remove();
// Create notification
if (recipients != null)
{
return admin.messaging().sendToDevice(recipients, payload, options);
}
else
{
return;
}
});
})
According to the transactions, I used
How do I stop using App Engine Flex Instance? What is it? Or is it time to look for a replacement before they start charging my card.
Thank you!
App Engine attempts to keep manual and basic scaling instances running indefinitely. However, at this time there is no guaranteed uptime for manual and basic scaling instances.
Instances are the computing units that App Engine uses to automatically scale your application. At any given time, your application can be running on one instance or many instances, with requests being spread across all of them.
You can stop all instances in flexible app engine by stopping the VERSION. I use this all the time for development - no sense in keeping things running overnight.
Go to your google cloud platform console, select app engine, then select version. Check the version you want to stop, and then click stop at the top. Note that you can't actually DELETE your last version, but you CAN stop it :) This shuts down all instances.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With