Flutter Notifications Made Easy: Using Firebase Cloud Messaging (FCM)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
ever wanted to send real-time notifications to your flutter app users Firebase Cloud messaging fcm makes it a breeze in this video we'll walk you through implementing fcm for powerful notifications in your flutter apps but wait before we dive in make sure you set up Firebase in your flutter project if not make sure to watch my Firebase setup video real quick so let's get started now search Firebase messaging flutter click on the link showed or go to the description of the video to get all the links let's install the Firebase messaging package to our package copy the command great we have installed the package now go back time to run our app you can either use flutter run command or use IDE shortcut to run the app here we will run through IDE [Music] shortcut let's see if everything is on right track oops seem like we got an error let's figure [Music] out got the culprit it's because we have not ensure initialization let fix it quickly by just adding the line widget flutter binding. insure initialize and done we let's try again running our app great let's rerun our app and here is our app it's fixed now and our Firebase messaging installed successfully in our project now time to subscribe Topic in our app for those who don't know about topic fcm topic messaging allows you to send a message to multiple devices that have opted in to a particular topic you compose topic messages as needed and fcm handles routing and delivering the message reliably to the right devices let's quickly copy the command shown in our main. Dart this command will allow user to subscribe to the topic now name your topic it can be anything for this project let's call it sample once done make sure to rerun your app so that your device subscribed to topic successfully there are a few things to remember first make sure your app settings has notifications on second if running on emulator you might face some issues like late notifications so if possible try to use real device than an emulator now let's go to our Firebase console and choose the project like here at sample once you go to engage tab then messaging as shown click on create your first campaign choose according to your needs for this video we are going for notification messages quickly add notification title description image if needed you can check the realtime preview on right side once done click next now click on topic tab as shown for this go back and copy the topic you have subscribed like in our case it's sample topic Also let's close our app let's copy it and click [Music] next schedule your notification for this video we schedule it now then click next and finally review it and click publish congratulations you have successfully published your first notification let's go back and check device there might be some delay on emulator so try to use real device and here is our notification title description and the image as we set on console on click it will open our app but wait imagine you want to Target specific users with notifications that's where fcm tokens come in think of them as unique IDs for each device by using a token you can send notifications directly to a particular user's device make sure to copy the token or securely store it after you retrieve it so let's get started go back and click on send a test message tab as shown scroll down and copy the code as shown this comad will generate our device fcm token let's quickly copy it make sure your function is asynchronous as its future now let's print the fcm token so that we can use it to send notification to this device once done rerun your app and copy the token from terminal and here is our fcm token let's quickly copy it go back to the console and click on new campaign under messaging tab as shown add notification title description image Etc once done click on send test message and add your fcm token there as shown and click test and make sure to close the app in order to view the notification Let's test it now go back and let's see if we get our notification and here it is congratulations you have successfully send the notification to specific device all right that's a solid foundation for using fcm with flutter notifications but wait there's more fcm offers even more advanced features to supercharge your app's notification capabilities here are a few to keep in mind background and foreground handling terminated State notifications APN token for iOS on token refresh if you're building an app with real-time engagement mastering these Advanced fcm features will be a GameChanger let me know in the comments what kind of notifications you're planning for your flutter app don't forget to smash that like button and subscribe for more flutter tutorials to level up your mobile development skills [Music] a
Info
Channel: King Rittik
Views: 581
Rating: undefined out of 5
Keywords: king rittik, kr, rittik, flutter, firebase, firebase fcm, flutter notification, APN token, foreground notification flutter, background notification flutter, firebase topic notification, firebase cloud messaging, android, engage users, fcm, firebase cloud messaging flutter, firebase console, firebase messaging flutter, firebase_messaging flutter, flutter firebase messaging, flutter firebase notification, flutter firebase push notification, flutter push notification, push notification
Id: rz8yYghVqaY
Channel Id: undefined
Length: 6min 7sec (367 seconds)
Published: Sun Mar 24 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.