I'm developing a web app which relies on realtime sync through Firebase firestore in Cordova.
I tried to use one specific plugin without success.
I ended up using just web calls like this:
index.html
I loaded
https://www.gstatic.com/firebasejs/5.8.0/firebase-app.js
https://www.gstatic.com/firebasejs/5.8.0/firebase-firestore.js
and I added to head
<meta http-equiv="Content-Security-Policy" content="
    default-src 'self' *.googleapis.com data: gap:
        https://ssl.gstatic.com;
    script-src 'self' 'unsafe-inline' 'unsafe-eval'
        https://*.gstatic.com https://*.googleapis.com;
    style-src 'self' 'unsafe-inline';
    media-src *;
    connect-src *
">
index.js
firebase.initializeApp({
     apiKey: 'my_api_key',
     authDomain: 'localhost',
     projectId: 'my_projectid'
});
var db = firebase.firestore();     
function loadMessages() {
    var query = firebase.firestore()
                    .collection('my_collection');
    // Start listening to the query.
    query.onSnapshot(function(snapshot) {
        snapshot.docChanges().forEach(function(change) {
            if (change.type === 'removed') {
                console.log("deleted"+change.doc.id);
            } else {
                var message = change.doc.data();
                //change color and text
                console.log(change.doc.id+": "+message.status);
                }
            }
        });
    });
}
// We load currently existing chat messages and listen to new ones.
loadMessages();
it works but I'm wondering if there is there any security risk in this approach?
Especially because api_key remains exposed...
EDIT
As metioned in the bottom comments of:
Is it safe to expose Firebase apiKey to the public?
How can I prevent my apikey to be used by someone else and then getting billed by Google for the calls I did not generate? Is there a way to allow calls only from my app "com.example.app" ?
Thanks