Appflow.ai
Visit our websitePricingSign up for freeLog in
  • GET STARTED
    • What is Appflow.ai?
    • Quickstart - How to start working with Appflow.ai?
    • FAQ
    • Ownership and other roles
  • SDK Set-up Instructions
    • Android SDK
      • Google Play Store Credentials
        • Google Service Account Key
        • Google real-time developer notifications(RTDN)
        • FCM server key(optional)(to be updated)
      • Events (Custom events)
      • Purchases
      • Visual constructor
      • User info
      • Push notifications
    • iOS SDK
      • Specify Apple Store Keys
      • Purchases and User Info
      • Event tracking (Custom events)
      • Push Notifications Configuration
      • Visual constructor
  • IN-APP PURCHASE
    • SKU adding
  • METRICS & EVENTS
    • Calculations of Analytics
    • Terms and Descriptions
    • Purchase Events
    • In-app Events
    • Events Structure
    • End-users Attributes
    • Users' statuses
  • SUBSCRIPTION ANALYTICS
    • Dashboard
    • Configurator
    • Reports
    • A/B Testing
    • Integrations
    • Create Push-notifications
    • In-app Messages
    • Return of Advertisement
    • Funnels
    • Funnel 2.0 BETA
    • Entitlements
    • Visual Constructor
  • INTEGRATIONS
    • Adjust
    • Appsflyer
    • Mixpanel
    • Webhooks
    • Apple Search Ads Attributions
    • Branch
    • Amplitude
  • OTHERS
    • Pricing plans and important information about your payments
    • Storing your data
    • Privacy Policy
    • Terms of Use
    • Unsubscribe from Appflow.ai
Powered by GitBook
On this page

Was this helpful?

  1. SDK Set-up Instructions
  2. Android SDK

Push notifications

The part of SDK needed to connect with your users through push-notifications


Add configuration file Create a project via the Firebase console, and download the google-services.json and move it into the app's modules (app level) directory

Apply gradle plugin a、If your project doesn't have dependencyResolutionManagement in your settings.gradle, add the following to your top-level build.gradle at the end of repositories:

top-level build.gradle

allprojects {
  repositories {
    ...
    // Check that you have the following line (if not, add it):
    google()  // Google's Maven repository
  }
}

Otherwise add the following to your settings.gradle in repositories of dependencyResolutionManagement section:

settings.gradle

dependencyResolutionManagement {
    repositories {
        ...
        // Check that you have the following line (if not, add it):
    		google()  // Google's Maven repository
    }
}

b、 add the following to your top-level build.gradle

top-level build.gradle

buildscript {
  repositories {
    // Check that you have the following line (if not, add it):
    google()  // Google's Maven repository
  }

  dependencies {
    // Add the following line:
    classpath 'com.google.gms:google-services:4.3.10'  // Google Services plugin
  }
}

c、In your module (app-level) Gradle file (usually app/build.gradle), apply the Google Services Gradle plugin:

app-level build.gradle

apply plugin: 'com.android.application'
// Add the following line:
apply plugin: 'com.google.gms.google-services'  // Google Services plugin

android {
  // ...
  // add the firebase dependency
  implementation platform('com.google.firebase:firebase-bom:29.0.3')
  implementation 'com.google.firebase:firebase-analytics'
  implementation 'com.google.firebase:firebase-messaging'  
}

notification message To get push messages, you have to call method:

Appflow.setListener(listener: FirebaseMsgListener)

Example

Appflow.setFirebaseMsgListener(object : Appflow.FirebaseMsgListener {
    override fun onNewToken(token: String) {
				//When the Firebase token is updated, it will be called back through this method
    }

    override fun onMessageReceived(remoteMessage: RemoteMessage) {
      	//When the App is in the background, when a push notification message is received, 
        //a notification will pop up directly in the system bar.
      	//When the App is in the foreground, a push notification is received, 
        //and the message is called back through this method.
        remoteMessage.notification?.let {
            Log.d(TAG,"Title:${it.title} Body: ${it.body}")
        }
    }
})

API Reference

FirebaseMsgListener

onNewToken(token: String)

When the Firebase token is updated, it will be called back through this method

onMessageReceived(remoteMessage: RemoteMessage)

Push notification message callback (when the App is in the foreground, the push notification will be called back)

PreviousUser infoNextiOS SDK

Last updated 1 year ago

Was this helpful?