// 알림 창 표시
private fun sendNotification(title: String?, body: String?, categoryId: Long?, noteId: Long?, noteType: String?)
{
val notiIconClickIntent = Intent(this, MainActivity::class.java).apply {
flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
putExtra("categoryId", categoryId);
putExtra("noteId", noteId);
putExtra("noteType", noteType ?: "");
}
val CHANNEL_ID = "CollocNotification"
val CHANNEL_NAME = "CollocChannel"
val description = "This
is Colloc channel"
val importance = NotificationManager.IMPORTANCE_HIGH
var notificationManager: NotificationManager = this.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
if( android.os.Build.VERSION.SDK_INT >=
android.os.Build.VERSION_CODES.O) {
val channel = NotificationChannel(CHANNEL_ID, CHANNEL_NAME, importance)
channel.description = description
channel.enableLights(true)
channel.lightColor = Color.RED
channel.enableVibration(true)
channel.setShowBadge(false)
notificationManager.createNotificationChannel(channel)
}
var pendingIntent = PendingIntent.getActivity(this, 0, notiIconClickIntent, PendingIntent.FLAG_UPDATE_CURRENT)
val notificationSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)
var notificationBuilder = NotificationCompat.Builder(this, CHANNEL_ID)
//.setLargeIcon(BitmapFactory.decodeResource(resources,
R.mipmap.ic_launcher))
//.setSmallIcon(R.mipmap.ic_launcher_round)
.setSmallIcon(if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) R.drawable.ic_stat_name else R.mipmap.ic_launcher_round)
.setColor(ContextCompat.getColor(this, R.color.colorPrimary))
.setContentTitle(title)
.setContentText(body)
.setAutoCancel(true)
.setSound(notificationSound)
.setContentIntent(pendingIntent)
notificationManager.notify(0, notificationBuilder.build());
}