Skip to content

Commit 56d943e

Browse files
committed
removed notification when timer ends
1 parent e53f72f commit 56d943e

File tree

4 files changed

+41603
-8013
lines changed

4 files changed

+41603
-8013
lines changed

android/src/main/java/com/reactnativecustomtimernotification/CustomTimerNotificationModule.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class CustomTimerNotificationModule: ReactContextBaseJavaModule {
3939
lateinit var builder: Notification.Builder
4040
val channelId:String = "255"
4141
var packageName: String = ""
42-
42+
var removedNotification = false;
4343
lateinit var myContext: ReactApplicationContext;
4444

4545
constructor (context:ReactApplicationContext):super(context){
@@ -56,7 +56,7 @@ class CustomTimerNotificationModule: ReactContextBaseJavaModule {
5656
params.putString("action", extras!!.getString("action"))
5757
params.putString("payload", extras!!.getString("payload"))
5858
removeNotification(extras!!.getInt("id"),foregound)
59-
59+
removedNotification = true
6060
sendEvent("notificationClick", params)
6161
} catch (e: Exception) {
6262
println(e)
@@ -90,7 +90,7 @@ class CustomTimerNotificationModule: ReactContextBaseJavaModule {
9090
val payload = objectData.getString("payload");
9191
val id =objectData.getInt("id");
9292
val isCountDown = objectData.getBoolean("isCountDown")
93-
93+
9494
val datetime = objectData.getString("date")
9595
val sdf = SimpleDateFormat("dd-MM-yyyy HH:mm:ss", Locale.ENGLISH)
9696

@@ -170,6 +170,7 @@ class CustomTimerNotificationModule: ReactContextBaseJavaModule {
170170
}
171171

172172
notificationBuilder.setCustomContentView(notificationLayout)
173+
if(!removedNotification)
173174
notificationManager.notify(id,notificationBuilder.build())
174175
}, Math.abs(elapsed))
175176
return notificationBuilder

0 commit comments

Comments
 (0)