TheCampApplication

MultiDexApplication class

createNotificationChannel

oreo ๋ฒ„์ „ ์ด์ƒ์—์„œ ํ•„์š”ํ•œ ์•Œ๋ฆผ์ฑ„๋„์„ ์ƒ์„ฑํ•œ๋‹ค. ํ•œ๋ฒˆ ์ƒ์„ฑ ํ•˜๋ฉด ๋‹ค์‹œ ์ƒ์„ฑํ•  ํ•„์š”๊ฐ€ ์—†์œผ๋ฏ€๋กœ SharedPreference์— ์ƒ์„ฑ์—ฌ๋ถ€๋ฅผ ์ €์žฅํ•œ๋‹ค.

private fun createNotificationChannel(){
    //oreo ๋ฒ„์ „ ์ด์ƒ์—์„œ๋งŒ ์ ์šฉ
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        SharedPreferenceManager.setNotiChannel(true)
        val notificationManager: NotificationManager =
            getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager

        //์ผ๋ฐ˜ ์•Œ๋ฆผ์ฑ„๋„(ํ‘ธ์‹œ ๋“ฑ)
        val notificationChannel =
            NotificationChannel(getString(R.string.noti_default_channel),
                getString(R.string.noti_default_channel_name),
                NotificationManager.IMPORTANCE_DEFAULT)
        notificationChannel.description = ""
        notificationChannel.setShowBadge(false)
        notificationChannel.enableLights(true)
        notificationChannel.lightColor = Color.GREEN
        notificationChannel.enableVibration(true)
        notificationChannel.vibrationPattern = longArrayOf(100, 200, 100, 200)
        notificationManager.createNotificationChannel(notificationChannel)
    }
}

Last updated

Was this helpful?