• Autentica a un usuario nuevo
  • Lee y escribe en tiempo real
  • Suscribe a un usuario a un tema de notificaciones
  • Registra un evento de Analytics personalizado
  • Guarda una imagen en Cloud Storage
Auth.auth().addStateDidChangeListener { (auth, user) in
  if let user = user {
    let email = user.email
    // ...
  }
}
Auth.auth().signIn(withEmail: userEmail, password: password) { (user, error) in
  if let user = user {
    // ...
  }
}
[[FIRAuth auth] addAuthStateDidChangeListener:^(FIRAuth * _Nonnull auth,
                                                FIRUser * _Nullable user) {
  if (user) {
    NSString *email = user.email;
    // ...
  }
}];
[[FIRAuth auth] signInWithEmail:email
                        password:password
                      completion:^(FIRUser * _Nullable user,
                                  NSError * _Nullable error) {
  if (error) {
    // ...
  }
}];
FirebaseAuth auth = FirebaseAuth.getInstance();
auth.signInWithEmailAndPassword(email, password)
    .addOnCompleteListener(new OnCompleteListener() {
        @Override
        public void onComplete(Task task) {
            if (task.isSuccessful()) {
                FirebaseUser user = task.getResult().getUser();
                String email = user.getEmail();
                // ...
            }
        }
    });
firebase.auth().onAuthStateChanged(function(user) {
    if (user) {
        // User is signed in
        var email = user.email;
        // ...
    } else {
        // User is not signed in
        // ...
    }
});
firebase.auth().signInWithEmailAndPassword(email, password);
firebase::auth::Auth* auth = firebase::auth::Auth::GetAuth(app);
firebase::Future result =
    auth->SignInWithEmailAndPasswordLastResult();

// ...
if (result.Status() == firebase::kFutureStatusComplete) {
  if (result.Error() == firebase::auth::kAuthErrorNone) {
    firebase::auth::User* user = *result.Result();
    printf("Sign in succeeded for email %s\n", user->Email().c_str());
    // ...
  }
}
Firebase.Auth.FirebaseAuth auth = Firebase.Auth.FirebaseAuth.DefaultInstance;
auth.SignInWithEmailAndPasswordAsync(email, password).ContinueWith(task => {
  if (!(Task.IsCancelled || Task.IsFaulted)) {
    Firebase.Auth.FirebaseUser newUser = task.Result;
    Debug.LogFormat("User signed in successfully: {0} ({1})",
        newUser.DisplayName, newUser.UserId);
  }
});
let ref = Database.database().reference()
// Write
ref.child("users/(userId)").setValue(user)
// Read / listen
ref.child("users").observe(.value) { snapshot in
  let dict = snapshot.value as? [String : AnyObject] ?? [:]
  // ...
}
FIRDatabaseReference *ref = [[FIRDatabase database] reference];
// write
[[[ref child:@"users"] child:userId] setValue:user];

// read / listen
[[ref child:@"users"] observeEventType:FIRDataEventTypeValue
                              withBlock:^(FIRDataSnapshot * _Nonnull snapshot) {
                                  NSDictionary *dict = snapshot.value;
                                  // ...
                              }];
FirebaseDatabase database = FirebaseDatabase.getInstance()
// write
database.child("users").child("userId").setValue(user);

// read / listen
database.child("users").addValueEventListener(new ValueEventListener() {
    @Override
    public void onDataChange(DataSnapshot dataSnapshot) {
        // ...
    }

    @Override
    public void onCancelled(DatabaseError databaseError) {}
});
var database = firebase.database();
// write
database.ref('users/' + userId).set(user);

// read / listen
database.child("users").on('value', function(snapshot) {
  // ...
});
firebase::database::Database* db = firebase::Database::GetInstance(app);
// write
db.GetReference("users").Child("userId").SetValue(user);

// read / listen
firebase::database::ValueListener* listener = new MyDatabaseValueListener();  // inherits from ValueListener
db.GetReference("users").AddValueListener(listener);
Firebase.Database.DatabaseReference database = FirebaseDatabase.DefaultInstance.RootReference;
// write
database.Child("users").Child(userId).Child("username").SetValueAsync(name);

// read / listen
database.GetReference("users").ValueChanged += HandleValueChanged;

void HandleValueChanged(object sender, ValueChangedEventArgs args) {
  if (args.DatabaseError == null) {
    // Do something with the data in args.Snapshot...
  }
}
Messaging.messaging().subscribe(toTopic: "/topics/news")
[[FIRMessaging messaging] subscribeToTopic:@"/topics/news"];
FirebaseMessaging.getInstance().subscribeToTopic("news");
firebase::messaging::Subscribe("news");
Firebase.Messaging.FirebaseMessaging.Subscribe("news");
Analytics.logEvent("share_image", parameters: ["id" : "image123"])
[FIRAnalytics logEventWithName:@"share_image"
                    parameters:@{@"id": "image123"}];
Bundle params = new Bundle();
params.putString("id", "image123");

FirebaseAnalytics.getInstance(this).logEvent("share_image", params);
const firebase::analytics::Parameter kParams[] = { firebase::analytics::Parameter("id", "image123") };
firebase::analytics::LogEvent("share_image", kParams, sizeof(kParams) / sizeof(kParams[0]));
Firebase.Analytics.FirebaseAnalytics.LogEvent("share_image", "id", "image123");
let storageRef = Storage.storage().reference()
let riversRef = storageRef.child("image/rivers.jpg")
let uploadTask = riversRef.putData(data, metadata: nil) { (metadata, error) in
  guard let metadata = metadata else { return }

  let downloadURL = metadata.downloadURL
  // ...
}
FIRStorage *storage = [FIRStorage storage];

FIRStorageReference *riversRef = [storageRef child:@"images/rivers.jpg"];
FIRStorageUploadTask *uploadTask = [riversRef putData:data
                                              metadata:nil
                                            completion:^(FIRStorageMetadata *metadata,
                                                        NSError *error) {
  if (error != nil) {
    // ...
  } else {
    NSURL *downloadURL = metadata.downloadURL;
    // ...
  }
}];
FirebaseStorage storage = FirebaseStorage.getInstance();

storage.child("images/rivers.jpg").putBytes(data)
    .addOnFailureListener(new OnFailureListener() {
        @Override
        public void onFailure(@NonNull Exception exception) {
            // ...
        }
    }).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
        @Override
        public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
            Uri downloadUrl = taskSnapshot.getDownloadUrl();
            // ...
        }
    });
var storageRef = firebase.storage().ref();

storageRef.child("images/rivers.jpg").put(data).then(function(snapshot) {
  // ...
});
firebase::storage::Storage* storage = firebase::storage::Storage::GetInstance(app);
firebase::storage::StorageReference ref = storage.GetReference("images/rivers.jpg");
firebase::Future result = ref.PutBytes(data, data_size, nullptr, nullptr);
// ...
if (result.Status() == firebase::kFutureStatusComplete) {
  if (result.Error() == firebase::storage::kErrorNone) {
    const char* url = result.Result()->download_url();
    // ...
  }
}
Firebase.Storage.StorageReference rivers_ref = storage.Reference().Child("images/rivers.jpg");
rivers_ref.PutBytesAsync(custom_bytes).ContinueWith(task => {
  if (!(Task.IsCancelled || Task.IsFaulted)) {
    // Metadata contains file metadata such as size, content-type, and download URL.
    Firebase.Storage.Metadata metadata = task.Result;
    // ...
  }
});