Giter Site home page Giter Site logo

patoliavishal / flutter-fcm Goto Github PK

View Code? Open in Web Editor NEW
47.0 2.0 20.0 854 KB

Flutter-3.0 Firebase Messaging, Foreground, and Background Notifications + Topic Subscription and Handle Redirection

License: Apache License 2.0

Kotlin 0.97% Swift 2.94% Objective-C 0.28% Dart 58.95% HTML 27.03% Ruby 9.85%
fcm flutter flutter-apps flutter-examples firebase-messaging flutter-firebase fcm-push-notification flutter-notification flutter2 background-notifications

flutter-fcm's Introduction

Flutter FCM Push Notification

A Flutter sample app for demonstrating how to handle firebase push notifications in the background and foreground.

Screenshots

Notification while the app is running in the background and handle navigation:

Notification while the app is running in the foreground and handle navigation:

Plugins

The Flutter plugins used in this project are as follows:

Add the following to your pubspec.yaml file:

  cupertino_icons: ^1.0.2
  firebase_messaging: ^14.2.5
  firebase_analytics: ^8.0.2
  flutter_local_notifications: ^13.0.0
  firebase_core: ^2.7.0

Usage

In order to run this project, you have to follow the steps below:

  1. Clone the project:

    git clone https://github.com/patoliavishal/flutter-FCM.git
  2. Complete Firebase project setup for both Android & iOS platforms by going to the Firebase console.

  3. For Android, replace your google-services.json file with an existing file.

    android -> app -> google-services.json
  4. For running on iOS, you have to do some configurations from Xcode. Follow the guide here.

  5. Get Flutter packages:

    flutter pub get
  6. Run the app:

    flutter run

If my example really helpful to you then please don't forgot to press Star icon.

Sent Notification Using Postman

URL:

   https://fcm.googleapis.com/fcm/send

Method:

   POST

Header:

   "Content-Type": "application/json",
   "Authorization": "key=<Server_key>"

Body:

   {
     "to": "/topics/flutter-notification",
     "notification": {
       "body": "Test Push Notification",
       "title": "Push Notification",
       "redirect": "product"
     },
     "data": {
       "title": "Push Notification",
       "message": "Test Push Notification",
       "redirect": "product"
     }
   }

Refer http-server-ref for more help.

License

Copyright (c) 2023 Vishal Patolia

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Contributing to Flutter FCM Push Notification

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -m 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create New Pull Request

flutter-fcm's People

Contributors

patoliavishal avatar vishalpatel19 avatar

Stargazers

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

Watchers

 avatar  avatar

flutter-fcm's Issues

restrict notifications

i have multi user types in my app say customer and pharmacist
so the scenario : assume that someone have to accounts , one for customer and another as pharmacist , when logged as customer i want to receive just a customer notifications and when logged as pharmacists just show notifications of the pharmacists

how to handle this?

Failed to Connect

Please help me. Thanks in advance.
Launching lib\main.dart on sdk gphone64 x86 64 in debug mode...
main.dart:1
โˆš Built build\app\outputs\flutter-apk\app-debug.apk.
Error connecting to the service protocol: failed to connect to http://127.0.0.1:49875/ONzENH4FU_g=/
Exited (sigterm)

Not showing any notification

Please help. Android Emulator is running but not showing any notification.
I used Firebase - message - new campaign to send Notifications.

W/er_notificatio( 1239): Accessing hidden method Landroid/os/WorkSource;->get(I)I (unsupported, reflection, allowed)
W/er_notificatio( 1239): Accessing hidden method Landroid/os/WorkSource;->getName(I)Ljava/lang/String; (unsupported, reflection, allowed)
I/flutter ( 1239): A new event was published!
D/CompatibilityChangeReporter( 1239): Compat change id reported: 160794467; UID 10150; state: ENABLED

IOS real device issue

i set up everything, uploaded APN key to firebase but IOS notifications not working on real device. Android works fine. Not sure what the issue is.

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.