Coder Social home page Coder Social logo

flutter_fcm's Introduction

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)

Getting Started

To get started with Firebase Cloud Messaging for Flutter, see Android Installation. and iOS Installation.

Usage

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

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;

  static deleteToken() {
    Messaging.token = null;
    FCM.deleteRefreshToken();
  }

  @pragma('vm:entry-point')
  static Future<void> onNotificationReceived(RemoteMessage message) async {
    await Firebase.initializeApp();
    //print('Handling a message ${message}');

  }

  @pragma('vm:entry-point')
  static initFCM() async {
    try {
      await Firebase.initializeApp();
      await FCM.initializeFCM(
        withLocalNotification: true,
        // navigatorKey: Keys.navigatorKey,
        onNotificationReceived: onNotificationReceived,
        onNotificationPressed: (Map<String, dynamic> data) {

        },
        onTokenChanged: (String? token) {
          if (token != null) {
            //print('FCM token  $token');
            Messaging.token = token;


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

flutter_fcm's People

Contributors

wh120 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

flutter_fcm's Issues

IOS Local Notification Issue

Even when I have set local notification OFF from boolean value and even comment the following code out

       LocalNotification.showNotification(
           notification: notification, payload: message.data, icon: icon);
     }```
     


im still getting local notification idk why

Hello. Help please

What should i do with icon: 'icon'?
And why on android notification came with no sound?

onNotificationPressed not working

flutter_fcm: ^1.1.0

im getting foreground notification but when I tap nothing within onNotificationPressed code block is being executed

if im in background and I tap on notification nothing within onNotificationPressed code block is being executed either

prompt action would be well appreciated

Version problem

Because flutter_fcm >=1.0.4 depends on firebase_messaging ^12.0.3 and pryaniconline depends on firebase_messaging ^14.1.3, flutter_fcm >=1.0.4 is forbidden.
So, because pryaniconline depends on flutter_fcm ^1.0.5, version solving failed.
pub get failed (1; So, because pryaniconline depends on flutter_fcm ^1.0.5, version solving failed.)

Add support for Flutter Web

Thank you first for that great plugin. Adding support for web would be a gamechanger as no other plugin yet support it

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.