// Sign in Anonymously void SignInAnonymouslyCompleted(AuthDataResult authDataResult, NSError error) { if (error == null) { AppDelegate.UserUid = authDataResult.User.Uid; // Points to https://MyDatabaseId.firebaseio.com/users userNode = AppDelegate.RootNode.GetChild("users").GetChild(AppDelegate.UserUid); VerifyIfUserExists(); } else { AuthErrorCode errorCode; if (IntPtr.Size == 8) // 64 bits devices { errorCode = (AuthErrorCode)((long)error.Code); } else // 32 bits devices { errorCode = (AuthErrorCode)((int)error.Code); } var title = "Anonymous sign-in failed!"; // Posible error codes that SignInAnonymously method could throw // Visit https://firebase.google.com/docs/auth/ios/errors for more information switch (errorCode) { case AuthErrorCode.OperationNotAllowed: UIAlertHelper.ShowMessage(title, "The app uses Anonymous sign-in to work correctly and seems to be disabled…\n" + "Please, go to Firebase console and enable Anonymous login.\n" + "Open «Application Output» in Xamarin Studio for more information.", NavigationController, "Ok, let me enable it!"); Console.WriteLine("Anonymous sign-in seems to be disabled. Please, visit the following link to know how " + "to enable it: https://firebase.google.com/docs/auth/ios/anonymous-auth#before-you-begin"); break; case AuthErrorCode.NetworkError: UIAlertHelper.ShowMessage(title, "Seems to be the first time that you run the sample and you don't have access to internet.\n" + "The sample needs to run with internet at least once so you can create an Anonymous user.", NavigationController, "Ok"); break; default: UIAlertHelper.ShowMessage(title, "An unknown error has ocurred…", NavigationController, "Ok"); break; } indicatorView.StopAnimating(); } }
// Gets the folder name and verifies that folder name is written correctly void btnNewFolder_Clicked(object sender, EventArgs e) { UIAlertHelper.ShowMessage("Create a new folder", "Type a folder name.\nName can contain letters, numbers, spaces, dashes and underscores only", NavigationController, "Create", new [] { "Folder name" }, (alertCanceled, textfieldInputs) => { if (alertCanceled) { return; } var folderName = textfieldInputs [0].Trim(); if (string.IsNullOrWhiteSpace(folderName)) { UIAlertHelper.ShowMessage("Empty name!", "A folder name cannot be a space or an empty name.", NavigationController, "Ok"); return; } if (!VerifyFolderName(folderName)) { UIAlertHelper.ShowMessage("Bad folder name!", "A name can contain letters, numbers, spaces, dashes and underscores only.", NavigationController, "Ok"); return; } if (VerifyIfFolderExists(folderName)) { UIAlertHelper.ShowMessage("Folder exists!", "A folder with that name already exists.", NavigationController, "Ok"); return; } CreateFolder(folderName); }); }