I have chat app with end-to-end encryption made in Flutter. When push notifications arrive, the app process it, decrypt the content and show notification. But the problem is, that there is one more notification not created by the app with unencrypted content. It looks like this:
This is really annoing and I don't know how to solve this problem.
Flutter logs:
Handling a background message: 0:1620226730325270%0454fd8a0454fd8a
W/FirebaseMessaging(23000): Notification Channel set in AndroidManifest.xml has not been created by the app. Default value will be used.
I/flutter (23000): true
D/FlutterSecureStoragePl(23000): Read: key exists => Running ensureInitStorageCipher
D/FlutterSecureStoragePl(23000): Initializing StorageCipher
D/FlutterSecureStoragePl(23000): StorageCipher initialization complete
D/NotificationSender(23000): Notification created
I/flutter (23000): Notification created
I/flutter (23000): Notification displayed
The log says that Notification Channel set in AndroidManifest.xml has not been created by the app. Default value will be used. But the channel was created by the app.
Thank you for you help.
Btw, I'm using AwesomeNitifications plugin for notifications.
EDIT:
Notification Channel set in AndroidManifest.xml has not been created by the app. Default value will be used. Error is not showing anymore, because I set notification channel id in FCM message this ID, but the notifications are still showing twice.
In fact, Firebase push notifications can be sent in the background or exposed as soon as they arrive.
In this case, you will have to change the sending of push notifications, to be sent only in the background, and this way your filter will not expose the message that is encrypted.
For more info:
https://firebase.google.com/docs/cloud-messaging/concept-options#notifications_and_data_messages
Related
In my Android app, the Push Notification Firebase Cloud Messaging is only received on the device when the user is not in the app at the time of sending - The message is received, but not displayed. I made a console.writeline to log if the message was received, and it was, but no sound was made and the notification didn't pop up.
Some background:
I am testing on an emulator
I am using the FirebasePushNotification Plugin (as it is a Xamarin.Forms project and I want to be able to do cross-platform setup
I have downloaded GoogleServicesJSON, set build action, etc.
I think you are sending the Data messages,When using this type of message you are the one providing the UI and handling when push notification is received on an Android device.
So you should define and create your notification yourself in the receive callback.
I am investigating about React Native and Firebase Cloud Messaging. In the document, I see that has 2 types of message can be send to client is:
Notification message ( Or Notification and data message )
Data - only message
The first one can be trigger by client using onNotification, and it only trigger if the app on foreground, if in background no way to trigger that has a notification. Just onNotificationOpened can be fired.
The second is inverse, the app can trigger on foreground and background. In case the app has been closed/swiped, on Android luckily it can be triggered also by using a Handler background. But on iOS if the app closed/swiped that no way until we open app again.
The problem is what type of 2 message above that I can use to listen the notification coming, and how it can work if app in foreground, background and closed.
Hope someone can help me about this.
I'm currently implementing a Chat application using Firebase Cloud Messaging to send push notifications. Using the notification field in the API call, Firebase displays them automatically without having to manually create a service and listen for the messages.
The push notification is pretty generic, just says "You have a new message!", so it doesn't make sense to keep adding new pushes every new message, I need firebase to not show a new push if the message body contents the same of a previous one.
Is it posible to do without implementing the service and handling Notification show manually? Found no references of this use case in the documentation.
If your application is in Foreground then you receive the notification in onReceive of your FirebaseMessagingService. Else notification is delivered to system notification tray. Since you don't know the id of the notification so you may not retrieve it. It is also possible that your application is not running at the time you receive the notification. So logically it is NOT possible even by implementing the service. Well you can solve the problem by another approach. You can use Firebase Database in conjuction with Cloud Functions. Just have a look on developer guide of cloud functions and you will find that they can help yourself achieve you what you want. As a solution skeleton : Post messages to Firebase Database and Send notification using cloud functions. When the recipient reads the message update the database to reflect message has been read like having a variable seen. Design your cloud function such that it reads the value of seen value of last message and sends notification only if it was true. Hope this helps.
For manual handling you have to use the service. Go for handleIntent(intent) of FirebaseMessagingService.
This method gets called when application is in foreground, background and killed state. To avoid the duplication, do not call super.handleIntent(intent). This will prevent the automatic push notification when app in BG or killed state.
This worked for me.
When testing to the android app from the firebase console the status of the messages says completed and shows the delivery date. How do we check whether a message has sent to the receipts and delivered in an android app with fire-base: https://console.firebase.google.com?
I am working on a firebase quickstart app to test push notification message to my target users. Please help me.
#SaikCaskey have an insight of the solution of your question, though I do not agree on some points.
The push notification is not guaranteed to be received to your targeted user actually. Push notification might fail for several reason. But that's not the issue here. You might get notifications even if your application is in background or stopped. You need to start your FirebaseMessagingService with START_STICKY. This behaviour might differ in different devices too. Some devices allows/disallow this behaviour of receiving push notification when your app is stopped.
So, if you need to log when your user has received the push notification, you might get it in a bit complex way. When your device will come online you'll get the push and in your onMessageReceived function you can get the System.Clock for getting the time of notification received. Then create an instance of Firebase and then set the time to the reference node of the user's notification delivery time.
Hope that helps!
I want to implement push notifications on both Android and iOS with Google Cloud Messaging.
I don't want to use the notification key in my payload because the Android behavior is not ideal. On Android, I would prefer my receiver to always get triggered with the data payload, and I can construct the Notification myself using NotificationCompat. If you use the notification payload on Android, you have no control over the notification style, for example.
However, if I only send a data payload, I think my iOS app will not receive the push if it is backgrounded - killed, never launched since device restart, etc. I think there's that content_available flag for GCM which may trigger the push anyway?
Am I, on iOS, able to duplicate the Android behavior of always having my in-app code execute upon notification? I'd be fine constructing my own iOS notification based on the GCM data payload, and perhaps using something like a UILocalNotification, but from what I'm reading, iOS is requiring the notification payload to exist to make sure the push is always received by the user.
Can I get this kind of control on iOS?
You have to disable the content_available flag to false, so that it works on Ios as expected and provide full control on android,
Source:- I have worked on Push Notification on both android and IOS recently
From my research, it seems that you can't avoid using the notification payload. However, you can get rid of the default Android behavior of auto-creating a notification, if, instead of creating a MyGcmListenerService that extends GcmListenerService, you create your own GcmListenerService and extend plain old Service.