Adding the Firebase Authentication system in MIT App Inventor 2

in #utopian-io4 years ago (edited)

Project Name:

MIT App Inventor 2

Project GitHub Repository:

https://github.com/mit-cml/appinventor-sources

My GitHub Profile:

https://github.com/rockstar96969696

Components

  • Firebase Authentication system Extension in MIT App Inventor
  • Firebase create a user account with email() and password() block in MIT App Inventor
  • Firebase Sign in user with email() and password() block in MIT App Inventor

Proposal

MIT App Inventor is a free opensource Android and Ios App developing platform. The Firebase extension in MIT App Inventor is awesome and allow the user to use the real-time database of Firebase.

  • Firebase Authentication system block
    The authentication system is used to authenticate the user with its email and password. There should b an Extension that used to authenticate a user to use the app if required. I provide the JAVA Code for the implementation of this Extention in MainActivity.java
        import com.google.firebase.auth.FirebaseAuth;
    import com.google.android.gsm.tsks.OnCompleteListner;
    import com.google.android.gsm.tasks.Task;
      public class MainActivity extends Activity {
    
    
    private FirebaseAuth Auth;
    private OnCompleteListener<AuthResult> _Auth_create_user_listener;
    private OnCompleteListener<AuthResult> _Auth_sign_in_listener;
@Override
protected void onCreate(Bundle _savedInstanceState) {
super.onCreate(_savedInstanceState);
setContentView(R.layout.main);
initialize();
initializeLogic();
}
private void initialize() {
Auth = FirebaseAuth.getInstance();
_Auth_create_user_listener = new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(Task<AuthResult> _param1) {
final boolean _success = _param1.isSuccessful();
final String _errorMessage = _param1.getException() != null ? _param1.getException().getMessage() : "";             
}
};
_Auth_sign_in_listener = new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(Task<AuthResult> _param1) {
final boolean _success = _param1.isSuccessful();
final String _errorMessage = _param1.getException() != null ? _param1.getException().getMessage() : "";
                
            }
        };

  • Firebase create a user account with email() and password() block
    There should be a block in MIT that allows the user to create an account using the firebase authentication.
    Suppose that I use two TextBoxes, one for inputting email and other for the password and a button to create a new account using these email and password it looks like as

MIT App Inventor.png

I am also providing the code for it.


button1.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view){
Auth.createUserWithEmailAndPassword(TextBox1.getText().toString().TextBox2.getText().toString()).addOnCompleteListener(MainActivity.this_Auth_create_user_listener);
}
});
  • Firebase Sign in user with email() and password() block
    There should be a block that sign in the user using the firebase authentication and allow the user to sign in to its firebase account that used in app after successfully signing up.
    Its code if we use button2 for sign in.
button2.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view){
Auth.signInWithEmailAndPassword(TextBox1.getText().toString().TextBox2.getText().toString()).addOnCompleteListener(MainActivity.this_Auth_sign_in_listener);
}
});

Mockups / Examples

  • Example of FirebaseAuth in MIT App Inventor
    MIT App Inventor (1).png

  • Example of Create an account block in MIT
    MIT App Inventor (2).png

  • Example of Sign in block in MIT
    MIT App Inventor (3).png

Benefits

  • Firebase Authentication is a very useful component of the firebase. By adding this component in MIT App Inventor the functionality of this platform is enhanced and it will add much more in firebase block. The user can easily authenticate with the app using the Firebase Authentication.
  • With the Create new user account the developer can easily link the authentication system with his app.
  • The developer can use the sign in block to allow the user access the app after the login activity
Sort:  

Hello @faisalmin.
Thank you for sharing this idea. digging inside the project code, i can see that this had already been implemented (code).

Aside that, i would like to point out something else which is the material (e.g codes) used in your contribution. They were not cited properly as i found those exact codes here and here . I strongly recommend that you always add a link to any material that is not directly yours.

As already mentioned in the project's readme its best you follow that guideline to contribute to that project. Perhaps during the discussion, you will get to know what has or has not been implemented.
Thank you.


Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

Thanks. I must go through the Source code before my next contribution.... Thanks for such a informative guideline @knowledges

Coin Marketplace

STEEM 0.29
TRX 0.06
JST 0.040
BTC 36851.37
ETH 2467.88
USDT 1.00
SBD 4.01