Reputation: 99
Hey I am trying to send notification inside from my flutter app to another app. But could not find anything. How can i implement this? Please help me. Thank you.
Upvotes: 0
Views: 565
Reputation: 1031
You can create a callable cloud function that sends an FCM notification.
exports.sendNotif = functions.https.onCall(async (data, context) => {
// Your notification sending code here, something like
// await admin.messaging().sendMulticast({data: ..., tokens: ...});
});
use cloud_function
package from pub.dev to call this function from your flutter app.
final callable = FirebaseFunctions.instance.httpsCallable('sendNotif');
await callable();
You can see why this is not a viable option, you need to have the service account JSON key shipped with the flutter app, so theoretically any user can easily send any notifications by getting their hands on the key.
Using the cloud functions (or a server) approach lets you specify the things that should be sent and who can send them.
Upvotes: 3
Reputation: 983
You should have a server that connects to the firebase account that you want then get your request from the first app and send a notification to the app and token that you want.
Upvotes: 1