I don't know how should I appreciate you, but I would like to thank you for this kind of tutorial that someone ever made. I am supporting you by watching all the adds and clicking on that adds sometimes...thank you so much again
This is the best tutorial on firebase I've watched. Though I'm from the java world, I can still understand the step. I was somehow stuck but not anymore. Thanks for the video
As the name suggests "Server key" is meant to be sorted on a server. It is not at all recommended to have you server key on your client app. As apps can be reverse engineered and then the key can be used in unwanted ways. You should have a server which interacts with your client app to send notifications using fcm.
Great content but now outdated. Can you upload new video for this? I tried to find some working solution but not succeeded.Thank you for excellent content you share !
Great tutorial, turns out to be much easier than expected after reading the docs. The only question I have now, can we actually schedule these messages via API? To make notifications not pop up immediately. Or we have to manually schedule them when we receive a message from Firebase?
For those who receive 200 OK from the server but the notification does not show, I had the same issue and I managed to fix it. Actually, even if you receive 200 OK, there is an error in the body (try to do it in postman or debug deeply in your client to see it). The response body actually has a field ""results":[{"error":"InvalidRegistration"}]" or another error type. In my case in a first time, I was using the topic /topics/myTopic and it seems to be forbidden to use such format. Then I replaced the topic with the device Id as shown in the video and it works. I would/will dig into the topic problems when I need it :) Anyway, the "results" should have a "message_id" field to be sur it is working !
if you face this error : MediaSessionCompat:Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent then change the pending intent code as below val pendingIntent: PendingIntent? = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_MUTABLE) } else { PendingIntent.getActivity(this, 0, intent, FLAG_ONE_SHOT) }
Love it, hope that you can make a list of tutorials that using exoplayer and custom it like youtube. I'd got stuck at it for weeks. I didn't know how to make a setting resolution (bitrate) button for mp4 adaptive stream. I hope that you can make a tutorial about it.
how I can add it to my java project? and how I can save this notification or some specifide notifiacation on my realtime database? I want to get and save notification by data change on any one of my fragments?
Congratulations for your channel and thanks for sharing your knwledge: always great content!!! In this tutorial, on pressed the button to send the notification I get this error: "java.lang.SecurityException: Can not make a java.lang.reflect.Method constructor accessible" Only this line in the log console and nothing happens. Any idea to solved it?
Philipp, your tutorials are wonderful and helps a lot. Just one query regarding FCM notification, some devices with custom android or battery optimization features or autostart prevention feature, do not display notification if app is not in use for some time (e.g. hours). Is there any robust solution?
Good job well done!, but I have a question if you please, I want to call this push notification method in my java project from another Activity, I already inserted your code tp a separated package inside my Android Java project and tested it and it works well, but how can I call this kotlin method (PushNotification) from another Java file (Activity)? I am stuck at this point. I know that we can call kotlin methods from Java, but how can we do this in my situation?
Great video ! It worked perfectly between all my android devices. But it doesn't reach my iphone. (I have tried to send notification to topics from firebase directly and it reached all my devices android and IOS). Is there anything we have to change in the android app to be able to reach IOS devices ?
Hi.. love it, this what im trying to do, without backend server, do you have the code in java ? i have try to guess translate to java, but seem didnt work ....
Kotlin seriously damn however good job sir keep going i know you worked so hard to make this video you deserve a subscribe even it wasn't useful for me
Server key not shown after If you are an existing user of the legacy HTTP or XMPP APIs (deprecated on 6/20/2023), you must migrate to the latest Firebase Cloud Messaging API (HTTP v1) by 6/20/2024. Need help .
haven't watched yet but does it work for Android Oreo and above which requires those notification channels ? if it does, then this is something i waited for so long !! and even if it doesn't, thanks for sharing the content and please try to make another one for handling notification channels ! thanks in advance to you mate !
yes of course, I wouldn't make a video about something that doesn't work below Android for >Oreo. In my android fundamentals series I have a video about notifications and I also use channels there
Well, theoretically every single information you put in an app can be reverse engineered. But usually, this is very hard to do, especially if it is not contained in the source code. If you store the server key on your server then the attacker could as well find out your server details from your source code and get the server key from there. There is no 100% protection against this
AndroidDevs Putting the key on client is absolutely different from hacking the server details . You are exposing the key to client. When client is pushing notifications, it makes requests with your key to firebase api. This means that the key can be easily found by monitoring requests made by client (like developer tools in chrome). Your server key must not expose to public. All notifications push must be done on server side, for example: firebase cloud function. See: stackoverflow.com/questions/37435750/how-to-send-device-to-device-messages-using-firebase-cloud-messaging
Found that the line of code Log.d("TAG", "Response ${Gson().toJson(response)}") causes error in devices that runs on Android 11. After removing it, app doesn't crashes anymore.
I ran into the same error. Not sure about the exact cause but after removing the Log statement that had - Response: ${Gson().toJson(response)} the error's gone. Hope this helps someone! :)
Hi Philipp, Storing an API Key in plain text is a pretty risky move, especially if your Github repository is public. To work around this, I have stored my key in Firebase. However, when I retrieve this key I can't pass it in to the @Headers in the Notification API interface because my retrieval of the key is not in constant time. Do you have any suggestions on how to solve this problem? Thanks
Hi thanks for tutorial i create function to send notification when app is enter doze after 1 min from sleep notification not recieved do you know how to fix this
I advice you to simplify the source code as much as you can. I find that you explains a lot of things together. but you should know this rule: teaches ill, who teaches all
I did the same code. I am receiving status code of 200 in response but not receiving any notifications. It's working fine when I push notifications from firebase console. Do you have any idea what might be wrong?
Hi Philipp! Thanks again for this video. I do however have a silly question. (Disclamer: I have just watched this and have not tested yet on my end). At this point, ua-cam.com/video/HoFWPPv1ih8/v-deo.html, you have already changed line 38 to send to the recipient token instead of TOPIC. The question is, since at line 29 is not yet modified to recipientToken, how come the other device is already receiving the notification when it is still subscribing to TOPIC?
Because the device knows its own token, so every message that goes to that token will be displayed. The topic doesn't change anything here, since we don't send a notification to it
I have a weird issue, notifications received by devices that has opened the activity that is used to send the notification only. other devices does not receive the notification. What is the issue and how to fix it?
When I generate APK file and install real device it's not working but it's working file in debug mode. NB: I am adding release key in firebase app config. getting error 400. How can I solve this? Thank you
I don't know how should I appreciate you, but I would like to thank you for this kind of tutorial that someone ever made. I am supporting you by watching all the adds and clicking on that adds sometimes...thank you so much again
This is just awesome
I was search for this from 2 days and finally I found this video
Thanks man, really appreciate your work🙌
This is the best tutorial on firebase I've watched. Though I'm from the java world, I can still understand the step. I was somehow stuck but not anymore. Thanks for the video
Hello Bro, can you share your Java code plz, I'm a beginner with Java knowledge only.
plz we need the java code ??
You just solved the problem of Saving data from firebase to Android apps. 😍😍😍
As the name suggests "Server key" is meant to be sorted on a server. It is not at all recommended to have you server key on your client app. As apps can be reverse engineered and then the key can be used in unwanted ways. You should have a server which interacts with your client app to send notifications using fcm.
Really helpful. Wish to watch all your videos. Keep posting the videos on advanced topics. Thanks
Great content but now outdated. Can you upload new video for this? I tried to find some working solution but not succeeded.Thank you for excellent content you share !
oooof after searching for 4 hours
i hope it's the right video
it's look like the right one from the beginning
i searched everywhere for a sample of this kind of Firebase cloud messaging now i've understand what the token is really for
Great tutorial, turns out to be much easier than expected after reading the docs. The only question I have now, can we actually schedule these messages via API? To make notifications not pop up immediately. Or we have to manually schedule them when we receive a message from Firebase?
So amazing bro as usual, keep going ✌️
And please extend your firebase series with playlist for "firebase ML kit" 😍
Thanks for the feedback!
This may be your best vid
Want more and more videos on advanced topics....keep it up.....
For those who receive 200 OK from the server but the notification does not show, I had the same issue and I managed to fix it. Actually, even if you receive 200 OK, there is an error in the body (try to do it in postman or debug deeply in your client to see it). The response body actually has a field ""results":[{"error":"InvalidRegistration"}]" or another error type. In my case in a first time, I was using the topic /topics/myTopic and it seems to be forbidden to use such format. Then I replaced the topic with the device Id as shown in the video and it works. I would/will dig into the topic problems when I need it :) Anyway, the "results" should have a "message_id" field to be sur it is working !
So, you change TOPIC with Device id? or what?
Love you from India 🇮🇳🇮🇳🇮🇳
Wow... Awesome Tutorial. Thanks for sharing the source code link in description....
great work ,i recommended with simple chat app
this video save my day...................... thanks a lot
Cool! But how do you add an image to the notification along with the title and message?
hi sir did you find out how to do it ???? if yes please tell me how
Haven't started yet.. but I know gonna be awesome ♥️🤪
Thanks, successfully implemented push notification.
Will this be applicable if two apps are connected to firebase like admin app and user app where admin want to send notifications to user app
There is no c2dm permission in official docs. Why we used that?
Hi, Philipp, thank you, you are the best❤
if you face this error : MediaSessionCompat:Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent
then change the pending intent code as below
val pendingIntent: PendingIntent? = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_MUTABLE)
} else {
PendingIntent.getActivity(this, 0, intent, FLAG_ONE_SHOT)
}
Hello Philipp and tank you for these tutorials, i have a question, why we are saving the token in sharedPref? i mean, why is this a good practice?
Love it, hope that you can make a list of tutorials that using exoplayer and custom it like youtube. I'd got stuck at it for weeks. I didn't know how to make a setting resolution (bitrate) button for mp4 adaptive stream. I hope that you can make a tutorial about it.
Works perfectly
I really fucking hate indian English pronunciation. You can't imagine how thankful I am for your pronunciation of this tremendous content:)
This video is very helpful for me, good work keep going. I appreciate your work ;)
Been looking for a good way to send notifications to the user, hope this works for what I want it
This should be what you're searching for
There is an easy way called one signal
@@PhilippLackner is there a way to add functional buttons to the notification, that can manipulate stuff in the app??
@@ahmedhegazi8039 yea, but firebase is more popular and known in the android community, so I thought this helps more people
@@maskedredstonerproz yes that's possible, you have a lot of possibilities, it's all stated in the docs
Bro, i really appreciate you when give me explanation code by code. Thanks for that
thanks for the video very helpful and informative!
Thank you so much. This helped me a lot :)
Just amazing 👏🏿 😍 🙌 ❤️ I love you
Awsome work my man. Thank u
hello sir how to use the new fcm api? please make a video about new firebase fcm.
Love it and liked and subscribed
Thanks and welcome!
my next project is :building an alternative to firebase. Curious to experiment with a 'binary local database creation" approach.
Like in pure C.
Thank you soo much for this tutorial !!!!!
how I can add it to my java project?
and how I can save this notification or some specifide notifiacation on my realtime database?
I want to get and save notification by data change on any one of my fragments?
Congratulations for your channel and thanks for sharing your knwledge: always great content!!! In this tutorial, on pressed the button to send the notification I get this error: "java.lang.SecurityException: Can not make a java.lang.reflect.Method constructor accessible" Only this line in the log console and nothing happens. Any idea to solved it?
Good content as always
Thanks!
Awesome tutorial!
Glad you liked it!
Philipp, your tutorials are wonderful and helps a lot. Just one query regarding FCM notification, some devices with custom android or battery optimization features or autostart prevention feature, do not display notification if app is not in use for some time (e.g. hours). Is there any robust solution?
I want to know too !!!! :S
Great tutorial
Hi thank you very much for your wonderful videos... can you talk about gradle, building sdk for clients , and proguard configuration
Thankyou very much ! It works
Good day Phillip, will this implementation work on Huawei devices as well?
Por fin un weon que habla normal por la chucha
Good job well done!, but I have a question if you please, I want to call this push notification method in my java project from another Activity, I already inserted your code tp a separated package inside my Android Java project and tested it and it works well, but how can I call this kotlin method (PushNotification) from another Java file (Activity)? I am stuck at this point.
I know that we can call kotlin methods from Java, but how can we do this in my situation?
Thank you so much!
Do you have with Aws sns for sending notifications for android using nodeJS and mongodb as a db to store tokens?
Thanks for video this helped me a lot
Glad it helped! :)
Great video ! It worked perfectly between all my android devices. But it doesn't reach my iphone. (I have tried to send notification to topics from firebase directly and it reached all my devices android and IOS). Is there anything we have to change in the android app to be able to reach IOS devices ?
Hi.. love it, this what im trying to do, without backend server, do you have the code in java ? i have try to guess translate to java, but seem didnt work ....
hi sorry to say you can enable kotlin for exiting java project
Kotlin seriously damn
however good job sir keep going i know you worked so hard to make this video you deserve a subscribe even it wasn't useful for me
Thanks, I would really recommend to learn Kotlin :)
Learn kotlin it's fun to code here
@@i-am-learning-life Hi again hahaah i learned Kotlin
@@zmemes69 happy to hear that
Server key not shown after
If you are an existing user of the legacy HTTP or XMPP APIs (deprecated on 6/20/2023), you must migrate to the latest Firebase Cloud Messaging API (HTTP v1) by 6/20/2024.
Need help .
many many thanks!!!
Amazing, thank you!
If possible, an explanation in the language java
java is outdated af for android
haven't watched yet but does it work for Android Oreo and above which requires those notification channels ? if it does, then this is something i waited for so long !! and even if it doesn't, thanks for sharing the content and please try to make another one for handling notification channels ! thanks in advance to you mate !
yes of course, I wouldn't make a video about something that doesn't work below Android for >Oreo. In my android fundamentals series I have a video about notifications and I also use channels there
thank you
thanks for video. how can we do this using java ?
thanks this is so helpful video for me
Most welcome 😊
FCM messages are not received if the app is close .... don't know what am doing wrong or if there is a work around please .....thank in anticipation
Amazing, thank you! 🙏
Glad you liked it!
i have tried exactly with your code but still not able to send the notification to specific device. so sad.
Is it secure to place the server key on the client app? I am wondering if this can be exploited.
Well, theoretically every single information you put in an app can be reverse engineered. But usually, this is very hard to do, especially if it is not contained in the source code. If you store the server key on your server then the attacker could as well find out your server details from your source code and get the server key from there. There is no 100% protection against this
AndroidDevs Putting the key on client is absolutely different from hacking the server details . You are exposing the key to client. When client is pushing notifications, it makes requests with your key to firebase api. This means that the key can be easily found by monitoring requests made by client (like developer tools in chrome).
Your server key must not expose to public. All notifications push must be done on server side, for example: firebase cloud function. See: stackoverflow.com/questions/37435750/how-to-send-device-to-device-messages-using-firebase-cloud-messaging
Why I am getting StackOverflowError: stack size 1043KB error? I only did the first part of it.
Found that the line of code Log.d("TAG", "Response ${Gson().toJson(response)}") causes error in devices that runs on Android 11. After removing it, app doesn't crashes anymore.
How to set High priority while app in background?
Bro but it is not working when I try to send from Firebase Cloud Messaging please tell me how could we receive data from the both sides !!
Does the FireBaseService launch by itself ?
Hi, I have a problem
In sendNotification method it throws an exception saying Unable to create call adapter
How should I solve this ?
I ran into the same error. Not sure about the exact cause but after removing the Log statement that had - Response: ${Gson().toJson(response)} the error's gone. Hope this helps someone! :)
Hi Philipp,
Storing an API Key in plain text is a pretty risky move, especially if your Github repository is public. To work around this, I have stored my key in Firebase. However, when I retrieve this key I can't pass it in to the @Headers in the Notification API interface because my retrieval of the key is not in constant time. Do you have any suggestions on how to solve this problem? Thanks
How do we localise the notifications according to user's preferred language
Thank you!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
do you have video of java of this push notification
Your channel is "the best" but everything in kotlin 😥😥
Hey, can we schedule firebase notification or local notification
I like it.
🤩
thanks a lot bro
you best
Broo How i know the recipient token without copy and paste?
Hi thanks for tutorial i create function to send notification when app is enter doze after 1 min from sleep notification not recieved do you know how to fix this
can i disble delete notification when app is in background
How to add notification badge count in app's launcher icon?
I advice you to simplify the source code as much as you can. I find that you explains a lot of things together. but you should know this rule: teaches ill, who teaches all
I did the same code. I am receiving status code of 200 in response but not receiving any notifications. It's working fine when I push notifications from firebase console. Do you have any idea what might be wrong?
Been waiting this for so looooong. Jk only aweek.
Hope you like it 😁
AndroidDevs I’m sure i will, will you make TDD vids? There’s can’t find people make it in utube
Yea I know it's important, but so few people are actually interested in it, it's sad
AndroidDevs hahaha
Hi Philipp! Thanks again for this video. I do however have a silly question. (Disclamer: I have just watched this and have not tested yet on my end). At this point, ua-cam.com/video/HoFWPPv1ih8/v-deo.html, you have already changed line 38 to send to the recipient token instead of TOPIC. The question is, since at line 29 is not yet modified to recipientToken, how come the other device is already receiving the notification when it is still subscribing to TOPIC?
Because the device knows its own token, so every message that goes to that token will be displayed. The topic doesn't change anything here, since we don't send a notification to it
I have a weird issue, notifications received by devices that has opened the activity that is used to send the notification only. other devices does not receive the notification. What is the issue and how to fix it?
does this work in flutter as well?
buen video solo que en la parte de notificationApi agreguen un / antes de fcm/send min 8:39 line 14
can you do that of flutter
Can you make the same thing using the java?
Nope, Java is outdated for android
how if i want to send the notif to two person in the same time?
I need code in java plz help me
When I generate APK file and install real device it's not working but it's working file in debug mode. NB: I am adding release key in firebase app config. getting error 400. How can I solve this? Thank you
I tried this, and for some reason it seems to be out of date :( please make an updated version?
Will this work if converted into Java Script?