Skip to content

Instantly share code, notes, and snippets.

@preetjdp
Created October 23, 2019 14:07
Show Gist options
  • Select an option

  • Save preetjdp/104fcde097aa93796fb8885618ae899a to your computer and use it in GitHub Desktop.

Select an option

Save preetjdp/104fcde097aa93796fb8885618ae899a to your computer and use it in GitHub Desktop.
package com.obodo.app
import android.os.Bundle
import android.app.NotificationChannel
import android.app.NotificationManager
import android.content.Context
import android.os.Build
import io.flutter.app.FlutterActivity
import io.flutter.plugins.GeneratedPluginRegistrant
class MainActivity: FlutterActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
GeneratedPluginRegistrant.registerWith(this)
createNotificationChannel()
}
private fun createNotificationChannel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val name = "Product Chats"
val descriptionText = "These are the product chats"
val importance = NotificationManager.IMPORTANCE_DEFAULT
val CHANNEL_ID = "product_chats_channel"
val channel = NotificationChannel(CHANNEL_ID, name, importance).apply {
description = descriptionText
}
// Register the channel with the system
val notificationManager: NotificationManager =
getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
notificationManager.createNotificationChannel(channel)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment