Skip to content

Firestore completion handler not called for setData #2167

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dbarrett0815 opened this issue Dec 10, 2018 · 11 comments
Closed

Firestore completion handler not called for setData #2167

dbarrett0815 opened this issue Dec 10, 2018 · 11 comments

Comments

@dbarrett0815
Copy link

dbarrett0815 commented Dec 10, 2018

[READ] Step 1: Are you in the right place?

Yes

[REQUIRED] Step 2: Describe your environment

  • Xcode version: 10.1
  • Firebase SDK version: 5.14.0
  • Firebase Component: Firestore
  • Component version: 5.14.0

[REQUIRED] Step 3: Describe the problem

Setting data to firestore using the setData method does not execute closure. Reading from the database works but cannot add new data to the database. I have followed the installation instructions for carthage step by step. The only discrepancy is that the when copying the bundle resources for firestore I copied the gRPCCertificates-Firestore.bundle file from the /Carthage/Build/iOS/FirebaseFirestore.framework/ folder but the readme says to copy gRPCCertificates.bundle(which was not in that folder). I've tried both on a simulator and a real device and have tried different network connections. Database rules allow writes

Steps to reproduce:

Relevant Code:

//This code works and the completion handler gets called
Firestore.firestore().collection("Ticket").getDocuments { (querysnapshot, error) in
            for document in querysnapshot!.documents {
                print(document.data())
            }
        }

