package com.example.shillongpubgtornament; import android.app.Notification; import android.util.Log; import android.widget.Toast; import com.google.firebase.messaging.FirebaseMessagingService; import com.google.firebase.messaging.RemoteMessage; import static android.content.ContentValues.TAG; public class FCMService extends FirebaseMessagingService { @Override public void onMessageReceived(RemoteMessage remoteMessage) { // ... // TODO(developer): Handle FCM messages here. // Not getting messages here? See why this may be: https://goo.gl/39bRNJ Log.d(TAG, "From: " + remoteMessage.getFrom()); // Check if message contains a data payload. if (remoteMessage.getData().size() > 0) { Log.d(TAG, "Message data payload: " + remoteMessage.getData()); // NotificationUtils mNotificationUtils = new NotificationUtils(getApplicationContext()); // Notification.Builder nb = mNotificationUtils. // getAndroidChannelNotification("hello", "By " + "This is Kit"); // mNotificationUtils.getManager().notify(101, nb.build()); if (/* Check if data needs to be processed by long running job */ true) { // For long-running tasks (10 seconds or more) use Firebase Job Dispatcher. // scheduleJob(); } else { // Handle message within 10 seconds // handleNow(); } } // Check if message contains a notification payload. if (remoteMessage.getNotification() != null) { Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody()); // Toast.makeText(getApplicationContext(),remoteMessage.getNotification().getBody(),Toast.LENGTH_SHORT).show(); } // Also if you intend on generating your own notifications as a result of a received FCM // message, here is where that should be initiated. See sendNotification method below. } @Override public void onNewToken(String token) { Log.d(TAG, "Refreshed token: " + token); // If you want to send messages to this application instance or // manage this apps subscriptions on the server side, send the // Instance ID token to your app server. // sendRegistrationToServer(token); } }