@@ -12,6 +12,7 @@ import android.content.Context
1212import android.content.Intent
1313import android.os.Build
1414import android.webkit.WebView
15+ import app.tauri.Logger
1516import app.tauri.PermissionState
1617import app.tauri.annotation.Command
1718import app.tauri.annotation.InvokeArg
@@ -220,6 +221,7 @@ class NotificationPlugin(private val activity: Activity): Plugin(activity) {
220221
221222 super .load(webView)
222223 this .webView = webView
224+ Logger .debug(Logger .tags(" Notification" ), " Plugin load started" )
223225 synchronized(this ) {
224226 pendingActionEvents.clear()
225227 pendingActionEventKeys.clear()
@@ -239,6 +241,7 @@ class NotificationPlugin(private val activity: Activity): Plugin(activity) {
239241 this .manager = manager
240242
241243 notificationManager = activity.getSystemService(Context .NOTIFICATION_SERVICE ) as NotificationManager
244+ Logger .debug(Logger .tags(" Notification" ), " Plugin load complete; awaiting notification intents" )
242245
243246 val intent = activity.intent
244247 intent?.let {
@@ -248,16 +251,21 @@ class NotificationPlugin(private val activity: Activity): Plugin(activity) {
248251
249252 override fun onNewIntent (intent : Intent ) {
250253 super .onNewIntent(intent)
254+ Logger .debug(Logger .tags(" Notification" ), " onNewIntent received action=${intent.action} " )
251255 onIntent(intent)
252256 }
253257
254258 fun onIntent (intent : Intent ) {
255259 if (Intent .ACTION_MAIN != intent.action) {
260+ Logger .debug(Logger .tags(" Notification" ), " Ignoring intent action=${intent.action} " )
256261 return
257262 }
263+ Logger .debug(Logger .tags(" Notification" ), " Processing ACTION_MAIN intent for notification action" )
258264 val dataJson = manager.handleNotificationActionPerformed(intent, notificationStorage)
259265 if (dataJson != null ) {
260266 dispatchActionPerformed(dataJson)
267+ } else {
268+ Logger .debug(Logger .tags(" Notification" ), " No action payload extracted from intent" )
261269 }
262270 }
263271
@@ -284,12 +292,17 @@ class NotificationPlugin(private val activity: Activity): Plugin(activity) {
284292 return
285293 }
286294 }
295+ Logger .debug(Logger .tags(" Notification" ), " Dispatching actionPerformed event immediately" )
287296 trigger(" actionPerformed" , payload)
288297 }
289298
290299 @Command
291300 fun show (invoke : Invoke ) {
292301 val notification = invoke.parseArgs(Notification ::class .java)
302+ Logger .debug(
303+ Logger .tags(" Notification" ),
304+ " show called id=${notification.id} title=${notification.title} actionTypeId=${notification.actionTypeId} hasSchedule=${notification.schedule != null } "
305+ )
293306 val id = manager.schedule(notification)
294307
295308 invoke.resolveObject(id)
@@ -298,23 +311,30 @@ class NotificationPlugin(private val activity: Activity): Plugin(activity) {
298311 @Command
299312 fun batch (invoke : Invoke ) {
300313 val args = invoke.parseArgs(BatchArgs ::class .java)
314+ Logger .debug(
315+ Logger .tags(" Notification" ),
316+ " batch called notifications=${args.notifications.size} "
317+ )
301318
302319 val ids = manager.schedule(args.notifications)
303320 notificationStorage.appendNotifications(args.notifications)
321+ Logger .debug(Logger .tags(" Notification" ), " batch scheduled ids=$ids " )
304322
305323 invoke.resolveObject(ids)
306324 }
307325
308326 @Command
309327 fun cancel (invoke : Invoke ) {
310328 val args = invoke.parseArgs(CancelArgs ::class .java)
329+ Logger .debug(Logger .tags(" Notification" ), " cancel called notifications=${args.notifications} " )
311330 manager.cancel(args.notifications)
312331 invoke.resolve()
313332 }
314333
315334 @Command
316335 fun removeActive (invoke : Invoke ) {
317336 val args = invoke.parseArgs(RemoveActiveArgs ::class .java)
337+ Logger .debug(Logger .tags(" Notification" ), " removeActive called notifications=${args.notifications.size} " )
318338
319339 if (args.notifications.isEmpty()) {
320340 notificationManager.cancelAll()
@@ -334,29 +354,40 @@ class NotificationPlugin(private val activity: Activity): Plugin(activity) {
334354 @Command
335355 fun getPending (invoke : Invoke ) {
336356 val notifications= notificationStorage.getSavedNotifications()
357+ Logger .debug(Logger .tags(" Notification" ), " getPending returning count=${notifications.size} " )
337358 val result = Notification .buildNotificationPendingList(notifications)
338359 invoke.resolveObject(result)
339360 }
340361
341362 @Command
342363 fun registerActionTypes (invoke : Invoke ) {
343364 val args = invoke.parseArgs(RegisterActionTypesArgs ::class .java)
365+ Logger .debug(
366+ Logger .tags(" Notification" ),
367+ " registerActionTypes called types=${args.types.size} "
368+ )
344369 notificationStorage.writeActionGroup(args.types)
345370 invoke.resolve()
346371 }
347372
348373 @Command
349374 fun registerActionListenerReady (invoke : Invoke ) {
350375 val pending = JSArray ()
376+ var drainedCount = 0
351377 synchronized(this ) {
352378 isActionListenerReady = true
353379 for (event in pendingActionEvents) {
354380 pending.put(event.payload)
355381 }
382+ drainedCount = pendingActionEvents.size
356383 pendingActionEvents.clear()
357384 pendingActionEventKeys.clear()
358385 persistPendingActionEventsLocked()
359386 }
387+ Logger .debug(
388+ Logger .tags(" Notification" ),
389+ " Action listener marked ready; drained pending actionPerformed events=$drainedCount "
390+ )
360391 invoke.resolveObject(pending)
361392 }
362393
0 commit comments