flutter_fcm 1.0.3 copy "flutter_fcm: ^1.0.3" to clipboard
flutter_fcm: ^1.0.3 copied to clipboard

outdated

Flutter plugin for Firebase Cloud Messaging (FCM) , a cross-platform messaging solution that lets you reliably deliver messages on Android and iOS.

Firebase Messaging Plugin for Flutter #

A Flutter plugin to use the Firebase Cloud Messaging API.

To learn more about Firebase Cloud Messaging, please visit the Firebase website

Getting Started #

To get started with Firebase Cloud Messaging for Flutter, please see the documentation.

Why flutter_fcm? #

  • 🚀 Easy to use
  • ❤ Supports local notification
  • 🛡️ Null safety
  • ⚡ On notification Received/Pressed works in all states: foreground,background and even when app is closed(not running)

Usage #

The easiest way to use this library is via the top-level functions.

import 'package:audioplayers/audioplayers.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter_fcm/flutter_fcm.dart';

class Messaging {
  static String token='token';

  static deleteToken(){
    FCM.deleteRefreshToken();
  }

  static Future<void> onNotificationReceived(RemoteMessage message) async {
    await Firebase.initializeApp();

    print('Handling a message ${message.messageId}');
  }

  static initFCM()async{
    try{

      await FCM.initializeFCM(
        onNotificationReceived: onNotificationReceived,
          onNotificationPressed: (Map<String, dynamic> data) {
            print(data);
          },
          onTokenChanged: (String token) {
            Messaging.token = token;
            print('FCM token  '+token);

          },
        // TODO add this icon to android/app/src/main/res/drawable/ic_launcher.png
          icon: 'ic_launcher',
      );

    }catch(e){
      print(e);
    }
  }
}

36
likes
0
pub points
83%
popularity

Publisher

verified publisherwaelalhalabi.com

Flutter plugin for Firebase Cloud Messaging (FCM) , a cross-platform messaging solution that lets you reliably deliver messages on Android and iOS.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

firebase_core, firebase_messaging, flutter, flutter_local_notifications

More

Packages that depend on flutter_fcm