2
votes

I am building an iOS app using Firebase as the backend. Firebase has "observeStatus(.Progress)" code that is used for image storage.

I have 2 questions:

  1. I will let users upload pictures which will be held in Firebase Storage, once a user decides to submit a picture, do they need to see a progress status bar indicator/progress status alert screen showing the image upload status?

  2. If not, what is the purpose of the observe Status code below if there's no need to display a progress indicator to the user?

Code:

let storageRef = FIRStorage.reference().child("folderName/file.jpg");
let localFile: NSURL = // get a file;

// Upload the file to the path "folderName/file.jpg"
let uploadTask = storageRef.putFile(localFile, metadata: nil)

let observer = uploadTask.observeStatus(.Progress) { snapshot in
  print(snapshot.progress) // NSProgress object
}
1
How would we track the progress if the functionality to upload the file is defined in a different controller rather than in the UI component? Should we use some global observers here?Nazar Medeiros
Sounds like you should use a delegation patternLance Samaria
Oh yes, you are right :) Thanks Frank van PuffelenNazar Medeiros

1 Answers

2
votes

Whether your users should be shown a progress bar is really up to you and the needs of your app.

If the user can continue using the app while the file is uploading, then probably the most you'll need is a completion listener to show them when it's done.

But if you're blocking the user from using the app while the file is uploading, it is very important to show them the progress. That way they'll have some idea of how much longer the operation will take.