LogoLogo
My AppsLive demoNewsArticles
  • Introduction
  • 📌Product updates: 2025
    • 2024
    • 2023
  • Getting Started
    • Registration
    • Adding a space
    • Adding an app to the space
  • Basic Events & Custom Events
  • Integration
    • Expert Tips
      • What to track
      • Payments & Anti-cheat
      • Check your integration
    • Integration of SDK 2.0+
      • SDK Integration
        • Android
        • iOS
        • macOS
        • Windows
        • Web
          • Web SDK Integration
          • Web SDK Releases
        • Unity
        • Unreal Engine
        • Godot Engine
      • Automatic payment tracking
        • App Store
        • Google Play
      • Setting up Events
        • Basic methods
        • Secondary methods
        • User profile
        • Anticheat methods
        • Track sessions
      • Push notifications
        • Android
        • iOS
        • Windows (UWP)
        • Unity
          • Android
          • iOS
          • Windows (UWP/WSA)
        • Unreal Engine
      • A/B testing
        • Description of A/B testing on the SDK side
        • Working with A/B tests in the devtodev interface
        • A/B testing examples
    • Integration of SDK 1.0+ (deprecated)
      • SDK Integration
        • iOS
        • Android
        • Windows 8.1 and 10
        • Web
        • Unity
        • Mac OS
        • Adobe Air
        • UE4
      • Setting up Events
        • Basic methods
        • Secondary methods
        • User profile
        • Anti-cheat Methods
      • Push Notifications
        • IOS
        • Android
        • Windows 8.1 and Windows 10
        • Unity
        • Abode Air
        • UE4
    • Test Devices
    • Server API
      • Data API 2.0
      • Subscription API
      • Push API
        • IOS
        • Android
        • Windows UWP
        • Windows
      • Raw Export
      • Labels API
      • Data API
    • Import historical data via API
    • Data Export
      • Data Export to Cloud Storage (BigQuery / Amazon S3)
  • 3rd Party Sources
    • Attribution Trackers
      • AppsFlyer
      • Adjust
      • Branch.io
      • Kochava
      • Tenjin
      • Tune (MAT)
      • Singular
      • Custom postback API
      • Facebook Ads referral decryption
    • App Marketplace Data
      • App Store Connect Stats
      • App Store Subscriptions
      • Google Play Console Stats
      • Google Play Subscriptions
      • AppGallery Connect Stats
    • Ad revenue
      • AdColony
      • AdMob
      • Facebook
      • MoPub
      • Unity Ads
      • Vungle
      • Ad revenue API
    • Cohort export
  • Reports and Functionality
    • Space-related Reports and Functionality
      • Overview
      • Custom dashboards & Reports
      • SQL
        • SQL tips
        • SQL Query examples
      • Audience overlap
    • Project-related Reports and Functionality
      • Overview
        • Real-Time Dashboard
        • Acquisition reports
        • Engagement reports
        • Monetization reports
        • In-game analysis reports
        • Cohort analysis
      • Reports
      • Push Notifications
        • Android Notifications
        • IOS Notifications
        • Windows Notifications
        • Button Templates
      • Predictions
      • Users & Segments
      • Filters
      • A/B Testing
      • Tuning
      • Settings
  • Metrics and Glossary
    • Ad networks metrics
    • Market Metrics
    • Prediction Metrics
    • SDK Metrics
    • Subscription metrics
  • Space Management
  • User Profile Management
  • Limits
  • Scenarios and Best Practices
    • Analytics use cases
    • Match-3
    • MMORPG Games
    • Hyper-Casual games
    • Social Casino
    • RPG games
    • Farming games
    • Non-gaming app
    • Acquisition Example
  • FAQ
    • Identification
    • Raw Data
    • All about data discrepancies
  • Slack
Powered by GitBook
On this page
  • Creating a project in Firebase
  • Obtaining the necessary keys
  • Implementation in the app
  • Changing the application settings in devtodev system
  • Creating a new push notification in devtodev interface

Was this helpful?

Export as PDF
  1. Integration
  2. Integration of SDK 1.0+ (deprecated)
  3. Push Notifications

Android

Android Push Notifications

PreviousIOSNextWindows 8.1 and Windows 10

Last updated 17 days ago

Was this helpful?

This generation of SDK is deprecated and is no longer supported. Information about the .

