質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.49%
Firebase

Firebaseは、Googleが提供するBasSサービスの一つ。リアルタイム通知可能、並びにアクセス制御ができるオブジェクトデータベース機能を備えます。さらに認証機能、アプリケーションのログ解析機能などの利用も可能です。

Q&A

0回答

202閲覧

Firebaseにデータを入れると、コンソールにエラー表示がでる

amazon_106

総合スコア50

Firebase

Firebaseは、Googleが提供するBasSサービスの一つ。リアルタイム通知可能、並びにアクセス制御ができるオブジェクトデータベース機能を備えます。さらに認証機能、アプリケーションのログ解析機能などの利用も可能です。

0グッド

0クリップ

投稿2019/01/23 16:22

編集2019/01/23 16:30

Xcodeのコンソールのエラーコードです。シミュレーターが立ち上がって、いきなり出たエラーです。

Failed to fetch default token Error Domain=com.firebase.iid Code=0 "(null)"```
import UIKit import Firebase class SignUpVC: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate { // MARK: - Properties var imageSelected = false let plusPhotoBtn: UIButton = { let button = UIButton(type: .system) button.setImage(#imageLiteral(resourceName: "plus_photo").withRenderingMode(.alwaysOriginal), for: .normal) button.addTarget(self, action: #selector(handleSelectProfilePhoto), for: .touchUpInside) return button }() let emailTextField: UITextField = { let tf = UITextField() tf.placeholder = "Email" tf.backgroundColor = UIColor(white: 0, alpha: 0.03) tf.borderStyle = .roundedRect tf.font = UIFont.systemFont(ofSize: 14) tf.addTarget(self, action: #selector(formValidation), for: .editingChanged) return tf }() let passwordTextField: UITextField = { let tf = UITextField() tf.placeholder = "password" tf.isSecureTextEntry = true tf.backgroundColor = UIColor(white: 0, alpha: 0.03) tf.borderStyle = .roundedRect tf.font = UIFont.systemFont(ofSize: 14) tf.addTarget(self, action: #selector(formValidation), for: .editingChanged) return tf }() let fullNameTextField: UITextField = { let tf = UITextField() tf.placeholder = "Full Name" tf.backgroundColor = UIColor(white: 0, alpha: 0.03) tf.borderStyle = .roundedRect tf.font = UIFont.systemFont(ofSize: 14) return tf }() let usernameTextField: UITextField = { let tf = UITextField() tf.placeholder = "Username" tf.backgroundColor = UIColor(white: 0, alpha: 0.03) tf.borderStyle = .roundedRect tf.font = UIFont.systemFont(ofSize: 14) return tf }() let signUpButton: UIButton = { let button = UIButton(type: .system) button.setTitle("Sign Up", for: .normal) button.setTitleColor(.white, for: .normal) button.backgroundColor = UIColor(red: 149/255, green: 204/255, blue: 244/255, alpha: 1) button.layer.cornerRadius = 5 button.isEnabled = false button.addTarget(self, action: #selector(handleSignUp), for: .touchUpInside) return button }() let alreadyHaveAccountButton: UIButton = { let button = UIButton(type: .system) let attributedTitle = NSMutableAttributedString(string: "Already have an account? ",attributes: [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 14), NSAttributedString.Key.foregroundColor: UIColor.lightGray]) attributedTitle.append(NSAttributedString(string: "Sign In", attributes: [NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 14),NSAttributedString.Key.foregroundColor: UIColor(red: 17/255, green: 154/255, blue: 237/255, alpha: 1)])) button.addTarget(self, action: #selector(handleShowLogin), for: .touchUpInside) button.setAttributedTitle(attributedTitle, for: .normal) return button }() override func viewDidLoad() { super.viewDidLoad() //background color view.backgroundColor = .white view.addSubview(plusPhotoBtn) plusPhotoBtn.anchor(top: view.topAnchor, left: nil, bottom: nil, right: nil, paddingTop: 40, paddingLeft: 0, paddingBottom: 0, paddingRight: 0, width: 140, height: 140) plusPhotoBtn.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true configureViewComponets() view.addSubview(alreadyHaveAccountButton) alreadyHaveAccountButton.anchor(top: nil, left: view.leftAnchor, bottom: view.bottomAnchor, right: view.rightAnchor, paddingTop: 0, paddingLeft: 0, paddingBottom: 0, paddingRight: 0, width: 0, height: 50) } // MARK: - Handlers @objc func handleSelectProfilePhoto() { // configure image picker let imagePicker = UIImagePickerController() imagePicker.delegate = self imagePicker.allowsEditing = true // present image picker self.present(imagePicker, animated: true, completion: nil) } @objc func handleShowLogin(){ _ = navigationController?.popViewController(animated: true) } @objc func handleSignUp() { guard let email = emailTextField.text else { return } guard let password = passwordTextField.text else { return } Auth.auth().createUser(withEmail: email, password: password) { (user, error) in //handle error if let error = error { print("Falled to create user with error: ",error.localizedDescription) return } // success print("Successfully created user with Firebase") } } @objc func formValidation(){ guard emailTextField.hasText, passwordTextField.hasText, fullNameTextField.hasText, usernameTextField.hasText, imageSelected == true else { signUpButton.isEnabled = false signUpButton.backgroundColor = UIColor(red: 149/255, green: 204/255, blue: 244/255, alpha: 1) return } signUpButton.isEnabled = true signUpButton.backgroundColor = UIColor(red: 17/255, green: 154/255, blue: 237/255, alpha: 1) } func configureViewComponets(){ let stackView = UIStackView(arrangedSubviews: [emailTextField, fullNameTextField, usernameTextField, passwordTextField, signUpButton]) stackView.axis = .vertical stackView.spacing = 10 stackView.distribution = .fillEqually view.addSubview(stackView) stackView.anchor(top: plusPhotoBtn.bottomAnchor, left: view.leftAnchor, bottom: nil, right: view.rightAnchor, paddingTop: 24, paddingLeft: 40, paddingBottom: 0, paddingRight: 40, width: 0, height: 240) } }

すいません。どこを抽出したらいいのかわからず、全部のコードを載せました。
loginとsignUpを作ったのですが、signUpのボタンがクリックしても、色の変化がなく、今回はsignUpのコードを載せました。図々しいですが、なぜボタンの色が変わらないか、見当が付く方いらっしゃいましたら、そちらの方も回答お願いしたいです。よろしくお願いします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

hameji001

2019/01/23 16:23

2個目のコード最初の ``` が抜けていますよ。 修正をお願いします。
amazon_106

2019/01/23 16:30

ご指摘ありがとうございます
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.49%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問