how to implement push notification in flutter

后端 未结 3 840
猫巷女王i
猫巷女王i 2020-12-29 03:44

Hi I am trying to implement push notification in flutter how to display as notification can any one help,I am able to listen as I am getting notification but I am not able t

3条回答
  •  佛祖请我去吃肉
    2020-12-29 04:31


    1. Add Dependency

    For sending push notifications we use a plugin called firebase_messaging…

    https://pub.dev/packages/firebase_messaging

    Open your pubspec.yaml file and add this dependency

    dependencies: firebase_messaging: ^6.0.9


    2. Firebase Account

    Make sure you have a firebase account before proceeding.
    In the next step, you should be able to download the google-services.json file.

    After downloading the file, make sure to copy it inside the app/ folder of your Android project.


    3. Android Manifest

    ADD

    
      
      
    
    

    Add these lines to [project]/android/build.gradle

    dependencies {
        classpath 'com.android.tools.build:gradle:4.0.0'
        classpath 'com.google.gms:google-services:4.3.3'
    }
    



    Add these lines to [project]/android/app/build.gradle

     dependencies {
       implementation fileTree(dir: "libs", include: ["*.jar"])
       implementation 'androidx.appcompat:appcompat:1.1.0'
       implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
       implementation 'com.google.firebase:firebase-messaging:20.2.3'
       implementation 'com.google.firebase:firebase-analytics:17.4.4'
    
       // Add the SDK for Firebase Cloud Messaging
       testImplementation 'junit:junit:4.12'
       androidTestImplementation 'androidx.test.ext:junit:1.1.1'
       androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    
     }
    
    
     apply plugin: 'com.google.gms.google-services'
    

    DONE

提交回复
热议问题