Thursday, January 11, 2024
HomeiOS Developmentios - Unable to make use of firestore in a flutter challenge...

ios – Unable to make use of firestore in a flutter challenge in dart facet and swift facet on the identical time


I’ve a challenge finished with flutter and i’m utilizing firebase for firestore database.
I would like to make use of it in dart facet like swift facet as properly.

however when i run my app and I begin utilizing it I get an error and the app get crashed.

that is the error :

Terminating app resulting from uncaught exception ‘FIRIllegalStateException’, motive: ‘Firestore occasion has already been began and its settings can not be modified. You may solely set settings earlier than calling some other strategies on a Firestore occasion.
terminating resulting from uncaught exception of sort NSException

I actually perceive the explanation trigger it’s actually clear , however I’m unable to establish the place is the app attempting to start out and set new settings.

I initialized the firebase app on dart facet on my primary.dart file contained in the initApp methodology like this:

.....
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
......

and the app doesn’t get crashed once I open it, it crashs specifically on a selected a part of the code on dart facet(I’ve to seek out it manually trigger even the all exceptions checked in android studio was not capable of finding it) once I take away the code I’ve that sends knowledge to firebase database it really works high quality, that is the code :

.....
DocumentReference<Map<String, dynamic>> documentParent = FirebaseFirestore
    .occasion
    .assortment('errors_backend')
    .doc(userId == null || userId.isEmpty
        ? DateTime.now().toIso8601String()
        : userId);
.....

now on swift facet i truly dont have a lot code about firebase, i’ve a file known as LocationManager that’s an extension of AppDelegate and inside this i’ve a way that known as each time the situation replace:

....
import FirebaseFirestore
import Firebase

enum MyError: Error {
case userIDNotFound
}

extension AppDelegate: CLLocationManagerDelegate {
 ......
 ....
 func sendDataToFirebase(knowledge: [String: String] ) throws {
        let db = Firestore.firestore()
        ......
  }

and that it’s on swift facet i dont have extra code about firebase and you may see each time the strategy known as i name the firestore methodology.

now like dart facet , if i depart the code that’s on dart facet and that i dont name the strategy that ship knowledge to firebase on swift facet , the app works high quality (however obviusly the app wouldn’t ship knowledge to firebase database).

so now i’m not certain what to do.

on my Podfile i’ve added this:

pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk- 
frameworks.git', :tag => '10.16.0'

i’ve tried wrapping the code in a try-catch on each facet swift and dart however the app continues to be getting the crash.

i hope a few of you guys might help me.
thanks a lot.



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments