Displaying Progress in a Notification Bar


#1

I want to display progress in push notification like native android downloads works.
Is there any way to do it in Ionic?


#2

Can you show an example?
Do you know any other apps doing anything like that?


#3

I want to do something like this.


#4

Ok. But:

Only if you have an example we can start investigating.


#5

for example, in android while updating any app from playstore, we see downloading progress of the update in notification bar.
I want to do the same for my app while downloading any image, video and attachment file in ionic v1.


#6

Yes, but that is not a normal app but part of the OS. You need an example of an app doing something like this, then we can investigate how the app does it and see if we can do the same in Ionic.


#7

No, I don’t have such example so I was showing similar kind of example for it.
Is it possible in ionic for doing this.


#8

Ionic itself - no.
Ionic Apps via Cordova plugins - maybe. But only if other apps are able to do this too.


#9

Some more research into this:

Seems to be possible in Android in general: https://developer.android.com/training/notify-user/display-progress.html

But couldn’t find any Cordova plugin supporting the setProgress() on local notifications :confused:

Only thing I did find is this “hack” on an existing Cordova plugin: https://stackoverflow.com/a/31909537/252627


#10

So can you suggest any alternative thing for this in ionic.


#11

@nikhil7
Did you get any solution for this so far?


#12

This plugin should do the trick https://github.com/katzer/cordova-plugin-local-notifications


#13

@Daskus
Thank you for suggestion.
But if possible then can you show an example that how the download percentage will increase as download goes on?


#14

I think you just need to reschedule the notification:

for(int i=0; i<=10; i++){
   cordova.plugins.notification.local.schedule({
       title: 'Sync in progress',
       text: 'Copied ' + i + 'of 10 files',
       progressBar: { value: i*10 }
    });
}

#15

U can use css for a progress bar

Place a div on top using z-index and change the progress using width and a percentage

See line 5 in https://github.com/Tommertom/Newzee/blob/master/src/pages/homepage/homepage.html

The progress percentage variable should deliver a string ending with %

And if angular cant catch up with your progress changes u possibly need to wrap it in a zonej


#16

Thanks for the suggestion.