Flutter Firebase apiKey, appId, messagingSenderId and projectId - flutter

I need to use firebase_messaging to send message from my backend to my flutter apk.
When initialize firebase, these are the 4 keys essential in the FirebaseOptions
apiKey : Is this the Server Key found in FCM?
appId : Where can I find this key?
messagingSenderId : Sender ID FCM
projectId : Where can I find this?
Besides, in order for me to send message to a single user. I need to tell Firebase who am I right? May I know which ID shall I use?
Thx

When you register with firebase you obtain the push notification token. This token is used to send a notification to the device the app is installed on.
Assuming you already initialized firebase app in flutter, and you added the google-services.json in your app. You can obtain your push notification token in the following way:
messaging = FirebaseMessaging.instance;
messaging.getToken().then((value){
print(value); //this is the push notification token
});
You can also test that you are able to receive the notification on the app from the firebase console. You can send a notification to the app under Compose notification section in the firebase console. It only requires the notification token you obtained from the app.

Related

I already get fcm key of ever users,How to send notification to another user with firebase cloud messaging?In dart

I have Fcm key
and working when i put fcm trial of cloud messageing in firebase
I tried but only got same device notification,
I am expecting that when I send a message to another user The other user need to get a notification while the app is not opened

How to setup push notification with supabase in flutter?

I had just replaced my app with supabase from firebase in flutter app.
Firebase has firebase_messaging that provide push notification to device token.
Is there any facilities to create function in supabase and send notification to selected user with device token while changing in database.
If yes than please suggest some function else suggest some method to send notification.
Supabase does not provide a mechanism to send push notifications at this point, so you can use FCM or other push notification sending services to send them out to the users.
If you are going with FCM, you can setup your own backend using Firebase cloud functions or other backend service that you prefer to send the notifications from.
Typically, you would want to send push notifications to your users when there is some kind of change in the database, like when there was a new message sent or someone liked a post. You can listen to these events using Supabase database webhooks. With database webhooks, you can send your backend a request whenever you receive certain data change happening in your database.

Ionic Capacitor One-To-One Chat Notification

Here's the thing:
I've made an one-to-one private chat with ionic capacitor, saving messages in Cloud Firestore. By far it's working fine. Both users can send and recieve messages.
On the other hand, I've made push notification with FCM(Firebase Cloud Messaging) according to official document of capacitor(https://capacitorjs.com/docs/guides/push-notifications-firebase) and from console of Firebase I can publish notificationes to certain device as I've got their tokens.
So, can I implement message notification using FCM as well when a user recieve a new message? Just like whatsapp, wechat o others common chat apps.
Attention: I'm using Ionic Capacitor + Angular. NOT cordova.
I think what you have to do is whenever you get the token , save it in your database with the user_id or device_id, then when sending message to a recipient, you get the token of the recipient from database(eg: get token where user_id=recipient_id) then send notification to that token.

Can I send fcm notifications to Firebase UserIds instead of device tokens?

I see examples where you have to extract device tokens and store them in a db to be able to send notifications to that device.
I wondered if I could use Firebase user ids to send a select list of users notifications skipping the need for tokens?
No firebase is not support to send notification using userID.
You have to integrate FCM package for getting token if firebase using below link :
https://pub.dev/packages/firebase_messaging
After getting token then only you can use this token and send the notification.
Other way of sending notification is the topic.
For topic i am giving you below link :
https://www.filledstacks.com/post/push-notifications-in-flutter-using-firebase/
No, you can't. You need to implement a custom notification sender from the firebase cloud function to send by user IDs. But you can't ignore the FCM tokens. You must register a valid FCM token of the user's device to trigger per device notification. Check the following guideline:
FCM Push Notifications for Flutter

Sending IOS notifications from Firebase (or another platform) to specific terminales

We are currently able to send notifications to specific Android devices through Firebase and I am trying to do the same to IOS devices.
We use POD and have installed
pod 'Firebase/Core'
pod ‘Firebase/Messaging'
We've created an account with Firebase.
I have added the functions that correspond to AppDelegate.swift. After executing the app, I can send notifications from Firebase to all iPhones... but no specific ones.
In production, I have the following
FIRInstanceID.instanceID().setAPNSToken(deviceToken, tape: FIRInstanceIDAPNSTokenType.prod)
Up to here, all good .. but when I try to get the token from a user and then send a notification only to that device... the notification does not arrive
The token is generated without any problems.
if let refreshedToken = FIRInstanceID.instanceID().token() {
print(“InstanceID token: \(refreshedToken)”)
}
From firebase The notification is sent and does not show errors.. but the notification never arrives to the actual device.
Can this be done with Firebase?
Is there any other service that would allow me to do this?
UPDATE
I send message for console
click open image
On Android, Firebase has the luxury of using GCM directly. For Apple, FCM messages need to be sent to Apple Push Notifications.
Make sure you have setup the backend by downloading your APN Key and uploading to your Firebase console:
Download: https://firebase.google.com/docs/cloud-messaging/ios/certs
Upload: Open your Firebase console, click on the gear icon in the upper left, click on Project settings and then the Cloud Messaging Tab. Upload your APN key there.
You should be able to grab the FCM device ID from the debug output console when Firebase starts up (when running the app in debug mode).
You need to update your Firebase pod and add code from this answer to your iOS Application-
Working Firebase Messaging Code for iOS App