Integration Steps

1

Create a Firebase project in the firebase console

To start sending notifications from FCM, you’ll have to first create a firebase project. Create a firebase project and application in firebase console with your applications package name which you can find in MainApplication.java or AndroidManifest.xml.

2

Adding google-services.json to your project

You can get your Service Account JSON from Firebase Console Project Settings. Download google-services.json and add the file inside your android > app folder.

3

Adding Firebase dependencies and plugins

Add the below dependency inside projects build.gradle inside dependencies

dependencies {
        ...
        classpath 'com.google.gms:google-services:4.3.10' // or latest version
}

Add the below plugin inside the app build.gradle

apply plugin: 'com.google.gms.google-services'

Add the below dependency inside apps build.gradle inside dependencies

implementation("com.google.firebase:firebase-messaging:22.0.0") // or latest version
4

Implementing push

Push feature can be implemented in two ways:

Targeting Android 13 (API-33):

In Android13 (API 33) or higher notification permission will be disabled by default so permission needs to be asked to enable notifications if you are targeting android 13 users. You can follow this doc to update to support Andriod 13(API 33), if not already supported: https://developer.android.com/about/versions/13/setup-sdk. Please test the application as well as upgrading to API 33 may causes breaking changes.

1

Add POST_NOTIFICATIONS permission in AndroidManifest.xml if not present already.

<manifest ...>
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/> 
    <application ...>
        ...
    </application>
</manifest>
2

Call the SDK method to show a notification permission popup

This method is asynchronous and returns permission values like granted, denied, and never_ask_again.

NOTE: This method is asynchronous and returns permission values like granted, denied, and never_ask_again.

const permission = await Suprsend.askNotificationPermission();

Once permission is granted users can be able to get push notifications.