Search This Blog

Sunday, September 25, 2016

Firebase notification if you are creating a new one

Add firebase to your application

To add Firebase to your app you'll need a Firebase project and a Firebase configuration file for your app.
  1. Create a Firebase project in the Firebase console, if you don't already have one. If you already have an existing Google project associated with your mobile app, click Import Google Project. Otherwise, click Create New Project.
  2. Click Add Firebase to your Android app and follow the setup steps. If you're importing an existing Google project, this may happen automatically and you can just download the config file.
  3. When prompted, enter your app's package name. It's important to enter the package name your app is using; this can only be set when you add an app to your Firebase project.
  4. At the end, you'll download a google-services.json file. You can download this file again at any time.
  5. If you haven't done so already, copy this into your project's module folder, typically app/.

* Note: If you have multiple build variants with different package names defined, each app must be added to your project in Firebase console.

Add the SDK
If you would like to integrate the Firebase libraries into one of your own projects, you need to perform a few basic tasks to prepare your Android Studio project. You may have already done this as part of adding Firebase to your app.
First, add rules to your root-level build.gradle file, to include the google-services plugin: 
  buildscript {
        dependencies {
            classpath ''

Then, in your module Gradle file (usually the app/build.gradle), add the apply plugin line at the bottom of the file to enable the Gradle plugin:

apply plugin: ''


dependencies {
    // ...
    compile ''

apply plugin  : ''

Set Up a Firebase Cloud Messaging Client App on Android

FCM clients require devices running Android 2.3 or higher that also have the Google Play Store app installed, or an emulator running Android 2.3 with Google APIs. Note that you are not limited to deploying your Android apps through Google Play Store.

Edit your app manifest

Add the following to your app's manifest:
  • A service that extends FirebaseMessagingService. This is required if you want to do any message handling beyond receiving notifications on apps in the background. To receive notifications in foregrounded apps, to receive data payload, to send upstream messages, and so on, you must extend this service.
  • A service that extends FirebaseInstanceIdService to handle the creation, rotation, and updating of registration tokens. This is required for sending to specific devices or for creating device groups.
  • If FCM is critical to the Android app's function, be sure to set android:minSdkVersion="8" or higher in the manifest. This ensures that the Android app cannot be installed in an environment in which it could not run properly.

<action android:name=""/>

<action android:name=""/>


Check this for implementing these 2 services

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.