In the "Offline Capabilities" section of the iOS guide it mentions kFirebaseServerValueTimestamp
, which doesn't seem to work in a Swift project (auto complete doesn't prompt it).
I tried [".sv": "timestamp"]
as the Swift example did. But it complains that this can not be set with other values and has to be the only value for at the given path.
I tried:
ref.childByAutoId().setValue(["text": "foobar", ".sv": "timestamp"], withCompletionBlock: {...}
And it gave me the error that ".sv" can't be saved with other value.
What I wanted to do is to save the createdAt timestamp along with other values for the object. And I'd prefer to use the server time to avoid client clock skew.
How can I do that?
Add the
".sv":"timestamp"
between brackets[ ]
when you add it to yourFirebase
entry.eg:
Code screenshot
It should be written to your Firebase as:
Firebase screenshot