@@ -125,6 +125,7 @@ class MainActivity : AppCompatActivity() {
125125 }
126126
127127 fun sendPermanentPush (subject : String , description : String , code : Int = 2023) {
128+ // If this is a more recent Android SDK, use a notification channel
128129 if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .O ) {
129130 notificationChannel =
130131 NotificationChannel (channelId, description, NotificationManager .IMPORTANCE_HIGH )
@@ -143,7 +144,7 @@ class MainActivity : AppCompatActivity() {
143144 addCategory(Intent .CATEGORY_LAUNCHER )
144145 }
145146 val pendingIntent: PendingIntent = PendingIntent .getActivity(this , 0 , actIntent,
146- PendingIntent .FLAG_UPDATE_CURRENT )
147+ PendingIntent .FLAG_UPDATE_CURRENT or PendingIntent . FLAG_MUTABLE )
147148
148149 builder.setSmallIcon(R .drawable.csh_logo)
149150 .setLargeIcon(BitmapFactory .decodeResource(this .resources, R .drawable.csh_logo))
@@ -162,7 +163,7 @@ class MainActivity : AppCompatActivity() {
162163 fun sendTemporaryPush (subject : String , description : String , code : Int = 2023) {
163164 if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .O ) {
164165 notificationChannel =
165- NotificationChannel (channelId, description, NotificationManager .IMPORTANCE_LOW )
166+ NotificationChannel (channelId, description, NotificationManager .IMPORTANCE_HIGH )
166167 notificationChannel.lightColor = Color .MAGENTA
167168 notificationManager.createNotificationChannel(notificationChannel)
168169
@@ -178,7 +179,7 @@ class MainActivity : AppCompatActivity() {
178179 addCategory(Intent .CATEGORY_LAUNCHER )
179180 }
180181 val pendingIntent: PendingIntent = PendingIntent .getActivity(this , 0 , actIntent,
181- PendingIntent .FLAG_UPDATE_CURRENT )
182+ PendingIntent .FLAG_UPDATE_CURRENT or PendingIntent . FLAG_IMMUTABLE )
182183
183184 builder.setSmallIcon(R .drawable.csh_logo)
184185 .setLargeIcon(BitmapFactory .decodeResource(this .resources, R .drawable.csh_logo))
@@ -196,6 +197,9 @@ class MainActivity : AppCompatActivity() {
196197 builder.setContentText(description)
197198 .style = Notification .BigTextStyle ()
198199 .bigText(description)
200+
201+ // Using the same notification code simply updates the old notification
202+ // Please ensure that your notification has .onlyAlertOnce(true) if using this
199203 notificationManager.notify(code, builder.build())
200204 }
201205
0 commit comments