I'm trying to upload a video file to Firebase but app crashes without any logs. There are no logs, the app just crashes.
const id = uuid.v4();
const path = `videos/${user.uid}/${id}`;
try {
const fileRef = ref(storage, path);
const blob = await new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest();
xhr.onload = function() {
resolve(xhr.response);
};
xhr.onerror = function(e) {
console.log(e);
reject(new TypeError('Network request failed'));
};
xhr.responseType = 'blob';
xhr.open('GET', uri, true);
xhr.send(null);
});
const uploadTask = uploadBytesResumable(fileRef, blob);
uploadTask.on(
'state_changed',
(snapshot) => {
const prog = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
callback(prog);
},
(error) => {
errorCallback(error);
},
() => {
getDownloadURL(uploadTask.snapshot.ref).then((downloadURL) => {
console.warn('Complete', downloadURL);
});
},
);
} catch (error) {
console.log(error);
}
The same code works fine on Android phones but crashes on iOS.