Claudiu
Claudiu

Reputation: 47

how to insert a loading-bar on status-bar ionic

I want to show a loading bar on status bar for the upload of the images. Is it possible on ionic/cordova? I use file transfer for upload the images. And i tried to use local notification (https://github.com/Wizcorp/phonegap-plugin-localNotifications.) but i don't know how to insert the html in the notification and how to update it instead of send multiples notifications.I want something like this:enter image description here

Upvotes: 0

Views: 1209

Answers (1)

OClyde
OClyde

Reputation: 1076

The most popular Cordova plugin for local notifications is the following:

https://github.com/katzer/cordova-plugin-local-notifications

However, even this plugin hasn't got any progress notification support yet. Have searched for this feature as well, though there are two possibilities I found.

  1. FileTransfer plugin => update via onProgress

    The first one is to implement the upload using the Cordova FileTransfer plugin:

    https://github.com/apache/cordova-plugin-file-transfer

    While uploading, you might hook on the onProgress event callback and use the information to update your local notification. But for sure, this is a workaround and does not mirror the native Android approach of showing the progress in the local notification as intended.

  2. Speaking of "as intended", here's the link to the corresponding Android docs on this:

    https://developer.android.com/training/notify-user/display-progress.html

    During my research I also found this StackOverflow post. It does also make use of the Cordova FileTransfer plugin. The post describes how to alter this plugin to show a native notification showing the progress.

    I haven't had time to go through it completely, however it might be at least a starting point. But be aware: Altering a plugin means that you lose the ability to update it. Also you have to maintain the code added manually on your own and it might lose backwards compatibility in case of OS updates.

    Was thinking about creating a pull request, but as I said - haven't found the time yet unfortunately.

Hope this helps you to wrap your head around the topic. Often there's a solution out there in form of a Cordova plugin doing the job - in this case I guess it's unfortunately not (yet) the case. ;)

Upvotes: 1

Related Questions