TapTalk.io Documentation
  • Introduction
  • OneTalk Omnichannel Documentation
    • Getting Started with OneTalk
      • Team Members
      • Add Topic
      • Assign Agent to Topic
      • Paid Proactive Chat
    • Channel Integration
      • Telegram Integration
      • WhatsApp SME Integration
      • Instagram DM Integration
      • Facebook Messenger Integration
      • Live Chat Integration (iOS, Android, Web)
        • OneTalk Live Chat for Android
          • Get Started
          • Event Listener
          • Authentication
          • Case & Topic
          • Navigate Live Chat UI
          • Customize UI Appearance
        • OneTalk Live Chat for iOS
          • Get Started
          • Background Process in TapTalk.io Omnichannel iOS
          • Event Delegate
          • Authentication
          • Case & Topic
          • Navigate Live Chat UI
          • Customize UI Appearance
        • OneTalk Live Chat for Web
          • Get Started
          • Callback
          • Method
        • OneTalk Live Chat for React Native
          • Get Started - Android
          • Authentication - Android
          • Get Started - iOS
          • Authentication - iOS
        • OneTalk Live Chat for Flutter
          • Get Started - Android
          • Get Started - iOS
      • Google Business Messages Integration
      • Google Business Profile Integration
      • Tokopedia Integration
    • Integration API
      • Inbox API
      • User/Contact API
    • Live Chat Widget Callback Function
    • Social Channel Button
    • Custom Chatbot Integration
      • Get Started
      • Edit or Delete Chatbot
      • Development
    • QnA via API
    • Webhook
  • PowerTalk Chat SDK Documentation
    • Getting Started with PowerTalk
    • PowerTalk Android
      • Get Started
      • Enable Chat Features
      • Authentication
      • TapUI and TapCore
      • Background Process in TapTalk.io
      • Connection
      • Event Listener
      • Push Notification
      • General
      • User
      • Room List
        • Room List - TapUI
        • Room List - TapCore
      • Chat Room and Messages
        • Chat Room and Messages - TapUI
        • Chat Room and Messages - TapCore
      • Contact
      • Message Type
      • Customize UI Appearance
      • Customize Chat Features
      • Customize Chat Message Bubble
      • Customize Navigation Bar
      • Deep Linking
      • Error Codes
    • PowerTalk iOS
      • Get Started
      • TapUI and TapCore
      • Background Process in TapTalk.io
      • Implement Application Delegate
      • Authentication
      • Connection
      • Event Delegate
      • Push Notification
      • General
      • User
      • Room List
        • Room List - TapUI
        • Room List - TapCore
      • Chat Room and Messages
        • Chat Room and Messages - TapUI
        • Chat Room and Messages - TapCore
      • Contact
      • Message Type
      • Customize UI Appearance
      • Customize Chat Features
      • Customize Chat Message Bubble
      • Customize Navigation Bar
      • Deep Linking
      • Error Codes
    • PowerTalk React Native
      • Get Started - Android
      • Get Started - iOS
    • PowerTalk Flutter
      • Get Started - Android
      • Get Started - iOS
    • Javascript SDK
      • Get Started
      • Authentication
      • Connection
      • General
      • Event Listener
      • User
      • Room List
      • Chat Room
      • Messages
      • Contact
      • Message Type
    • Server API
      • Get Started
      • Base URL
      • Authentication
      • User
      • Contact
      • Message
      • Room
    • Webhook
      • Get Started
      • Webhook Payload
  • MeetTalk SDK Documentation
    • Getting Started with MeetTalk
    • MeetTalk Android
      • Get Started
      • Event Listener
    • MeetTalk iOS
      • Get Started
      • Implement Application Delegate
      • Event Delegate
  • SendTalk API Documentation
    • Introduction
    • Whatsapp Verification
Powered by GitBook
On this page
  • Step 1: Add Firebase Cloud Messaging and Google Play Service Dependencies
  • Step 2: Create Project and Get google-service.json File
  • Step 3: Register the FCM Server Key and Sender ID to Taptalk.io Dashboard

Was this helpful?

  1. PowerTalk Chat SDK Documentation
  2. PowerTalk Android

Push Notification

Push notification is a very important aspect of a chat application. Taptalk.io provides a convenient way to implement push notifications so you can easily manage them according to your needs. If you implement Taptalk.io with the UI implementation method, incoming notifications will be handled within our library and will be automatically shown to the user. If you prefer having full control over the push notifications, the core implementation method can be used.

Before you get a notification from your message, you must ensure that the following steps are setup properly in your application. The first step is to create your project on Firebase Console and have the google-service.json file in your application project. The next step is to register the FCM Server Key and Sender ID on the Taptalk.io dashboard.

Step 1: Add Firebase Cloud Messaging and Google Play Service Dependencies

Implement Google Play Service dependency to your build.grade project file.

dependencies {
    classpath 'com.google.gms:google-services:$gms_version'
}

Apply google play service plugin and implement firebase messaging dependency to your app-level build.gradle

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

dependencies {
   implementation 'com.google.firebase:firebase-messaging:$firebase_version'
}

If you have implemented your own push notification to your app, you may add this code in your FirebaseMessagingService class to let Taptalk handle the chat notification.