Push Notifications on Android are sent with the help of the FCM service. To work with it, two keys are required: a client and server key. If you have a project, move on to the second part of this article.

Creating a project in Firebase

Add a new project to the .

Fill in the name and country of your project.

Congratulations, the project has been created! Now you need to indicate the package name of your Android app.

Obtaining the necessary keys

Go to the settings of your Android project.

Remember or copy Server key and Sender ID from the Cloud Messaging tab. You will need them to integrate push notifications and create push campaigns.

Implementation in the app

Download the generated by google-service.json file and add it to the project.

  1. Project-level build.gradle (<project>/build.gradle):

    buildscript {
      dependencies {
        // Add this line
        classpath 'com.google.gms:google-services:4.3.3'
      }
    }
  2. App-level build.gradle (<project>/<app-module>/build.gradle):

    dependencies {
       ...
       implementation 'com.devtodev:android:1.14.5'
       implementation 'com.google.android.gms:play-services-base:17.1.0'
       implementation 'com.google.firebase:firebase-core:17.2.3'
       implementation 'com.google.firebase:firebase-messaging:20.1.0'
    }
    // Add to the bottom of the file
    apply plugin: 'com.google.gms.google-services'
  3. In Activity (where the SDK initializes) add the push notifications initialization and the listener of push notifications processing.

    public class MainActivity extends AppCompatActivity implements PushListener {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            DevToDevPushManager.setPushListener(this);
            DevToDevPushManager.init(getIntent());
        }
    
        @Override
        public void onRegisteredForPushNotifications(String s) {
            // Insert the code for processing the received token
    
        }
    
        @Override
        public void onFailedToRegisteredForPushNotifications(String s) {
            // Insert the code for tracking integration errors
        }
    
        @Override
        public void onPushNotificationsReceived(Map<String, String> map) {
            // Insert the code to track received notifications
        }
    
        @Override
        public void onPushNotificationOpened(PushMessage pushMessage, @Nullable ActionButton actionButton) {
            // Insert the code to track opened notification
        }
    }
  4. Optional. To set the custom icons to be shown in push-notification on the SDK part, use the following methods: To set the small icon:

    DevToDevPushManager.setCustomSmallIcon(int resourceId);

    To set the default color of the small icon:

    DevToDevPushManager.setCustomSmallIconColor(int colorHexadecimal)

    To set the large icon:

    DevToDevPushManager.setCustomLargeIcon(int resourceId);

    Use resources of your app. For example, R.drawable.ic_launcherIcons which set in the push-notification wizard have priority over the icons which set in these methods.

In case you use several push notifications services or would like to use your own implementation of FirebaseMessagingService, please add the call of the method for displaying messages sent from the devtodev system:

DevToDevPushManager.displayPushNotification(Context context, RemoteMessage remoteMessage);

For example:

public class MyFirebaseMessagingService extends FirebaseMessagingService {
    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        Map<String, String> data = remoteMessage.getData();
        if (data != null) {
            if (data.containsKey("_k")) {
                DevToDevPushManager.displayPushNotification(this, remoteMessage);
            } else {
                showNotification(remoteMessage);
            }
        }
    }
}

Changing the application settings in devtodev system

2. Proceed to Settings of your app in devtodev.

3. Go to Integration page and insert the previously received Firebase Cloud Messaging token to the FCM token field in Push notifications section.

4. If the Firebase Cloud Messaging token is correct, you will see the following result

Creating a new push notification in devtodev interface

  1. Fill in campaign name, select an app for delivery*

  2. Choose user group to send a message. You can choose existing segment or create a new one

  3. Enter notification details

  4. Make some tests and correct the message if it's required

  5. Schedule the delivery

  6. That's it!

You can create a campaign only after at least one push token comes from devtodev SDK integrated to your application. Otherwise the app will not be displayed in the list.

After a successful registration in Firebase, you can receive your keys that you will use in devtodev.

The Google services plugin for loads the google-services.json file that you just downloaded. Modify your build.gradle files to use the plugin.

Finally, press "Sync now" in the bar that appears in the IDE:

1. Go to and then to your project settings. On the Cloud messaging tab get the Firebase Cloud Messaging token of your project.

Open section and click on 'Add new campaign" button

Gradle
Firebase console
PUSH NOTIFICATIONS
current version can be found here
Firebase console