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

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

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

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

Flutter

Flutterは、iOSとAndroidのアプリを同じコードで開発するためのフレームワークです。オープンソースで開発言語はDart。双方のプラットフォームにおける高度な実行パフォーマンスと開発効率を提供することを目的としています。

ログイン

ログインは、ユーザーがコンピューターシステムにアクセスするプロセスの事を呼びます。

Dart

Dartは、Googleによって開発されたJavaScriptの代替となることを目的に作られた、ウェブ向けのプログラミング言語である。

Google

Googleは、アメリカ合衆国に位置する、インターネット関連のサービスや製品を提供している企業です。検索エンジンからアプリケーションの提供まで、多岐にわたるサービスを提供しています。

Q&A

解決済

1回答

1823閲覧

firebaseでメール確認ができない

gawasa29

総合スコア25

Firebase

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

Flutter

Flutterは、iOSとAndroidのアプリを同じコードで開発するためのフレームワークです。オープンソースで開発言語はDart。双方のプラットフォームにおける高度な実行パフォーマンスと開発効率を提供することを目的としています。

ログイン

ログインは、ユーザーがコンピューターシステムにアクセスするプロセスの事を呼びます。

Dart

Dartは、Googleによって開発されたJavaScriptの代替となることを目的に作られた、ウェブ向けのプログラミング言語である。

Google

Googleは、アメリカ合衆国に位置する、インターネット関連のサービスや製品を提供している企業です。検索エンジンからアプリケーションの提供まで、多岐にわたるサービスを提供しています。

0グッド

0クリップ

投稿2021/09/22 04:59

#【できていること】
FlutterでFirebaseに接続しAuthenticationを用いてログイン機能を実装しsendEmailVerification()メソッドを使用し確認メールを飛ばす
#【したいこと】
メール確認をしないとログインできないようにしたい。
#【質問】
確認メールがきてリンクをクリックしてメールアドレス確認をしてもemailVerified()の値がfalseのままです。
正直エラーも出ていないので何が間違っているかわかりませんよろしければぜひアドバイスお願いします。

#【実際のコード】

import 'package:firebase_auth/firebase_auth.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/material.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp(); runApp(MyApp()); } class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'sample', theme: ThemeData( primaryColor: Color.fromRGBO(128, 128, 128, 1.0), secondaryHeaderColor: Color.fromRGBO(128, 128, 128, 1.0), colorScheme: ColorScheme.fromSwatch() .copyWith(secondary: Color.fromRGBO(250, 250, 250, 1.0))), home: MailScreen(), ); } } // 入力されたメールアドレス String newUserEmail = ""; // 入力されたパスワード String newUserPassword = ""; class MailScreen extends StatefulWidget { const MailScreen({Key? key}) : super(key: key); @override _MailScreenState createState() => _MailScreenState(); } class _MailScreenState extends State<MailScreen> { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( elevation: 0.0, backgroundColor: Colors.white10, automaticallyImplyLeading: false, ), body: Column(children: <Widget>[ Align( alignment: Alignment.topLeft, child: Text( "メールアドレス登録", style: TextStyle( fontSize: 25, fontWeight: FontWeight.w600, color: Colors.black54), )), SizedBox( height: (80.0), ), Row(children: <Widget>[ Expanded( flex: 3, child: TextFormField( // テキスト入力のラベルを設定 decoration: InputDecoration(labelText: "メールアドレス"), onChanged: (String value) { setState(() { newUserEmail = value; }); }, ), ), ]), Row(children: <Widget>[ Expanded( flex: 3, child: TextFormField( decoration: InputDecoration(labelText: "パスワード(6文字以上)"), obscureText: true, onChanged: (String value) { setState(() { newUserPassword = value; }); }, ), ), ]), SizedBox( height: 66, ), SizedBox( height: 50, width: 300, child: ElevatedButton( style: ElevatedButton.styleFrom( shape: RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(30))), primary: Color.fromRGBO(128, 128, 128, 1.0), onPrimary: Colors.white, ), onPressed: () async { try { // メール/パスワードでユーザー登録 final FirebaseAuth auth = FirebaseAuth.instance; final UserCredential result = await auth.createUserWithEmailAndPassword( email: newUserEmail, password: newUserPassword, ); //メール確認コード送信 await FirebaseAuth.instance.currentUser! .sendEmailVerification(); print("成功"); Navigator.push( context, MaterialPageRoute(builder: (context) => EmailCheckScreen()), ); } catch (e) { // 登録に失敗した場合 print("アカウントあります"); } }, child: const Text('次へ'), ), ), ]), ); } } //メール確認画面 class EmailCheckScreen extends StatefulWidget { const EmailCheckScreen({Key? key}) : super(key: key); @override _EmailCheckScreenState createState() => _EmailCheckScreenState(); } class _EmailCheckScreenState extends State<EmailCheckScreen> { User? user = FirebaseAuth.instance.currentUser; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("サンプル"), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ ElevatedButton( child: const Text('Button'), style: ElevatedButton.styleFrom( primary: Colors.orange, onPrimary: Colors.white, ), onPressed: () async { try { UserCredential userCredential = await FirebaseAuth.instance.signInWithEmailAndPassword( email: newUserEmail, password: newUserPassword, ); //中身確認 print(user?.emailVerified); if (user!.emailVerified) { Navigator.push( context, MaterialPageRoute( builder: (context) => Screen(), )); } else { print("失敗"); } } catch (e) { print('NG'); } }, ), ], ), ), ); } } class Screen extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("gawa"), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: const <Widget>[ Text( 'You have pushed the button this many times:', ), ], ), ), floatingActionButton: FloatingActionButton( onPressed: () {}, tooltip: 'Increment', child: Icon(Icons.add), ), ); } }

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

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

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

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

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

guest

回答1

0

ベストアンサー

こんな感じですかね

dart

1// EmailCheckScreen内 2User? currentUser; 3initState(){ 4 currentUser = FirebaseAuth.instance.currentUser; 5 currentUser!.sendEmailVerifycation(); 6} 7Future checkIsEmailVerified(context) async { 8 // ElevatedButtonが押された時の処理 9 await currentUser!.reload(); 10 if (currentUser!.emailVerified) { 11 // contextを利用して任意のページへ 12 } else { 13 print('認証に失敗しました') 14 } 15} 16

投稿2021/10/01 08:24

nekoyama141592

総合スコア53

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.46%

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

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

質問する

関連した質問