Skip to content

Commit

Permalink
Updated Notification module
Browse files Browse the repository at this point in the history
  • Loading branch information
myofficework000 committed Mar 13, 2024
1 parent 6d46881 commit 8b9b480
Showing 1 changed file with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,42 @@ import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

/**
* This module provides dependencies related to notifications, such as notification builder
* and notification manager.
*/
@Module
@InstallIn(SingletonComponent::class)
class NotificationModule {

/**
* Provides a NotificationCompat.Builder instance for building notifications.
* @param context Application context.
* @return NotificationCompat.Builder instance.
*/
@Singleton
@Provides
fun provideNotificationBuilder(
@ApplicationContext context: Context
):NotificationCompat.Builder{
return NotificationCompat.Builder(context,"Main Channel ID")
): NotificationCompat.Builder {
return NotificationCompat.Builder(context, "Main Channel ID")
.setContentTitle("Inspiration for today")
.setContentText("Life is hard")
.setSmallIcon(R.drawable.baseline_notifications_24)
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
}

/**
* Provides a NotificationManagerCompat instance for managing notifications.
* Also creates a notification channel if it doesn't exist.
* @param context Application context.
* @return NotificationManagerCompat instance.
*/
@Singleton
@Provides
fun provideNotificationManager(
@ApplicationContext context: Context
):NotificationManagerCompat{
): NotificationManagerCompat {
val notificationManager = NotificationManagerCompat.from(context)
val channel = NotificationChannel(
"Main Channel ID",
Expand All @@ -43,4 +58,4 @@ class NotificationModule {
notificationManager.createNotificationChannel(channel)
return notificationManager
}
}
}

0 comments on commit 8b9b480

Please sign in to comment.