Skip to content

Commit 6969ae2

Browse files
committed
added setCustom Content View option
1 parent 56d943e commit 6969ae2

File tree

5 files changed

+8027
-8212
lines changed

5 files changed

+8027
-8212
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ RemoveTimer(160211114);
5050
foreground: false,
5151
date: new Date(Date.now() + 20000),
5252
isCountDown: true, // false for positive timer
53+
setCustomContentView:true // optional
5354
});
5455
```
5556

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,13 @@ var removedNotification = false;
9090
val payload = objectData.getString("payload");
9191
val id =objectData.getInt("id");
9292
val isCountDown = objectData.getBoolean("isCountDown")
93-
93+
94+
val setCustomContentView =
95+
if (objectData.hasKey("setCustomContentView"))
96+
objectData.getBoolean("setCustomContentView")
97+
else
98+
true;
99+
94100
val datetime = objectData.getString("date")
95101
val sdf = SimpleDateFormat("dd-MM-yyyy HH:mm:ss", Locale.ENGLISH)
96102

@@ -145,12 +151,15 @@ var removedNotification = false;
145151
.setContentTitle(title)
146152
.setContentText(body)
147153
.setOnlyAlertOnce(true)
148-
.setStyle(NotificationCompat.DecoratedCustomViewStyle())
149154
.setCustomContentView(notificationLayout)
150155
.setContentIntent(pendingIntent)
151156
.setDeleteIntent(onDismissPendingIntent)
152157
.setPriority(NotificationCompat.PRIORITY_HIGH)
153158
.setWhen(endTime.getTimeInMillis());
159+
160+
if(setCustomContentView)
161+
notificationBuilder.setStyle(NotificationCompat.DecoratedCustomViewStyle())
162+
154163
val handler = Handler()
155164
if(isCountDown)
156165
handler.postDelayed({

example/src/App.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@ export default function App() {
1616
body: 'Much longer text that cannot fit one line... ',
1717
id: 160211114,
1818
remove: false, // optional
19-
foreground: true,
20-
date: new Date(Date.now()),
21-
isCountDown: false,
19+
foreground: false,
20+
date: new Date(Date.now()+20000),
21+
isCountDown: true,
22+
setCustomContentView:true // optional
2223
});
23-
setTimeout(() => {
24-
RemoveTimer(160211114, true);
25-
}, 5000);
24+
2625
}, []);
2726

2827
return <></>;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-custom-timer-notification",
3-
"version": "0.6.0",
3+
"version": "0.7.0",
44
"description": "custom timer notification",
55
"main": "lib/commonjs/index",
66
"module": "lib/module/index",

0 commit comments

Comments
 (0)