///This code does not work, completion handler never gets called
Firestore.firestore().collection("Ticket").document().setData(["myData":` "data"]) { (error) in
            if error != nil {
                print(error!.localizedDescription)
            } else {
                print("data was written")
            }
        }
@wilhuff
Copy link
Contributor

wilhuff commented Dec 10, 2018

Could you enable logging and post what you see in the logs? I can't think of any way that reads would work but writes don't work that's related to certificate setup--the connection should be all or nothing.

One thing to be careful of: are you sure getDocuments is actually hitting the server? The client will happily operate offline, reading back data it has written locally. The completion handler for setData is only called once the write has completed on the server but if you're completely disconnected that write will still be visible to local getDocuments calls. If this is the case the connection isn't working at all.

@wilhuff
Copy link
Contributor

wilhuff commented Dec 10, 2018

We've updated the Carthage instructions in #2171.

@var-const
Copy link
Contributor

An assertion will fail if the certificates bundle cannot be loaded, triggering a crash, so it's unlikely that this issue is related to certificates.

@dbarrett0815
Copy link
Author

dbarrett0815 commented Dec 10, 2018

Here is a debug log of the successful getDocuments and a failed setData ran on a real device

18-12-10 13:30:26.850978-0500 MobileValet[478:68157]  - <AppMeasurement>[I-ACS036002] Analytics screen reporting is enabled. Call +[FIRAnalytics setScreenName:setScreenClass:] to set the screen name or override the default screen class name. To disable screen reporting, set the flag FirebaseScreenReportingEnabled to NO (boolean) in the Info.plist
2018-12-10 13:30:26.983972-0500 MobileValet[478:68157] 5.14.0 - [Firebase/Analytics][I-ACS023007] Analytics v.50400000 started
2018-12-10 13:30:26.984036-0500 MobileValet[478:68157] 5.14.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://goo.gl/RfcP7r)
2018-12-10 13:30:26.991075-0500 MobileValet[478:68073] [NetworkInfo] Signal strength query returned error: Error Domain=NSPOSIXErrorDomain Code=13 "Permission denied", descriptor: <CTServiceDescriptor 0x28281fcc0, domain=1, instance=1>
2018-12-10 13:30:27.011018-0500 MobileValet[478:68168] 5.14.0 - [Firebase/Crash][I-CRA000004] Successfully initialized
2018-12-10 13:30:27.044293-0500 MobileValet[478:68168] 5.14.0 - [Firebase/Firestore][I-FST000001] Initializing. Current user:
2018-12-10 13:30:27.050000-0500 MobileValet[478:68168] 5.14.0 - [Firebase/Firestore][I-FST000001] Committing transaction: <LevelDbTransaction Start LevelDB: 0 changes (0 bytes):>
2018-12-10 13:30:27.081962-0500 MobileValet[478:68168] 5.14.0 - [Firebase/Firestore][I-FST000001] Committing transaction: <LevelDbTransaction Start MutationQueue: 0 changes (0 bytes):>
2018-12-10 13:30:27.083077-0500 MobileValet[478:68168] 5.14.0 - [Firebase/Firestore][I-FST000001] Committing transaction: <LevelDbTransaction NextMutationBatchAfterBatchID: 0 changes (0 bytes):>
2018-12-10 13:30:27.083640-0500 MobileValet[478:68168] 5.14.0 - [Firebase/Firestore][I-FST000001] Committing transaction: <LevelDbTransaction NextMutationBatchAfterBatchID: 0 changes (0 bytes):>
2018-12-10 13:30:27.083985-0500 MobileValet[478:68168] 5.14.0 - [Firebase/Firestore][I-FST000001] Committing transaction: <LevelDbTransaction NextMutationBatchAfterBatchID: 0 changes (0 bytes):>
2018-12-10 13:30:27.084236-0500 MobileValet[478:68168] 5.14.0 - [Firebase/Firestore][I-FST000001] Committing transaction: <LevelDbTransaction NextMutationBatchAfterBatchID: 0 changes (0 bytes):>
2018-12-10 13:30:27.084569-0500 MobileValet[478:68168] 5.14.0 - [Firebase/Firestore][I-FST000001] Committing transaction: <LevelDbTransaction NextMutationBatchAfterBatchID: 0 changes (0 bytes):>
2018-12-10 13:30:27.084832-0500 MobileValet[478:68168] 5.14.0 - [Firebase/Firestore][I-FST000001] Committing transaction: <LevelDbTransaction NextMutationBatchAfterBatchID: 0 changes (0 bytes):>
2018-12-10 13:30:27.085070-0500 MobileValet[478:68168] 5.14.0 - [Firebase/Firestore][I-FST000001] Committing transaction: <LevelDbTransaction NextMutationBatchAfterBatchID: 0 changes (0 bytes):>
2018-12-10 13:30:27.085393-0500 MobileValet[478:68168] 5.14.0 - [Firebase/Firestore][I-FST000001] Committing transaction: <LevelDbTransaction NextMutationBatchAfterBatchID: 0 changes (0 bytes):>
2018-12-10 13:30:27.085702-0500 MobileValet[478:68170] 5.14.0 - [Firebase/Firestore][I-FST000001] Committing transaction: <LevelDbTransaction NextMutationBatchAfterBatchID: 0 changes (0 bytes):>
2018-12-10 13:30:27.085930-0500 MobileValet[478:68170] 5.14.0 - [Firebase/Firestore][I-FST000001] Committing transaction: <LevelDbTransaction NextMutationBatchAfterBatchID: 0 changes (0 bytes):>
2018-12-10 13:30:27.085968-0500 MobileValet[478:68170] 5.14.0 - [Firebase/Firestore][I-FST000001] WriteStream (11dd169d8) start
2018-12-10 13:30:27.086080-0500 MobileValet[478:68168] 5.14.0 - [Firebase/Auth][I-AUT000002] Token auto-refresh enabled.
2018-12-10 13:30:27.086348-0500 MobileValet[478:68168] 5.14.0 - [Firebase/Auth][I-AUT000004] Token auto-refresh scheduled in 48:34 for the new token.
2018-12-10 13:30:27.087083-0500 MobileValet[478:68170] 5.14.0 - [Firebase/Firestore][I-FST000001] Committing transaction: <LevelDbTransaction Allocate query: 0 changes (0 bytes):>
2018-12-10 13:30:27.087606-0500 MobileValet[478:68170] 5.14.0 - [Firebase/Firestore][I-FST000001] Committing transaction: <LevelDbTransaction ExecuteQuery: 0 changes (0 bytes):>
2018-12-10 13:30:27.087642-0500 MobileValet[478:68170] 5.14.0 - [Firebase/Firestore][I-FST000001] Committing transaction: <LevelDbTransaction RemoteDocumentKeysForTarget: 0 changes (0 bytes):>
2018-12-10 13:30:27.088230-0500 MobileValet[478:68170] 5.14.0 - [Firebase/Firestore][I-FST000001] WatchStream (281433a18) start
2018-12-10 13:30:27.088822-0500 MobileValet[478:68170] 5.14.0 - [Firebase/Firestore][I-FST000001] Committing transaction: <LevelDbTransaction Locally write mutations: 2 changes (123 bytes):
  - Put [document_mutation: user_id= key=Ticket/SNCBQ3zhvIqpdl2xQEsl batch_id=32] (0 bytes)
  - Put [mutation: user_id= batch_id=32] (123 bytes)>
2018-12-10 13:30:27.088912-0500 MobileValet[478:68170] 5.14.0 - [Firebase/Firestore][I-FST000001] Committing transaction: <LevelDbTransaction NotifyLocalViewChanges: 0 changes (0 bytes):>
2018-12-10 13:30:27.091609-0500 MobileValet[478:68165] 5.14.0 - [Firebase/Analytics][I-ACS029014] Successfully parsed a configuration. Version: 1544206063193539
2018-12-10 13:30:27.092035-0500 MobileValet[478:68170] 5.14.0 - [Firebase/Analytics][I-ACS023016] Analytics is ready to receive events
2018-12-10 13:30:27.092970-0500 MobileValet[478:68165] 5.14.0 - [Firebase/Analytics][I-ACS031010] Tracking view controller. Class, ID: HomeViewController, 5019870669691843386
2018-12-10 13:30:27.093017-0500 MobileValet[478:68165] 5.14.0 - [Firebase/Analytics][I-ACS031013] Screen view event not logged. App is not active.
2018-12-10 13:30:27.093578-0500 MobileValet[478:68165] 5.14.0 - [Firebase/Analytics][I-ACS031006] View controller already tracked. Class, ID: HomeViewController, 5019870669691843386
2018-12-10 13:30:27.093697-0500 MobileValet[478:68165] 5.14.0 - [Firebase/Analytics][I-ACS031006] View controller already tracked. Class, ID: HomeViewController, 5019870669691843386
2018-12-10 13:30:27.093994-0500 MobileValet[478:68165] 5.14.0 - [GoogleUtilities/AppDelegateSwizzler][I-SWZ001008] Successfully created App Delegate Proxy automatically. To disable the proxy, set the flag GoogleUtilitiesAppDelegateProxyEnabled to NO (Boolean) in the Info.plist
2018-12-10 13:30:27.094675-0500 MobileValet[478:68170] 5.14.0 - [Firebase/Firestore][I-FST000001] Credential Changed. Current user: QVIPtCHBtdaVg0nL4nJH046b5zD2
2018-12-10 13:30:27.094792-0500 MobileValet[478:68170] 5.14.0 - [GULReachability][I-REA902004] Network status has changed. Code:2, status:Connected
2018-12-10 13:30:27.096220-0500 MobileValet[478:68168] 5.14.0 - [Firebase/Analytics][I-ACS023080] Setting user property. Name, value: _fi, 1
2018-12-10 13:30:27.098010-0500 MobileValet[478:68168] 5.14.0 - [Firebase/Analytics][I-ACS033003] Scheduling user engagement timer
2018-12-10 13:30:27.098192-0500 MobileValet[478:68168] 5.14.0 - [Firebase/Analytics][I-ACS002002] Engagement timer scheduled to fire in approx. (s): 3600
2018-12-10 13:30:27.098929-0500 MobileValet[478:68170] 5.14.0 - [Firebase/Analytics][I-ACS023087] User property set. Name, value: _fi, 1
2018-12-10 13:30:27.101007-0500 MobileValet[478:68170] 5.14.0 - [Firebase/Firestore][I-FST000001] Committing transaction: <LevelDbTransaction OldBatches: 0 changes (0 bytes):>
2018-12-10 13:30:27.101151-0500 MobileValet[478:68170] 5.14.0 - [Firebase/Firestore][I-FST000001] Committing transaction: <LevelDbTransaction Start MutationQueue: 0 changes (0 bytes):>
2018-12-10 13:30:27.102077-0500 MobileValet[478:68170] 5.14.0 - [Firebase/Firestore][I-FST000001] Committing transaction: <LevelDbTransaction NewBatches: 0 changes (0 bytes):>
2018-12-10 13:30:27.102215-0500 MobileValet[478:68170] 5.14.0 - [Firebase/Firestore][I-FST000001] Committing transaction: <LevelDbTransaction NotifyLocalViewChanges: 3 changes (3 bytes):
  - Put [document_target: key=Ticket/SNCBQ3zhvIqpdl2xQEsl target_id=0] (1 bytes)
  - Put [document_target: key=Ticket/YiZspL1fw489kfDRaJYz target_id=0] (1 bytes)
  - Put [document_target: key=Ticket/hisrepsYwBuvgbArNdy5 target_id=0] (1 bytes)>
2018-12-10 13:30:27.102305-0500 MobileValet[478:68170] 5.14.0 - [Firebase/Firestore][I-FST000001] FSTRemoteStore 28033c1c0 restarting streams for new credential
2018-12-10 13:30:27.102709-0500 MobileValet[478:68170] 5.14.0 - [Firebase/Firestore][I-FST000001] WatchStream (281433a18) stop
2018-12-10 13:30:27.102742-0500 MobileValet[478:68170] 5.14.0 - [Firebase/Firestore][I-FST000001] WriteStream (11dd169d8) stop
2018-12-10 13:30:27.102767-0500 MobileValet[478:68170] 5.14.0 - [Firebase/Firestore][I-FST000001] Stopping write stream with <invalid>u pending writes
2018-12-10 13:30:27.102792-0500 MobileValet[478:68170] 5.14.0 - [Firebase/Firestore][I-FST000001] WatchStream (281433a18) start
2018-12-10 13:30:27.102828-0500 MobileValet[478:68170] 5.14.0 - [Firebase/Firestore][I-FST000001] Committing transaction: <LevelDbTransaction NextMutationBatchAfterBatchID: 0 changes (0 bytes):>
2018-12-10 13:30:27.103040-0500 MobileValet[478:68170] 5.14.0 - [Firebase/Firestore][I-FST000001] Creating Firestore stub.
2018-12-10 13:30:27.211499-0500 MobileValet[478:68170] 5.14.0 - [Firebase/Analytics][I-ACS032003] iAd framework is not linked. Search Ad Attribution Reporter is disabled.
2018-12-10 13:30:27.211930-0500 MobileValet[478:68170] 5.14.0 - [Firebase/Analytics][I-ACS023024] No data to upload. Upload task will not be scheduled
2018-12-10 13:30:27.212523-0500 MobileValet[478:68162] 5.14.0 - [Firebase/Analytics][I-ACS023012] Analytics enabled
2018-12-10 13:30:27.213308-0500 MobileValet[478:68162] 5.14.0 - [Firebase/Analytics][I-ACS023051] Logging event: origin, name, params: auto, _vs, {
    "_o" = auto;
    "_sc" = HomeViewController;
    "_si" = 5019870669691843386;
}
2018-12-10 13:30:27.331845-0500 MobileValet[478:68162] 5.14.0 - [Firebase/Firestore][I-FST000001] Using roots.pem file from Firestore pod
2018-12-10 13:30:27.335808-0500 MobileValet[478:68162] 5.14.0 - [Firebase/Firestore][I-FST000001] WatchStream (281433a18) watch: <GCFSListenRequest 0x28030d960>: {
    database: "projects/prestige-parking/databases/(default)"
    add_target {
      query {
        parent: "projects/prestige-parking/databases/(default)"
        structured_query {
          from {
            collection_id: "Ticket"
          }
          order_by {
            field {
              field_path: "__name__"
            }
            direction: ASCENDING
          }
        }
      }
      resume_token: "\n\t\010\364\207\237\215\361\225\337\002"
      target_id: 2
    }
}
2018-12-10 13:30:27.531846-0500 MobileValet[478:68165] 5.14.0 - [Firebase/InstanceID][I-IID009000] Cannot retrieve keypair with tag com.google.iid-|K|
2018-12-10 13:30:27.562012-0500 MobileValet[478:68165] 5.14.0 - [Firebase/Analytics][I-ACS023072] Event logged. Event name, event params: _vs, {
    "_o" = auto;
    "_sc" = HomeViewController;
    "_si" = 5019870669691843386;
}
2018-12-10 13:30:27.569017-0500 MobileValet[478:68157] 5.14.0 - [Firebase/Analytics][I-ACS002002] Measurement timer scheduled to fire in approx. (s): 3227.529773116112
2018-12-10 13:30:27.569144-0500 MobileValet[478:68157] 5.14.0 - [Firebase/Analytics][I-ACS023028] Upload task scheduled to be executed in approx. (s): 3227.529773116112
2018-12-10 13:30:27.637829-0500 MobileValet[478:68162] 5.14.0 - [Firebase/Firestore][I-FST000001] WatchStream (281433a18) headers (whitelisted): date: Mon, 10 Dec 2018 18:30:27 GMT
2018-12-10 13:30:27.638979-0500 MobileValet[478:68162] 5.14.0 - [Firebase/Firestore][I-FST000001] WatchStream (281433a18) response: <GCFSListenResponse 0x280628500>: {
    target_change {
      target_change_type: ADD
      target_ids: 2
    }
}
2018-12-10 13:30:27.639723-0500 MobileValet[478:68162] 5.14.0 - [Firebase/Firestore][I-FST000001] WatchStream (281433a18) headers (whitelisted): date: Mon, 10 Dec 2018 18:30:27 GMT
2018-12-10 13:30:27.639879-0500 MobileValet[478:68162] 5.14.0 - [Firebase/Firestore][I-FST000001] WatchStream (281433a18) response: <GCFSListenResponse 0x280629080>: {
    target_change {
      resume_token: "\n\t\010\364\207\237\215\361\225\337\002"
      read_time {
        seconds: 1544466240
        nanos: 881652000
      }
    }
}
2018-12-10 13:30:27.641082-0500 MobileValet[478:68157] 5.14.0 - [Firebase/Firestore][I-FST000001] Committing transaction: <LevelDbTransaction Apply remote event: 1 changes (20 bytes):
  - Put [target_global:] (20 bytes)>
2018-12-10 13:30:27.641174-0500 MobileValet[478:68157] 5.14.0 - [Firebase/Firestore][I-FST000001] Committing transaction: <LevelDbTransaction NotifyLocalViewChanges: 0 changes (0 bytes):>
2018-12-10 13:30:27.693171-0500 MobileValet[478:68157] 5.14.0 - [Firebase/Firestore][I-FST000001] WatchStream (281433a18) headers (whitelisted): date: Mon, 10 Dec 2018 18:30:27 GMT
2018-12-10 13:30:27.694171-0500 MobileValet[478:68157] 5.14.0 - [Firebase/Firestore][I-FST000001] WatchStream (281433a18) response: <GCFSListenResponse 0x280629080>: {
    filter {
      target_id: 2
      count: 2
    }
}
2018-12-10 13:30:27.694345-0500 MobileValet[478:68157] 5.14.0 - [Firebase/Firestore][I-FST000001] WatchStream (281433a18) headers (whitelisted): date: Mon, 10 Dec 2018 18:30:27 GMT
2018-12-10 13:30:27.696367-0500 MobileValet[478:68157] 5.14.0 - [Firebase/Firestore][I-FST000001] WatchStream (281433a18) response: <GCFSListenResponse 0x280629500>: {
    target_change {
      target_change_type: CURRENT
      target_ids: 2
      resume_token: "\n\t\010\346\215\323\305\362\225\337\002"
      read_time {
        seconds: 1544466627
        nanos: 610342000
      }
    }
}
2018-12-10 13:30:27.696498-0500 MobileValet[478:68157] 5.14.0 - [Firebase/Firestore][I-FST000001] WatchStream (281433a18) headers (whitelisted): date: Mon, 10 Dec 2018 18:30:27 GMT
2018-12-10 13:30:27.696621-0500 MobileValet[478:68157] 5.14.0 - [Firebase/Firestore][I-FST000001] WatchStream (281433a18) response: <GCFSListenResponse 0x280629580>: {
    target_change {
      resume_token: "\n\t\010\346\215\323\305\362\225\337\002"
      read_time {
        seconds: 1544466627
        nanos: 610342000
      }
    }
}
2018-12-10 13:30:27.697787-0500 MobileValet[478:68157] 5.14.0 - [Firebase/Firestore][I-FST000001] Committing transaction: <LevelDbTransaction Apply remote event: 2 changes (128 bytes):
  - Put [target: target_id=2] (108 bytes)
  - Put [target_global:] (20 bytes)>
2018-12-10 13:30:27.698095-0500 MobileValet[478:68157] 5.14.0 - [Firebase/Firestore][I-FST000001] Committing transaction: <LevelDbTransaction NotifyLocalViewChanges: 0 changes (0 bytes):>
2018-12-10 13:30:27.699566-0500 MobileValet[478:68157] 5.14.0 - [Firebase/Firestore][I-FST000001] Committing transaction: <LevelDbTransaction Release query: 2 changes (128 bytes):
  - Put [target: target_id=2] (108 bytes)
  - Put [target_global:] (20 bytes)>
2018-12-10 13:30:27.699912-0500 MobileValet[478:68157] 5.14.0 - [Firebase/Firestore][I-FST000001] WatchStream (281433a18) unwatch: <GCFSListenRequest 0x28032c0e0>: {
    database: "projects/prestige-parking/databases/(default)"
    remove_target: 2
}
["dateClosed": FIRTimestamp: seconds=1544438400 nanoseconds=0>, "firstName": Moo, "rate": 5, "carLocation": B4, "dateIssued": FIRTimestamp: seconds=1544434800 nanoseconds=0>, "phoneNumber": 123456789, "status": Parked, "lastName": Moose]
["myData": data]
2018-12-10 13:30:27.737471-0500 MobileValet[478:68165] 5.14.0 - [Firebase/Firestore][I-FST000001] WatchStream (281433a18) headers (whitelisted): date: Mon, 10 Dec 2018 18:30:27 GMT
2018-12-10 13:30:27.737813-0500 MobileValet[478:68165] 5.14.0 - [Firebase/Firestore][I-FST000001] WatchStream (281433a18) response: <GCFSListenResponse 0x280629300>: {
    target_change {
      target_change_type: REMOVE
      target_ids: 2
    }
}

@dbarrett0815
Copy link
Author

@wilhuff The read with getDocuments() appears to be hitting the database. Whenever I make a change in the firestore its able to pull those changes in. And if the client was offline shouldnt it read all those docuements that I have attempted to write but failed? It doesnt pick up on those local writen docuemnts on a read only whats in the actual firestore database.

@mikelehen
Copy link
Contributor

@dbarrett0815 Thanks for the logs! Very helpful.

It looks like what's happening is that your write is being queued before you're authenticated to Firebase Authentication and so it's an "unauthenticated" write. And then you authenticate as some user before we get a chance to send the write to the backend, and so we do not send it, because now you're authenticated as a different user.

Basically, Firestore keeps a separate write queue per user (aka separate Firebase Authentication UID) and because you can only be authenticated as one user at a time, Firestore only sends writes to the backend for the user you are currently authenticated as. That way the writes aren't incorrectly rejected or accepted due to security rules being applied for a different user. We treat unauthenticated writes as a separate user as well, so they fall into the same category. Once you're authenticated, we don't send them (unless you sign out again).

We have an open issue to try to improve this situation somewhat. For instance, in the case of unauthenticated writes, we could spin up a separate unauthenticated stream to the backend and continue sending your unauthenticated writes in the background, even when you are logged in as somebody new. Unfortunately this doesn't generalize to authenticated users, since we can only get authentication tokens for the currently-signed-in user. So it's not a full solution, but it looks like it might solve your case.

In your situation, you may be able to workaround the issue by either:

  1. Avoiding doing writes until you've successfully signed-in to Firebase Authentication, or
    2 Avoiding signing in to Firebase Authentication until all previously-queued writes have completed successfully.

Does this help?

@dbarrett0815
Copy link
Author

@mikelehen That seems like that was the issue! I was bypassing the login for testing purposes but when I logged in it worked. Thank you

@JoakoDr
Copy link

JoakoDr commented May 30, 2019

Same problem, how do you solve it?

@wilhuff
Copy link
Contributor

wilhuff commented May 30, 2019

@JoakoDr If this really is the same problem, then the advice from @mikelehen above is:

  1. Avoiding doing writes until you've successfully signed-in to Firebase Authentication, or
  2. Avoiding signing in to Firebase Authentication until all previously-queued writes have completed successfully.

However, the way we diagnosed this was specifically this problem was by looking at the logs. If those suggestions don't help (or you're not using Firebase Auth) then please create a new issue describing in detail what you're doing. Ideally share relevant code snippets and the output of logs to help us help you track this down.

@JoakoDr
Copy link

JoakoDr commented May 30, 2019

i've successfully signed-in to Firebase, get the user email and the user uid, and then do the setData(), but it doesnt work:

func registrarse(user: String, password:String ,delegate: DataHolderDelegate){
// var blFinRegistro:Bool = false

        Auth.auth().createUser(withEmail:user, password:password){ (user, error) in
                if (error == nil) {
				//successfully register
                    FirebaseApiManager.sharedInstance.firUser = AuthResult.user
                    print("Te Registraste !")
					
					
				//PROBLEM IS HERE, .SETDATA() DOESN'T WORK
					FirebaseApiManager.sharedInstance.firestoreDB?.collection("perfiles").document((FirebaseApiManager.sharedInstance.firUser?.uid)!).setData(FirebaseApiManager.sharedInstance.miPerfil.getMap()) { err in
					if let err = err {
							print("Error adding document: \(err)")
									} else {
											print("Document added with ID:")
																				}
																					}
                    delegate.DHDregistro!(blFinRegistro: true)
                }else
                {
                    print(error!)
                    
                }
        
    }
    
}

Looking for some help, Thanks.

@JoakoDr
Copy link

JoakoDr commented May 30, 2019

Solved. Thanks to @albertogurpegui

@firebase firebase locked and limited conversation to collaborators Oct 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants