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);
5050 foreground: false ,
5151 date: new Date (Date .now () + 20000 ),
5252 isCountDown: true , // false for positive timer
53+ setCustomContentView: true // optional
5354 });
5455```
5556
Original file line number Diff line number Diff 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({
Original file line number Diff line number Diff 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 < > </ > ;
Original file line number Diff line number Diff line change 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" ,
You can’t perform that action at this time.
0 commit comments