Created
October 23, 2019 14:07
-
-
Save preetjdp/104fcde097aa93796fb8885618ae899a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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