fcm_config 3.0.1 copy "fcm_config: ^3.0.1" to clipboard
fcm_config: ^3.0.1 copied to clipboard

outdated

This flutter package is made to merge between firebase_messaging package and flutter_local_notifications

fcm_config #

add pcakage #


dependencies:
  flutter:
    sdk: flutter
  fcm_config: ^3.0.0-nullsafety.17
# firbase_messaging has unresolved issue that prevent onMessage to be triggered so to solve this you has to add this 
# it is very important to listen to incomming notification
dependency_overrides:
  firebase_messaging_platform_interface:
    git:
      url: https://github.com/mo-ah-dawood/flutterfire.git
      path: packages/firebase_messaging/firebase_messaging_platform_interface

What can this packge do #

  • Show fcm notification while app is in forground
  • Easly recieve incoming notification where you are
  • Easly recieve clicked where you are
  • Notification is an object

Setup #

Android #

Ios #

MacOs #

Web #



Dart/Flutter #

Initialize

  void main() async {
      await FCMConfig().init();
      runApp(MaterialApp(
        home: MyHomePage(),
      ));
  }

Background messages(Web not supported)

  • To handle message in background you can do that
    Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
     print("Handling a background message: ${message.messageId}");
    }
      
    void main() async {
      FCMConfig().init(onBackgroundMessage:_firebaseMessagingBackgroundHandler);
      runApp(MaterialApp(
        home: MyHomePage(),
      ));
    }

Get token

   FCMConfig().getToken().then((token) {
        print(token);
   });

To get notification that launched the application

  await FCMConfig().getInitialMessage();// may be null
 

Listen to incomming notification :

  • First option

    class MyScreen extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return FCMNotificationListener(
          onNotification:
              (RemoteMessage notification, void Function() setState) {},
          child: SizedBox(),
        );
      }
    }
    
  • Second option

    class MyScreen extends StatefulWidget {
      @override
      _MyScreenState createState() => _MyScreenState();
    }
      
    class _MyScreenState extends State<MyScreen>
        with FCMNotificationMixin {
      @override
      Widget build(BuildContext context) {
        return SizedBox();
      }
      
      @override
      void onNotify(RemoteMessage notification) {
        // do some thing
      }
    }
      
    

Listen to notification tap:

  • First option

    class MyScreen extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return FCMNotificationClickListener(
          onNotificationClick:
              (RemoteMessage notification, void Function() setState) {},
          child: SizedBox(),
        );
      }
    }
    
  • Second option

    class MyScreen extends StatefulWidget {
      @override
      _MyScreenState createState() => _MyScreenState();
    }
      
    class _MyScreenState extends State<MyScreen>
        with FCMNotificationClickMixin {
      @override
      Widget build(BuildContext context) {
        return SizedBox();
      }
      
      @override
      void onClick(RemoteMessage notification) {
        // do some thing
      }
    }
      
    

Localize your notification #

see https://pub.dev/packages/fcm_localization

127
likes
0
pub points
91%
popularity

Publisher

verified publishernew-step-apps.com

This flutter package is made to merge between firebase_messaging package and flutter_local_notifications

Homepage
Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

firebase_core, firebase_messaging, flutter, flutter_local_notifications

More

Packages that depend on fcm_config