简体   繁体   中英

Looking for a secure way to store and read json file in serverless flutter using firebase

I'm making a mobile app using flutter and firebase.

To use Cloud Messaging of firebase, I need to send server key of firebase by putting in headers and sending with http post method.

headers: {
  'Authorization': server key
}

However, it is not a recommended way to use server key. Firebase recommends to download json file of service account and use that file to get JWT token from firebase. Otherwise, I have to use Admin SDK and it's difficult for us because we don't have a backend server.

Therefore, my question is that are there any good ways to store json files in client side or local environment or firebase or Azure and can read the file only when we need it.

Plus, if you know the better way to send FCM from client side, please let me know. Thank you so much for reading it.

I have to use Admin SDK and it's difficult for us because we don't have a backend server.

You can very well use the Admin SDK with Cloud Functions for Firebase , the "serverless framework that lets you run backend code". It is very common to use Cloud Functions to send message requests to the FCM backend, which then routes messages to client apps running on users' devices.

There is actually an official example that demonstrates how to send an FCM notification from a Realtime Database triggered Function. You can adapt it to be triggered by any other available trigger mechanism.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM