I am losing my mind here... I tested my Flutter app that uses Firebase and everything is working perfectly fine. On every simulator, on a real device, in TestFlight. Everything is working.
BUT the apple reviewer keeps getting an error when trying to upload something to Firebase but the error
only says:
an unknown error occurred please check the server response
This is where the error
occurs:
Future<Memory?> addMemory({
required BuildContext context,
required String title,
required List<String> imageFilePaths,
required DateTime dateTime,
required String? story,
int? sortIndexIfEditing,
}) async {
try {
Year currentYear =
Provider.of<DataProvider>(context, listen: false).getCurrentYear();
Month currentMonth =
Provider.of<DataProvider>(context, listen: false).getCurrentMonth();
int currentMonthIndex = currentMonth.month;
String uid = AuthService.currentUser!.uid;
List<String> imageLocations = [];
for (String path in imageFilePaths) {
String uidForLocation = Uuid().v1();
String imageLocation =
'$uid/${currentYear.id}/${currentMonth.id}/$uidForLocation';
await FirebaseStorage.instance.ref(imageLocation).putFile(
File(path),
);
imageLocations.add(imageLocation);
}
Memory? memoryToReturn = await _addMemoryToDatabse(
context: context,
imageLocations: imageLocations,
currentYear: currentYear,
currentMonthIndex: currentMonthIndex,
title: title,
dateTime: dateTime,
story: story,
sortIndexIfEditing: sortIndexIfEditing,
);
return memoryToReturn;
} on FirebaseException catch (e) {
print('addMemory failed: ' + e.message.toString());
AlertService.showSnackBar(
title: 'Ups, hier ist etwas schiefgelaufen...',
description: e.message.toString(),
isSuccess: false,
);
return null;
}
}
It is not about Security Rules
, already checked that:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.auth != null;
}
}
}
What else can this error
mean? I wish I could provide you with more information, but that's all I got.
Let me know your email if you want access to TestFlight, so you can test it yourself.
as Frank suggested, this is a known issue with Firebase Storage.
This is another SO-Question about the same case:
Btw, my app just got accepted. I changed my Security Rules
to allow read, write: if true
which you SHOULD NOT do. After it got accepted I changed it back to a secure rule.
I don't know if there was an actual auth
issue, because my Firebase-Log
didn't show any rejections.