How to Get Firebase Token In Flutter??

2 min read
How to Get Firebase Token In Flutter
How to Get Firebase Token In Flutter

When users trying to send a notification from Rest Api using Firebase Admin SDK to the Flutter Application and it seems it requires a device token to send a notification. So in this article, we will go through How to Get Firebase Token In Flutter.

Are you ready for the same?

Let’s Drive through the same.

How to Get Firebase Token In Flutter??

Add this to your package’s pubspec.yaml file as shown here:

  firebase_messaging: ^6.0.16

You can install packages from the command line:

with Flutter like the below:

flutter pub get

Now in your file import package like the below:

import 'package:firebase_messaging/firebase_messaging.dart';

Implementation would be as the below snippet:

final FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
    onLaunch: (Map<String, dynamic> message) {
      print('onLaunch called');
    onResume: (Map<String, dynamic> message) {
      print('onResume called');
    onMessage: (Map<String, dynamic> message) {
      print('onMessage called');
    sound: true,
    badge: true,
    alert: true,
      .listen((IosNotificationSettings settings) {
  _firebaseMessaging.getToken().then((token) {
    print(token); // Print the Token in Console

you can refer here, to know more about how to Integrate Push Notification For iOS In Flutter.


So in this article, we have been through How to Get Firebase Token In Flutter.

Thanks for Reading !!! we hope you have learned well 馃檪

Keep Learning !!! Keep Fluttering !!!

Do let us know if you need any assistance with Flutter Development. Don’t forget to drop your valuable feedback in the comments, It keeps us moving!

FlutterAgency.com聽is our portal Platform dedicated to聽Flutter Technology聽and聽Flutter Developers. The portal is full of cool resources from Flutter like聽Flutter Widget聽Guide,聽Flutter Projects,聽Code libs聽and etc. is one of the most popular online portals dedicated to聽Flutter Technology and daily thousands of unique visitors come to this portal to enhance their knowledge of聽Flutter.

Leave a Reply