简体   繁体   English

销毁活动后删除Auth Firebase用户

[英]Deleting an Auth Firebase User When an Activity Is Destroyed

I have an activity called ValidadorActivity, in this activity I do a sms validation, right after the user signs up. 我有一个名为ValidadorActivity的活动,在此活动中,我在用户注册后立即进行了短信验证。

The registration is done by the Firebase Auth but it is done before this validation, so I look for a way to delete the auth firebase registry when the user exits the validation screen without putting the Token that was sent by sms correctly. 注册是由Firebase Auth完成的,但是它是在此验证之前完成的,因此,我寻找一种在用户退出验证屏幕时删除auth firebase注册表的方法,而不会正确放置由sms发送的令牌。

@Override
    protected void onDestroy() {
        super.onDestroy();

        //Ao fechar completamente a tela de validação com o campo textValidacao nulo ou incorreto, o cadastro no autenticacao e no banco de dados sao apagados, para evitar o cadastro de usuarios não validados.

        String codigoDigitado = codigoValidacao.getText().toString(); //Pega o texto da caixa de texto

        if (! codigoDigitado.equals(tokenGerado)) {//Verifica se esse texto e igual

            user.delete().addOnCompleteListener(new OnCompleteListener<Void>() { //deleta o usuario no Auth
                @Override
                public void onComplete(@NonNull Task<Void> task) {

                    if (task.isSuccessful()) {//Testa para ver se funcionou

                        Log.i("Usuario deletado(auth)","Sim");


                    }else{

                        Log.i("Usuario deletado(auth)","Não");

                    }

                }
            });
}

This code is not running, I think the code is right. 这段代码没有运行,我认为代码是正确的。 Any ideas or suggestions? 有什么想法或建议吗?

The onDestroy method only runs when the activity is destroyed by the system, which is seldom the same as when the user exits the activity. onDestroy方法仅在活动被系统销毁时才运行,这与用户退出活动时很少相同。

You might want to look at onPause or onStop , and in general have a look at the Android activity lifecycle for when precisely you want the code to run. 您可能需要查看onPauseonStop ,并且通常可以了解一下您希望代码何时运行的Android活动生命周期

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM