Notify.cancelNotification(id) causes KotlinNullPointerException
NLLAPPS opened this issue · comments
NLL APPS commented
Hi,
Notify.cancelNotification(id) Seems to cause KotlinNullPointerException if you have not used/initialized Notify before. This is probably "notificationManager" is null in Notify.kt at cancelNotification(id: Int)
Deprecated Notify.with(context).cancel(id) works fine.
Where is the scenario I am able to reproduce it. I have following function where it can be called with "false" before "true". Crash happens when it is called with "false" before it "true". Crash does not happen if you call it with "true" first.
`fun focusModeIsOn2(context: Context, show: Boolean) {
if (show) {
Notify.with(context)
{ ...... }.show(focusModeOnNotificationId)
} else {
//Notify.with(context).cancel(focusModeOnNotificationId)
Notify.cancelNotification(focusModeOnNotificationId)
}
}`
Karn Saheb commented
Awesome find @NLLAPPS! I've created a PR above to address the issue.
Cheers!