Search code examples
nativescriptnativescript-background-http

How to clear upload notification after upload is completed in nativescript


I'm using nativescript plugin nativescript-background-http to upload files in background.

Writing only for Android. Plugin works fine. Plugin displays upload progress in the notification, as required in API26+. When upload is completed (success or error), the notification remains in the drawer until dismissed by the user.

I'm looking for a way to clear the upload notification automatically after success or error.

Has anyone done this before? Guidance on how to access the underlying notification manager that the plugin uses would also be helpful as well.

Notes:

  1. I can't hide the notification completely using androidDisplayNotificationProgress = false option of the plugin, as since API26, Android requires developers to use notifications when running background tasks.
  2. I've searched this question, but couldn't find information about dismissing notifications of the plugin.

Thanks


Solution

  • Set androidAutoClearNotification to true.

    (Android only) Used to set if notifications should be cleared automatically upon upload completion. Default is false. Please note that setting this to true will also disable the ringtones.