easy_fcm 0.0.1 copy "easy_fcm: ^0.0.1" to clipboard
easy_fcm: ^0.0.1 copied to clipboard

The easiest way to handle Firebase Notifications in Flutter. Auto-handles foreground pop-ups and channels.

EasyFCM πŸš€ #

A Logic-First wrapper for Firebase Messaging. Handle Foreground, Background, and Terminated notifications with one simple initialization.

Pub Version License

🌟 Why use EasyFCM? #

  • Foreground Notifications: Automatically bridges Firebase to Local Notifications so users see a pop-up alert even when the app is open.
  • Zero Boilerplate: No need to manually create Android Notification Channels or Request Permissions.
  • Unified Logic: One callback (onTap) handles notification taps from any state (Background, Terminated, or Foreground).
  • No Widget Wrapping: Pure Dart class. Initialize it in main(), GetX, Provider, or Bloc.

πŸ“¦ Installation #

Add this to your pubspec.yaml:

dependencies:
  easy_fcm: ^0.0.1

πŸš€ Usage #

1. Configure Firebase #

Run the standard FlutterFire command to generate your options file:

flutterfire configure

2. Initialize in main.dart #

import 'package:flutter/material.dart';
import 'package:easy_fcm/easy_fcm.dart';
import 'firebase_options.dart'; // Generated by flutterfire

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await EasyFCM().initialize(
    // 1. Pass your generated Firebase Options
    firebaseOptions: DefaultFirebaseOptions.currentPlatform,

    // 2. Get the FCM Token (Send this to your backend)
    onTokenReceived: (token) {
      print("FCM Token: $token");
    },

    // 3. Handle Notification Taps
    onTap: (message) {
      print("Notification Tapped! Payload: ${message.data}");
      // Example: Navigator.pushNamed(context, '/notifications');
    },
  );

  runApp(const MyApp());
}

πŸ“± Platform Specific Setup #

Android #

To prevent build errors with local notifications, you must enable Core Library Desugaring in your android/app/build.gradle file.

  1. Open android/app/build.gradle.
  2. Update the android block and dependencies block as shown below:
android {
    defaultConfig {
        
        minSdkVersion 23
        multiDexEnabled true
    }

    compileOptions {
        versions
        isCoreLibraryDesugaringEnabled true
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    
    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'
}

iOS #

  1. Open your project in Xcode.
  2. Go to Signing & Capabilities.
  3. Add Push Notifications.
  4. Add Background Modes -> Check Remote notifications.
  5. Ensure your APNs Key is uploaded to the Firebase Console.
0
likes
140
points
104
downloads

Publisher

unverified uploader

Weekly Downloads

The easiest way to handle Firebase Notifications in Flutter. Auto-handles foreground pop-ups and channels.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

firebase_core, firebase_messaging, flutter, flutter_local_notifications

More

Packages that depend on easy_fcm