import io.taptalk.TapTalk.Helper.TapTalk;
import io.taptalk.TapTalk.Listener.TapCommonListener;

...

public class YourFirebaseMessagingService extends FirebaseMessagingService {

  @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        super.onMessageReceived(remoteMessage);
        if (TapTalk.isTapTalkNotification(remoteMessage)) {
            TapTalk.handleTapTalkPushNotification(remoteMessage);
        }
        else {
            // Your own notification here 
        }
    }

    @Override
    public void onNewToken(String s) {
        super.onNewToken(s);
        TapTalk.saveFirebaseToken(s);
        TapTalk.updateFirebaseTokenToServer(new TapCommonListener() {
            @Override
            public void onSuccess(String successMessage) {
                // Successfully updated token
            }
    
            @Override
            public void onError(String errorCode, String errorMessage) {
            
            }
        });
    }
}
import io.taptalk.TapTalk.Helper.TapTalk
import io.taptalk.TapTalk.Listener.TapCommonListener

...

class YourFirebaseMessagingService : FirebaseMessagingService() {
    override fun onMessageReceived(remoteMessage: RemoteMessage?) {
        super.onMessageReceived(remoteMessage)
        if (TapTalk.isTapTalkNotification(remoteMessage!!)) {
            TapTalk.handleTapTalkPushNotification(remoteMessage)
        }
        else {
            // Your own notification here
        }
    }

    override fun onNewToken(s: String?) {
        super.onNewToken(s)
        TapTalk.saveFirebaseToken(s)
        TapTalk.updateFirebaseTokenToServer(object : TapCommonListener() {
            override fun onSuccess(successMessage: String?) {
                // Successfully updated token
            }
        
            override fun onError(errorCode: String?, errorMessage: String?) {
        
            }
        })
    }
}

Otherwise, if you don't handle your own app notification, you can add Taptalk default Firebase Service to your Manifest file.AndroidManifest.xml

<service android:name="io.taptalk.TapTalk.Firebase.TapFirebaseMessagingService">
     <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT" />
     </intent-filter>
</service>

Step 2: Create Project and Get google-service.json File

Before getting notifications, you are required to add firebase to your android project by having a google-service.json file. If the file is already in the folder in your project, no additional steps are needed and you can skip Step 1. If it isn't, you can easily add the file to your project in the way below.

import io.taptalk.TapTalk.Listener.TapListener;
import io.taptalk.TapTalk.Model.TAPMessageModel;

...

TapListener tapListener = new TapListener() {
    @Override
    public void onNotificationReceived(TAPMessageModel message) {
        // Implement your notification here
        super.onNotificationReceived(message); // Using super will show TapTalk's default notification
    }
};
import io.taptalk.TapTalk.Listener.TapListener
import io.taptalk.TapTalk.Model.TAPMessageModel

...

var tapListener: TapListener = object : TapListener() {
    override fun onNotificationReceived(message: TAPMessageModel?) {
        // Implement your notification here
        super.onNotificationReceived(message) // Using super will show TapTalk's default notification
    }
}

Note: TapTalk will also show its default notification if your do not override the onNotificationReceived method in TapListener

import io.taptalk.TapTalk.Listener.TapListener;

...

TapListener tapListener = new TapListener() {
    @Override
    public void onTaskRootChatRoomClosed(Activity activity) {
        // Open your application's main activity here
        Intent intent = new Intent(activity, YourMainActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
        activity.startActivity(intent);
    }
};
import io.taptalk.TapTalk.Listener.TapListener

...

var tapListener: TapListener = object : TapListener() {
    override fun onTaskRootChatRoomClosed(activity: Activity?) {
        // Open your application's main activity here
        val intent = Intent(activity!!, YourMainActivity::class.java)
        intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
        activity.startActivity(intent)
    }
}

Step 3: Register the FCM Server Key and Sender ID to Taptalk.io Dashboard

3. Next, select Add FCM Key

4. Fill in the FCM Server Key and FCM Sender ID field and click Save

5. Finally the FCM Server Key and FCM Sender ID will be saved to your project and will be used for push notifications in your application.

PreviousEvent ListenerNextGeneral

Last updated 1 month ago

Was this helpful?

There are 2 options to add the google-service.json file, the first is through the Firebase Console. You will be asked to create and register your project to get the google-service.json file. The second option is using Firebase Assistant where you have to add the plugin in your Android Studio then log in with a google account to connect and configure. For the second option, the google-service.json file will not be needed to be added manually, Firebase Assistant will help you to add it to your project. For further instruction for generating google-service.json file, .

After adding firebase to your account, if you are using UI implementation method, the process of activating notification is complete. But if you are using core or combined implementation, you can override the onNotificationReceived method in to implement your own push notification style, or you can use TapTalk's default notification like below.

If you are using TapTalk's default chat notification, TapTalk's chat room will be opened when the user taps the push notification from the phone. Note that your application's main activity will not be present when this happens, and the application will exit once the user closes the chat room. To prevent this, you can override the onTaskRootChatRoomClosed method in to open your application's main activity when the user closes the chat room as shown below.

1. Go to , and login to your dashboard. 2. Select Tab Development -> Push Certificates

check out the complete documentation
TapTalk.io Dashboard page
TapListener
TapListener