app/src/main/java/io/lbry/browser/LbrynetMessagingService.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 title, String messageBody, String type, String url, String name,
                                  String contentTitle, String channelUrl, String publishTime) {
        if (url == null) {
            if (TYPE_REWARD.equals(type)) {
                url = "lbry://?rewards";
            } else {
                url = "lbry://?discover";
            }
        }
        Intent launchIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
        launchIntent.putExtra("notification_name", name);
        launchIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, launchIntent, PendingIntent.FLAG_ONE_SHOT);
        Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        NotificationCompat.Builder notificationBuilder =
                new NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID)
                        .setColor(ContextCompat.getColor(this, R.color.lbryGreen))
                        .setSmallIcon(R.drawable.ic_lbry)
                        .setContentTitle(title)
                        .setContentText(messageBody)
                        .setAutoCancel(true)
                        .setSound(defaultSoundUri)
                        .setContentIntent(pendingIntent);
        NotificationManager notificationManager =
                (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            NotificationChannel channel = new NotificationChannel(
                    NOTIFICATION_CHANNEL_ID, "LBRY Engagement", NotificationManager.IMPORTANCE_DEFAULT);
            notificationManager.createNotificationChannel(channel);
        }
        notificationManager.notify(3, notificationBuilder.build());
    }
private void sendNotification ( String title , String messageBody , String type , String url , String name , String contentTitle , String channelUrl , String publishTime ) { if ( url == null ) { if ( TYPE_REWARD . equals ( type ) ) { url = "lbry://?rewards" ; } else { url = "lbry://?discover" ; } } Intent launchIntent = new Intent ( Intent . ACTION_VIEW , Uri . parse ( url ) ) ; launchIntent . putExtra ( "notification_name" , name ) ; launchIntent . setFlags ( Intent . FLAG_ACTIVITY_CLEAR_TOP | Intent . FLAG_ACTIVITY_SINGLE_TOP ) ; PendingIntent pendingIntent = PendingIntent . getActivity ( this , 0 , launchIntent , PendingIntent . FLAG_ONE_SHOT ) ; Uri defaultSoundUri = RingtoneManager . getDefaultUri ( RingtoneManager . TYPE_NOTIFICATION ) ; NotificationCompat . Builder notificationBuilder = new NotificationCompat . Builder ( this , NOTIFICATION_CHANNEL_ID ) . setColor ( ContextCompat . getColor ( this , R . color . lbryGreen ) ) . setSmallIcon ( R . drawable . ic_lbry ) . setContentTitle ( title ) . setContentText ( messageBody ) . setAutoCancel ( true ) . setSound ( defaultSoundUri ) . setContentIntent ( pendingIntent ) ; NotificationManager notificationManager = ( NotificationManager ) getSystemService ( Context . NOTIFICATION_SERVICE ) ; if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . O ) { NotificationChannel channel = new NotificationChannel ( NOTIFICATION_CHANNEL_ID , "LBRY Engagement" , NotificationManager . IMPORTANCE_DEFAULT ) ; notificationManager . createNotificationChannel ( channel ) ; } notificationManager . notify ( 3 , notificationBuilder . build ( ) ) ; }
Create and show a simple notification containing the received FCM message.
Create and show a simple notification containing the received FCM message .
//Intent intent = new Intent(this, MainActivity.class); //intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // default to home page // Since android Oreo notification channel is needed.