ആദ്യം android studio യിൽ പോയ് firebase ടൂൾസിൽ click ചെയ്യണം
പിന്നീട് gmail (google) account sign ചെയ്യാൻ അതിൽ option കാണും
1.connect to firebase
നിങ്ങളുടെ രാജ്യം select ചെയ്യാൻ അതിൽ option കാണും
2.add firebase authentication your app
Accept and changes click ചെയ്യുക
3.https://console.firebase.google.com/
ചെന്ന്
https://console.firebase.google.com/project/--yourprojectname--/authentication/providers
email/password enable ചെയ്യുക
ഇനി പ്രോഗ്രാമിലോട്ടു വരാം
4.private FirebaseAuth mAuth;
ഇത് class ൽ global variable ആക്കി set ചെയ്യുക
5.mAuth = FirebaseAuth.getInstance()
ഇത് oncreate bundle constructor ഫങ്ക്ഷനിൽ കൊടുക്കുക
6.
@Override
public void onStart() {
super.onStart();
// Check if user is signed in (non-null) and update UI accordingly.
FirebaseUser currentUser = mAuth.getCurrentUser();
updateUI(currentUser);
}
ഇത് ഒരു onStart() overide function നീൽ
FirebaseUser currentUser = mAuth.getCurrentUser();paste ചെയ്യുക
ഈ current user വെച്ച് കൊണ്ട് user ഉണ്ടോ ഇല്ലയോ എന്ന് ചെക്ക് ചെയ്യാൻ കഴിയും
if(currentUser ==nul)
{
current user ഇല്ല എങ്കിൽ ഇത് ചെയ്യുക
}
7.user registration email and password വെച്ച് ചെയ്യാൻ
ഇനി already register ചെയ്തിട്ടുണ്ടെൽ step 8 ഇലോട്ടു പോവുക
ഇത് ഒരു button click ചെയ്താൽ ചെയ്യേണ്ടതാണ് അതിൽ ഒരു method കൊടുക്കുക register__User(String displayname,String username,String password);
mAuth.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
// Sign in success, update UI with the signed-in user's information
// Log.d(TAG, "createUserWithEmail:success");
// FirebaseUser user = mAuth.getCurrentUser();
// updateUI(user);
sign in ആയാൽ succes പേജ് ഇലോട്ടു പോവുക eg:
ഇവിടെ user account page ഇലോട്ടു direct ചെയ്യാം
} else {
// If sign in fails, display a message to the user.
// Log.w(TAG, "createUserWithEmail:failure", task.getException());
// Toast.makeText(EmailPasswordActivity.this, "Authentication failed.",
// Toast.LENGTH_SHORT).show();
// updateUI(null);
. എന്തോ പ്രശനം ഉണ്ട്
അത് കൊണ്ട് home register page ഇലോട്ടു തന്നെ redirect ചെയ്യാം
}
// ...
}
});
8.sign in ചെയ്യാൻ
mAuth.signInWithEmailAndPassword(email, password)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
// Sign in success, update UI with the signed-in user's information
// Log.d(TAG, "signInWithEmail:success");
// FirebaseUser user = mAuth.getCurrentUser();
// updateUI(user);
user succes ആയി sign in ചെയ്തിരിക്കുന്നു ഇനി അടുത്ത പേജിലോട് പോകാം
} else {
// If sign in fails, display a message to the user.
// Log.w(TAG, "signInWithEmail:failure", task.getException());
// Toast.makeText(EmailPasswordActivity.this, "Authentication failed.",
// Toast.LENGTH_SHORT).show();
// updateUI(null);
email അല്ലെങ്കിൽ password തെറ്റാണു error പേജിലോട് പോവുക
}
// ...
}
});
പിന്നീട് gmail (google) account sign ചെയ്യാൻ അതിൽ option കാണും
1.connect to firebase
നിങ്ങളുടെ രാജ്യം select ചെയ്യാൻ അതിൽ option കാണും
2.add firebase authentication your app
Accept and changes click ചെയ്യുക
3.https://console.firebase.google.com/
ചെന്ന്
https://console.firebase.google.com/project/--yourprojectname--/authentication/providers
email/password enable ചെയ്യുക
ഇനി പ്രോഗ്രാമിലോട്ടു വരാം
4.private FirebaseAuth mAuth;
ഇത് class ൽ global variable ആക്കി set ചെയ്യുക
5.mAuth = FirebaseAuth.getInstance()
ഇത് oncreate bundle constructor ഫങ്ക്ഷനിൽ കൊടുക്കുക
6.
@Override
public void onStart() {
super.onStart();
// Check if user is signed in (non-null) and update UI accordingly.
FirebaseUser currentUser = mAuth.getCurrentUser();
updateUI(currentUser);
}
ഇത് ഒരു onStart() overide function നീൽ
FirebaseUser currentUser = mAuth.getCurrentUser();paste ചെയ്യുക
ഈ current user വെച്ച് കൊണ്ട് user ഉണ്ടോ ഇല്ലയോ എന്ന് ചെക്ക് ചെയ്യാൻ കഴിയും
if(currentUser ==nul)
{
current user ഇല്ല എങ്കിൽ ഇത് ചെയ്യുക
}
7.user registration email and password വെച്ച് ചെയ്യാൻ
ഇനി already register ചെയ്തിട്ടുണ്ടെൽ step 8 ഇലോട്ടു പോവുക
ഇത് ഒരു button click ചെയ്താൽ ചെയ്യേണ്ടതാണ് അതിൽ ഒരു method കൊടുക്കുക register__User(String displayname,String username,String password);
mAuth.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
// Sign in success, update UI with the signed-in user's information
// Log.d(TAG, "createUserWithEmail:success");
// FirebaseUser user = mAuth.getCurrentUser();
// updateUI(user);
sign in ആയാൽ succes പേജ് ഇലോട്ടു പോവുക eg:
ഇവിടെ user account page ഇലോട്ടു direct ചെയ്യാം
} else {
// If sign in fails, display a message to the user.
// Log.w(TAG, "createUserWithEmail:failure", task.getException());
// Toast.makeText(EmailPasswordActivity.this, "Authentication failed.",
// Toast.LENGTH_SHORT).show();
// updateUI(null);
. എന്തോ പ്രശനം ഉണ്ട്
അത് കൊണ്ട് home register page ഇലോട്ടു തന്നെ redirect ചെയ്യാം
}
// ...
}
});
8.sign in ചെയ്യാൻ
mAuth.signInWithEmailAndPassword(email, password)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
// Sign in success, update UI with the signed-in user's information
// Log.d(TAG, "signInWithEmail:success");
// FirebaseUser user = mAuth.getCurrentUser();
// updateUI(user);
user succes ആയി sign in ചെയ്തിരിക്കുന്നു ഇനി അടുത്ത പേജിലോട് പോകാം
} else {
// If sign in fails, display a message to the user.
// Log.w(TAG, "signInWithEmail:failure", task.getException());
// Toast.makeText(EmailPasswordActivity.this, "Authentication failed.",
// Toast.LENGTH_SHORT).show();
// updateUI(null);
email അല്ലെങ്കിൽ password തെറ്റാണു error പേജിലോട് പോവുക
}
// ...
}
});
thanks
ReplyDelete