I can't control how the app opens the notification message with firebase
FirebaseMessaging.onMessageOpenedApp is not working
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
debugPrint("CLICKED!");
RemoteNotification? notification = message.notification;
AndroidNotification? android = message.notification?.android;
debugPrint("id: ${notification?.body}");
if (android != null && notification != null) {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const NotificationScreen()),
);
}
});
do you know?
how many words do you know
See also questions close to this topic
-
How can I fixed my problem"FirebaseError: Firebase: Error (auth/invalid-api-key)."
My environment variable is ok. No comas and name mistakes but they given me error like "FirebaseError: Firebase: Error (auth/invalid-api-key)". How can I fixed it. Please Help me...
This my .env file
REACT_APP_apiKey=AIzaSyBWobnhbdeMdNpXXXXXXXXXXXXXXXXXXXX REACT_APP_authDomain=XXXXX.firebaseapp.com REACT_APP_projectId=XXXX REACT_APP_storageBucket=XXXXX.appspot.com REACT_APP_messagingSenderId=4997390XXXXX REACT_APP_appId=1:4997390XXXXX:web:cc7bc80aa1bdb78fXXXXXX REACT_APP_measurementId=G-M1XDXXXXXX
This my firebase config file
const firebaseConfig = { apiKey: process.env.REACT_APP_apiKey, authDomain: process.env.REACT_APP_authDomain, projectId: process.env.REACT_APP_projectId, storageBucket: process.env.REACT_APP_storageBucket, messagingSenderId: process.env.REACT_APP_messagingSenderId, appId: process.env.REACT_APP_appId, measurementId: process.env.REACT_APP_measurementId, }; when I debugging firebaseConfig object console.log(firebaseConfig.apiKey); ==========> undefined console.log(firebaseConfig.authDomain); ==========> undefined console.log(firebaseConfig.projectId); ==========> undefined console.log(firebaseConfig.storageBucket); ==========> undefined console.log(firebaseConfig.measurementId); ==========> undefined console.log(firebaseConfig.appId); ==========> undefined console.log(firebaseConfig.measurementId); ==========> undefined
client side given error this "FirebaseError: Firebase: Error (auth/invalid-api-key)"
-
How to order comments in firebase firestore by createdAt
I have a document in which there is a comments array of objects and each object has createdAt property. I want to sort all the comments that are inside the comments array using the createdAt property, so, a new comment comes to the top.
I did some research and found that we can do this in firebase's real-time database but I want to do the ordering of data using firestore.
Here is my code:
import { useEffect, useRef, useState } from "react" // firebase import import { doc, onSnapshot, orderBy, query } from "firebase/firestore" import { db } from "../firebase/config" export const useDocument = (c, id, o) => { const [document, setDocument] = useState(null) const [error, setError] = useState(null) // realtime document data useEffect(() => { let docRef = doc(db, c, id) if (o) { docRef = query(docRef, orderBy("createdAt", "desc")) // this is not working } const unsubscribe = onSnapshot( docRef, (snapshot) => { // need to make sure the doc exists & has data if (snapshot.data()) { setDocument({ ...snapshot.data(), id: snapshot.id }) setError(null) } else { setError("No such document exists") } }, (err) => { console.log(err.message) setError("failed to get document") } ) // unsubscribe on unmount return () => unsubscribe() }, [c, id]) return { document, error } }
-
How to group firebase data in flutter with DateTime?
I am making a chat application in flutter using firebase. I want to show a header with the date whenever the date changes. How can I group messages in flutter coming from firebase on the basis of date and show a header with the changed date?
I have tried GroupedListView package but I was not able to retrieve the chatmessages successfully.
-
how to change prettier format for react native
my code formatting prettier didn't works well for react native, i don't understand where to config it but it works well with flutter
from this code
import { View, Text } from 'react-native' import React from 'react' export default function App() { return ( <View> <Text>Apps</Text> </View> ) }
it's formatted to this
import { View, Text } from 'react-native' import React from 'react' export default function App() { return ( < View > < Text > Apps < /Text> < /View> ) }
-
Can you make complete apps using Flutter & Dart or just the UI part of an app?
I'm confused about what Flutter framework actually does, I know that it uses Dart and have heard that both of them can be used to create cross-platform apps.
But Wikipedia defines Flutter as a "UI Framework", so my question is, can you make a complete app (for mobile) which also has backend part (communicates with a database) built entirely using Flutter & Dart and not only the UI part?
If you didn't get my question, here is an example:
Suppose a front-end web developer works on client side programming in his job, and the backend logic is written by another backend developer.
When it comes to mobile app development, suppose as a Flutter developer, your job is to create apps, but does that mean that as a Flutter developer, you'll only write the front-end logic and leave the backend part for another backend developer like in web world? Can Flutter developers also write the backend of an app using only Flutter & Dart? If not, then who writes the backend of a mobile app and what tools/languages/frameworks does he uses?
-
Subscribing to firebase topic do not filter push message
Context
I am developping an Angular web application using firebase messaging. I configured firebase successfully (I guess) and I now subscribe to a "users" topic.
To do so I use thesubscribeToTopic('users')
from'firebase-admin'
library on server side (NestJS application) and it always prints the success message.await firebaseAdmin .messaging() .subscribeToTopic(firebaseIdToken, topic) .then((response) => { console.log('Successfully subscribed to topic:', response); response.errors.forEach((err) => console.log(err.error)); }) .catch((error) => { console.log('Error subscribing to topic:', error); });
On client side, I use
AngularFireMessaging.messages
to listen the message push.
To test the push message, I use postman and the firebase api https://fcm.googleapis.com/fcm/send with following body{ "topic": "users", "notification": { "title": "notif title", "body": "Hello world" }, "data": { "action": "CREATE", }, "to": "{{firebase.id_token}}" }
where
firebase.id_token
is the id token generated by firebase withAngularFireMessaging.getToken
function
I successfully receive the push message on my client app.Issue 1
But now, if I change the "topic" key in the request body by any topic name, I still receive the push messages on client side !! And this is not what I expected I wonder what I'm doing wrong with the subscription or configuration making the client side not filtering the push messages according to topic subscription.
Issue 2
I tryied to implement my own sendPush method on server side with the following code
@Post('send-push') async sendPushMessage(@Body() { topic, payload }: FirebasePush): Promise<void> { console.log('sendPushMessage', topic, payload); // print the right values await firebaseAdmin .messaging() .sendToTopic(topic, payload) .then((response) => { console.log('Successfully sent message:', response); // this is printed with the message id }) .catch((error) => { console.log('Error sending message:', error); });
}
if I call this endpoint with postman using the following body
{ "topic": "users", "payload": { "data": { "action": "CREATE", } } }
the message seems to be send correctly because the message id is printed in the console but I never receive any message push on client side and I wonder why as well
I hope someone can help me with theses issues, thanks -
how can I push notifications using data already built in SQLite?
I'm currently developing a notification type Android app, how can I push notifications using data already built in SQLite?
Data table fields: [notification title] [build date] [Duration of days] [time when the daily reminder starts] [Reminder Interval] [end date] SQL Table: db.execSQL("CREATE TABLE NF"+ "(_id INTEGER PRIMARY KEY NOT NULL , "+ "type TEXT NOT NULL,"+ "name TEXT NOT NULL,"+ "date DATE NOT NULL,"+ "times INTEGER NOT NULL,"+ "startTime TIMES NOT NULL,"+ "days INTEGER NOT NULL,"+ "endDate DATE NOT NULL)");
I want to use AlarmManager to implement this function, but I can't find the relevant application case, please help me 😭
-
Only 70% users get firebase notification Received
I am using Latest firebase "firebase-bom:29.0.3" SDK And I am sending notification by Topic and also tried by token array in previous code
Android Code
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder =new NotificationCompat.Builder(this, channelId)
.setSmallIcon(R.drawable.ic_notification) .setContentTitle(title) .setContentText(messageBody) .setAutoCancel(true) .setSound(defaultSoundUri) .setPriority(NotificationCompat.PRIORITY_HIGH) .setContentIntent(pendingIntent);
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(getApplicationContext());
// Since android Oreo notification channel is needed. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { NotificationChannel channel = new NotificationChannel(channelId, channelId, NotificationManager.IMPORTANCE_DEFAULT); notificationManager.createNotificationChannel(channel); }
notificationManager.notify(id, notificationBuilder.build());
Php CODE
$msg = array( 'title' => $title, 'body' => $message, 'text' => $message, 'sound' => 'default', 'badge' => $badge, 'id' => $id, 'type' => $idType, 'timestamp' => time() ); $fields = array('to' =>'/topics/global', 'notification' => $msg, 'data' => $msg); if(!empty($fields)){ $headers = array('Authorization: key=' . env('FIREBASE_FCM_API_KEY'),'Content-Type: application/json'); #Send Reponse To FireBase Server $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send'); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); return $result; } else{ return 0; }
-
How can I send firebase notifications using any other notification Library in react-native
I want to build custom style for the notifications I'm recieving from firebase in kill/background state.
-
firebase data messaging in flutter
Hi guys I'm looking for some help about Data message in firebase which we can handle from app side how i can listen them on foreground background and terminate state and also how i can save on local storage not notification message.