File tree Expand file tree Collapse file tree 5 files changed +8027
-8212
lines changed
android/src/main/java/com/reactnativecustomtimernotification Expand file tree Collapse file tree 5 files changed +8027
-8212
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,7 @@ RemoveTimer(160211114);
50
50
foreground: false ,
51
51
date: new Date (Date .now () + 20000 ),
52
52
isCountDown: true , // false for positive timer
53
+ setCustomContentView: true // optional
53
54
});
54
55
```
55
56
Original file line number Diff line number Diff line change @@ -90,7 +90,13 @@ var removedNotification = false;
90
90
val payload = objectData.getString(" payload" );
91
91
val id = objectData.getInt(" id" );
92
92
val isCountDown = objectData.getBoolean(" isCountDown" )
93
-
93
+
94
+ val setCustomContentView =
95
+ if (objectData.hasKey(" setCustomContentView" ))
96
+ objectData.getBoolean(" setCustomContentView" )
97
+ else
98
+ true ;
99
+
94
100
val datetime = objectData.getString(" date" )
95
101
val sdf = SimpleDateFormat (" dd-MM-yyyy HH:mm:ss" , Locale .ENGLISH )
96
102
@@ -145,12 +151,15 @@ var removedNotification = false;
145
151
.setContentTitle(title)
146
152
.setContentText(body)
147
153
.setOnlyAlertOnce(true )
148
- .setStyle(NotificationCompat .DecoratedCustomViewStyle ())
149
154
.setCustomContentView(notificationLayout)
150
155
.setContentIntent(pendingIntent)
151
156
.setDeleteIntent(onDismissPendingIntent)
152
157
.setPriority(NotificationCompat .PRIORITY_HIGH )
153
158
.setWhen(endTime.getTimeInMillis());
159
+
160
+ if (setCustomContentView)
161
+ notificationBuilder.setStyle(NotificationCompat .DecoratedCustomViewStyle ())
162
+
154
163
val handler = Handler ()
155
164
if (isCountDown)
156
165
handler.postDelayed({
Original file line number Diff line number Diff line change @@ -16,13 +16,12 @@ export default function App() {
16
16
body : 'Much longer text that cannot fit one line... ' ,
17
17
id : 160211114 ,
18
18
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
22
23
} ) ;
23
- setTimeout ( ( ) => {
24
- RemoveTimer ( 160211114 , true ) ;
25
- } , 5000 ) ;
24
+
26
25
} , [ ] ) ;
27
26
28
27
return < > </ > ;
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " react-native-custom-timer-notification" ,
3
- "version" : " 0.6 .0" ,
3
+ "version" : " 0.7 .0" ,
4
4
"description" : " custom timer notification" ,
5
5
"main" : " lib/commonjs/index" ,
6
6
"module" : " lib/module/index" ,
You can’t perform that action at this time.
0 commit comments