ahmedelbagory332 / flutter_notification

This project is a sample example for pushing payload notification in flutter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Flutter App Screenshots

Note

read all file before donig anything 

Getting Started

This project is a sample example for pushing payload notification and i will put all links which i learned from this project works perfectly on android platform but for ios i have not the requirement for it

setp 1

add your project on firebase and make its settings 

setp 2

add these plugins : 
      firebase_messaging: ^7.0.3
      dio: ^3.0.10
      flutter_local_notifications: ^3.0.3
   in pubspec.yaml file

setp 3

now we have to create 2 file in this path (your project name/android/app/src/main/kotlin/your package name/)
    first file is jave class which name is FirebaseCloudMessagingPluginRegistrant (dont worry about red error)
    this calss to register plugins with native paltForm and for run this class we will create the second file in the same path 
    it will be another jave class called Application it will extends FlutterApplication and implements PluginRegistrantCallback

setp 4

open AndroidManifest file in this path (your project name/android/app/src/main/AndroidManifest)
    put these two permission 
          - android.permission.INTERNET
          - android.permission.VIBRATE
    and go to application tag and change  android:name="" to  android:name=".Application"
    and inside activity tag put intent filter 
                 with action: FLUTTER_NOTIFICATION_CLICK and category android.intent.category.DEFAULT
       dont worry if you dont know how to put  intent filter  you find everything in the links        

setp 5

in this step i create dart calss NotificationHelper which has all methods:
    -  uploadDevice this method to upload data like user mail and device token  
    - showNotificationWithDefaultSound this method to show notification
    - onSelectNotification this method to navigate when notification clicked
    
  we have two constructor:
   - main constructor which declared all variables in the class
   - named constructor which declared some variables in the class for back ground notification

setp 6

this is step is very important i have uplaod my server file in php which is responsible for sending notification
 - Config.php this is important file which has data base info like host name and DB name ..etc and has FIREBASE_API_KEY this key you can get from your fire base project setting
  this key very important for sending notification the rest of the files if you not good in php we will need a backend developer with you

Links

You will notice some similarities in some lines between this project and these links because
I did not rely on only one source until I was able to complete the project in this way.
Link 1
Link 2
Link 3
Link 4

About

This project is a sample example for pushing payload notification in flutter


Languages

Language:Dart 76.6%Language:Java 18.0%Language:Swift 3.7%Language:Kotlin 1.3%Language:Objective-C 0.4%