From bd5c2140a70660161e7b44380b1089008a46cf8a Mon Sep 17 00:00:00 2001 From: priagungs <priagungsatyagama@gmail.com> Date: Sat, 23 Feb 2019 15:36:52 +0700 Subject: [PATCH] modified notif icon --- android/app/src/main/AndroidManifest.xml | 6 +++--- .../com/chatman/service/PushNotificationService.java | 10 +++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index ce47978..9faa4a1 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -17,9 +17,9 @@ Set custom default icon. This is used when no icon is set for incoming notification messages. See README(https://goo.gl/l4GJaQ) for more. --> - <!-- <meta-data --> - <!-- android:name="com.google.firebase.messaging.default_notification_icon" --> - <!-- android:resource="@drawable/logo" /> --> + <meta-data + android:name="com.google.firebase.messaging.default_notification_icon" + android:resource="@mipmap/chatman_launcher_round" /> <!-- <!– Set color used with incoming notification messages. This is used when no color is set for the incoming --> <!-- notification message. See README(https://goo.gl/6BKBk7) for more. –> --> <!-- <meta-data --> diff --git a/android/app/src/main/java/com/chatman/service/PushNotificationService.java b/android/app/src/main/java/com/chatman/service/PushNotificationService.java index 4d73cbf..58ee1a6 100644 --- a/android/app/src/main/java/com/chatman/service/PushNotificationService.java +++ b/android/app/src/main/java/com/chatman/service/PushNotificationService.java @@ -7,12 +7,16 @@ import android.app.PendingIntent; import android.app.Service; import android.content.Context; import android.content.Intent; +import android.graphics.Bitmap; import android.graphics.Color; +import android.graphics.drawable.BitmapDrawable; +import android.graphics.drawable.Drawable; import android.media.RingtoneManager; import android.net.Uri; import android.os.Build; import android.os.IBinder; import android.support.v4.app.NotificationCompat; +import android.support.v4.content.ContextCompat; import android.util.Log; import com.chatman.MainActivity; @@ -84,11 +88,15 @@ public class PushNotificationService extends FirebaseMessagingService { PendingIntent.FLAG_UPDATE_CURRENT); // Build the notification with all of the parameters. + Drawable drawable= ContextCompat.getDrawable(this,R.mipmap.chatman_launcher_round); + Bitmap bitmap = ((BitmapDrawable)drawable).getBitmap(); + NotificationCompat.Builder notifyBuilder = new NotificationCompat .Builder(this, getString(R.string.default_notification_channel_id)) .setContentTitle(title) .setContentText(text) - .setSmallIcon(R.drawable.ic_launcher_foreground) + .setSmallIcon(R.mipmap.chatman_launcher_round) + .setLargeIcon(bitmap) .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)) .setAutoCancel(true).setContentIntent(notificationPendingIntent) .setPriority(NotificationCompat.PRIORITY_HIGH) -- GitLab