katzer / cordova-plugin-local-notifications

Cordova Local-Notification Plugin
Apache License 2.0
2.57k stars 1.75k forks source link

Ionic 2: need to display real time progress indicator in notification #1288

Closed umasdai closed 7 years ago

umasdai commented 7 years ago

Hi,

I'm new to ionic 2 and i'm using file transfer plugin https://ionicframework.com/docs/native/transfer/ to upload a file in my project. Whenever i'm uploading a file there will be percentage indicator showing the file upload progress. Do you guys have any idea how I want to replicate this in the notification?

Your Environment

Expected Behavior

I need the notification to keep updating whenever the progress percentage increases until the upload completed to 100%

Actual Behavior

I tried and it only take some of the number and displays only that only updates when the upload completes. It doesnt updates in real time with the progress.

Steps to Reproduce

onProgress = (progressEvent: ProgressEvent) : void => { this.ngZone.run(() => { if (progressEvent.lengthComputable) { let progress = Math.round((progressEvent.loaded / progressEvent.total) * 100); this.uploadNotification(progress); } }); }

public uploadFile() { this.onGoing(); this.fileTransfer.onProgress(this.onProgress); this.fileTransfer.upload(path, url,options).then((result) => { this.localNoti.completeNoti(); },(err) => {

}) }

onGoing(){

let notification = {
  id: 1,
  title: 'File Transfer App!',
  text: 'Upload Start',
  at: this.now,
};

this.localNotifications.schedule(notification);

}

uploadNotification(fileName){

let notification = {
  id: 1,
  title: 'File Transfer App!',
  text: 'Uploading: ' + fileName + '%'
};

this.localNotifications.update(notification);

}

completeNotification(){

let notification = {
  id: 1,
  title: 'File Transfer App!',
  text: 'Upload complete!',
};    
this.localNotifications.update(notification);

}

Context

The onProgress() function will keep updating the value when a file is being uploaded, so I want the value updates the respectively with the notifications showing the upload progress.

Debug logs

No debug logs

rwillett commented 7 years ago

AFAIK This can't be done using this plugin.

You are pushing what local notifications can do, so this is not a plugin issue per se.

rwillett commented 7 years ago

Ionic has things like spinners and stuff to try and provide this sort of feedback. I'd look at those.

umasdai commented 7 years ago

Thanks for the reply. I have been trying to create it but I only got for it to display one of the number it catches. I've tried using the ongoing hoping that the notification will stay there and keep updating the text but it doesnt. Maybe I will try to look at spinners stuff

umasdai commented 7 years ago

Also it seems by default the notification have a delay of 5 sec even when I didnt put a specific time.

rwillett commented 7 years ago

Thats Android for you. There is no guarantee of immediately delivery with the current plugin.

umasdai commented 7 years ago

Yeah, it seems that way. I'm just hoping somebody successfully tried something similar

rwillett commented 7 years ago

It has come up before.

We have issues with Ionic and loading indicators and gave up. They never worked for us.

umasdai commented 7 years ago

Really?? Well that's a bit disappointing. Still, I'll try to search for any other solution that might display a bit of the progress.

Thanks.