app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/MyFirebaseMessagingService.java
/**
     * Create and show a simple notification containing the received FCM message.
     *
     * @param messageBody FCM message body received.
     */
Create and show a simple notification containing the received FCM message.
@param messageBody FCM message body received.
Create and show a simple notification containing the received FCM message . @param messageBody FCM message body received .
private void sendNotification(String messageBody) {
        Intent intent = new Intent(this, MainActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
                PendingIntent.FLAG_ONE_SHOT);
        Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
                .setSmallIcon(R.drawable.check)
                .setContentTitle("FCM Message")
                .setContentText(messageBody)
                .setAutoCancel(true)
                .setSound(defaultSoundUri)
                .setContentIntent(pendingIntent);
        NotificationManager notificationManager =
                (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
    }
private void sendNotification ( String messageBody ) { Intent intent = new Intent ( this , MainActivity . class ) ; intent . addFlags ( Intent . FLAG_ACTIVITY_CLEAR_TOP ) ; PendingIntent pendingIntent = PendingIntent . getActivity ( this , 0 /* Request code */ , intent , PendingIntent . FLAG_ONE_SHOT ) ; Uri defaultSoundUri = RingtoneManager . getDefaultUri ( RingtoneManager . TYPE_NOTIFICATION ) ; NotificationCompat . Builder notificationBuilder = new NotificationCompat . Builder ( this ) . setSmallIcon ( R . drawable . check ) . setContentTitle ( "FCM Message" ) . setContentText ( messageBody ) . setAutoCancel ( true ) . setSound ( defaultSoundUri ) . setContentIntent ( pendingIntent ) ; NotificationManager notificationManager = ( NotificationManager ) getSystemService ( Context . NOTIFICATION_SERVICE ) ; notificationManager . notify ( 0 /* ID of notification */ , notificationBuilder . build ( ) ) ; }
Create and show a simple notification containing the received FCM message.
Create and show a simple notification containing the received FCM message .