https://stackoverflow.com/questions/1515884/using-javascript-to-truncate-text-to-a-certain-size-8-kb
function toBytesUTF8(chars) {
return unescape(encodeURIComponent(chars));
}
function fromBytesUTF8(bytes) {
return decodeURIComponent(escape(bytes));
}
function truncateByBytesUTF8(chars, n) {
var bytes= toBytesUTF8(chars).substring(0, n);
while (true) {
try {
return fromBytesUTF8(bytes);
} catch(e) {};
bytes= bytes.substring(0, bytes.length-1);
}
}
Firebase Realtime Database
Create new project
Add new firebase realtime database
Let’s design a simple notification database
Secure your firebase database
There are several ways to authenticate a user with firebase. In this case we will use custom token through our API server to shared the same user id of our system with firebase
Access your firebase console and enable authentication product
5.1. Generate admin service account to use in your API Server
5.2. Generate app configuration
Add app -> select web app