I am using firebase in an iOS-Swift project in which I have to enable offline support for uploading posts, in the post there is a picture and caption just like Instagram, so what I want is when user is offline and he/she wants to upload a post, his/her picture get saved in cache and when user comes online that photo get uploaded and give back a download url that we can use for saving posts-details it in database.
sample code is:
                let photoIDString = UUID().uuidString
                let storageRef = Storage.storage().reference(forURL: "storage ref URL").child("posts").child(photoIDString)
                storageRef.putData(imageData, metadata: nil, completion: { (metadata, error) in
                guard let metadata = metadata else {
                    return
                }
                if error != nil {
                    return
                }
                storageRef.downloadURL(completion: { ( url, error ) in
                    guard let downloadURL = url else {
                        return
                    }
                    let photoUrl = downloadURL.absoluteString
                    self.sendDataToDatabase(photoUrl: photoUrl)
                    })
                }
                )
I want to know what changes should I make in my code to provide the offline capability. Any code snippet will help more.
 
     
     
     
    