Skip to content

10zgurr/NotificationMan

Repository files navigation

NotificationMan

This library's superpower is firing scheduled local notifications. Even the app is killed.

Implementation:

Groovy .gradle:

Add it in your root build.gradle at the end of repositories:

allprojects {
  repositories {
    ...
    maven { url 'https://jitpack.io' }
    }
}

Add it in the your app dependencies:

dependencies {
  ...
  implementation 'com.github.theozgurr:NotificationMan:1.0.8'
}

Kotlin .gradle.kts:

Add it in your root build.gradle.kts at the end of repositories:

allprojects {
  repositories {
    ...
    maven(url = "https://jitpack.io")
    }
}

Add it in the your app dependencies:

dependencies {
  ...
  implementation("com.github.theozgurr:NotificationMan:1.0.8")
}

Usage:

NotificationMan
        .Builder(context = this, classPathWillBeOpen = "com.notification.man.MainActivity") // the activity's path that you want to open when the notification is clicked
        .setTitle(title = "test title") // optional
        .setDescription(desc = "test desc") // optional
        .setThumbnailUrl(thumbnailUrl = "image url") // optional
        .setTimeInterval(timeInterval = 10L) // needs secs - default is 5 secs
        .setNotificationType(type = NotificationTypes.IMAGE.type) // optional - default type is TEXT
        .setNotificationChannelConfig(config = createNotificationManChannelConfig()) // optional
        .fire()

Canceling the latest added worker in the queue:

NotificationMan
        .coolDownLatestFire(context)

Canceling all workers:

NotificationMan
        .coolDownAllFires(context)

You can also set your custom notification channel configuration. This is optional to set:

NotificationManChannelConfig
        .Builder()
        .setChannelId(id = "notification-man-channel")
        .setChannelName(name = "custom-channel-name")
        .setImportanceLevel(level = NotificationImportanceLevel.HIGH)
        .setShowBadge(shouldShow = true)
        .build()

One important note, with Android13, make sure that your app has the post notification permission to have functionality of the app. You can check requesting the permission here.

App is in the foreground:


Exit the app:


App is in the background:


App is killed: