async void RequestAccessToPhotoLibrary() { switch (PHPhotoLibrary.AuthorizationStatus) { case PHAuthorizationStatus.NotDetermined: await PHPhotoLibrary.RequestAuthorizationAsync(); GetPhotos(); break; case PHAuthorizationStatus.Authorized: break; default: UIAlertHelper.ShowMessage("Cannot access to Photo Library!", "Please, check in Settings app that you have permission to access to Photos.", NavigationController, "Ok", null, null, null, new [] { "Go to settings" }, new Action[] { OpenSettings }); break; } }
// Sign in Anonymously void SignInAnonymouslyCompleted(AuthDataResult authData, NSError error) { if (error == null) { AppDelegate.UserUid = authData.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, "The sample needs internet to create an Anonymous user.", NavigationController, "Ok"); break; default: UIAlertHelper.ShowMessage(title, "An unknown error has ocurred…", NavigationController, "Ok"); break; } indicatorView.StopAnimating(); } }