I have configured email verification and password email reset in my firebase project, it used to work fine, I tested it multiple times, but suddenly it stopped working and I am not recieving any email.
I tried checking spam but still, there was nothing.
Here's my code for sending email verification after registering user:
user.sendEmailVerification().addOnSuccessListener(new OnSuccessListener<Void>() {
#Override
public void onSuccess(Void unused) {
Toast.makeText(RegisterActivity.this, "Please verifiy your email and sign in", Toast.LENGTH_SHORT).show();
startActivity(new Intent(getApplicationContext(), VerificationActivity.class));
finish();
}
}).addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
Toast.makeText(RegisterActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
}
});
I also tried to make a button that re-send the email but I get the following message "we have stopped all traffic from this device due to unsual activity"
verify.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
user.sendEmailVerification().addOnSuccessListener(new OnSuccessListener<Void>() {
#Override
public void onSuccess(Void unused) {
Toast.makeText(VerificationActivity.this, "Verification email has been sent, check spam if you are unable to find it", Toast.LENGTH_LONG).show();
}
}).addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
Toast.makeText(VerificationActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
});
my code for email reset:
auth.sendPasswordResetEmail(email.getText().toString()).addOnSuccessListener(new OnSuccessListener<Void>() { //email is entered by the user
#Override
public void onSuccess(Void unused) {
Toast.makeText(LoginActivity.this, "Reset email sent", Toast.LENGTH_SHORT);
}
}).addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
Toast.makeText(LoginActivity.this, e.getMessage(), Toast.LENGTH_SHORT);
}
});
Related
I am working on an application where i have list of items in recyclerview now on the recyclerview i have a heart icon when someone click on that icon that particular data added to the firebase and when again clikc on that data delete from the firebase now data is adding successully but i dont know why the data is not deleting from the firebase. please guide me
code is
holder.wishlist.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
#Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
int id = holder.getBindingAdapterPosition();
//CODE TO ADD THE ITEM TO THE WISHLIST
if(compoundButton.isChecked())
{
firebaseFirestore.collection("wishlistDetails").document(uid).set(wishMap).addOnSuccessListener(new OnSuccessListener<Void>() {
#Override
public void onSuccess(Void unused) {
Toast.makeText(context, "added to firestire", Toast.LENGTH_SHORT).show();
}
}).addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
}
});
Toast.makeText(context, "item added to wishlist" + id , Toast.LENGTH_SHORT).show();
}else {
//CODE TO REMOVE THE WISHLIST FROM FIREBASE
firebaseFirestore.collection("wishlistDetails").document(datalist.get(position).getID())
.delete()
.addOnCompleteListener(new OnCompleteListener<Void>() {
#Override
public void onComplete(#NonNull Task<Void> task) {
Toast.makeText(context, "removed", Toast.LENGTH_SHORT).show();
}
}).addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
Toast.makeText(context, e.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
}
});
Try this -
In your wishlistmap add one more key id -- pass value uid for that key. Modify your wishlist model and add the id key.
Modify function for remove wishlist like below -
//CODE TO REMOVE THE WISHLIST FROM FIREBASE
firebaseFirestore.collection("wishlistDetails").document(list.get(position).getId())
.delete()
.addOnCompleteListener(new OnCompleteListener<Void>() {
#Override
public void onComplete(#NonNull Task<Void> task) {
Toast.makeText(context, "removed", Toast.LENGTH_SHORT).show();
}
}).addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
Toast.makeText(context, e.getMessage(), Toast.LENGTH_SHORT).show();
}
});
realtime Database in firebase doesn't save data and doesn't show any errors
i have already set
"rules": {
".read": "true",
".write": "true"
}
and this is the function it create new user and it's created in firebase but the user name and email doesn't save in realtime database
public void createUser(String email, String password, String userName) {
auth = FirebaseAuth.getInstance();
auth.createUserWithEmailAndPassword(email, password).addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_SHORT).show();
}
}).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
#Override
public void onComplete(#NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
Toast.makeText(getContext(), "user created", Toast.LENGTH_SHORT).show();
User user = new User(email, userName);
FirebaseDatabase.getInstance().getReference().child("Users")
.child(FirebaseAuth.getInstance().getCurrentUser().getUid())
.setValue(user).addOnCompleteListener(new OnCompleteListener<Void>() {
#Override
public void onComplete(#NonNull Task<Void> task) {
if (task.isSuccessful()) {
Toast.makeText(getContext(), "user info added", Toast.LENGTH_SHORT).show();
}
}
}).addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
}
});
}
and this line is appere as toast i don't know how it is happen
Toast.makeText(getContext(), "user info added", Toast.LENGTH_SHORT).show()
I don't know why I'm getting this exception E/StorageException: Unable to obtain an upload URL whenever it gets to uploading file/image onto Firebase Storage. It's also returning W/NetworkRequest: error sending network request error. Although I don't experience any internet connectivity problems. I've also tried running this with another device but it results in the same thing.
firebaseAuth.createUserWithEmailAndPassword(inputEmail, inputPassword).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
#Override
public void onComplete(#NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
firebaseAuth.getCurrentUser().sendEmailVerification().addOnCompleteListener(new OnCompleteListener<Void>() {
#Override
public void onComplete(#NonNull final Task<Void> task) {
final String uID = firebaseAuth.getCurrentUser().getUid();
if (task.isSuccessful()) {
storageReference = FirebaseStorage.getInstance().getReference("image").child(uID); // for image uploads
storageReference.putFile(image_uri)
.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
#Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
//image uri is taken care of in the onActivityResult method.
member.setImage_url(taskSnapshot.getUploadSessionUri().toString());
member.setEmail(email.getText().toString().trim());
member.setFname(fname.getText().toString().trim());
member.setLname(lname.getText().toString().trim());
df = FirebaseDatabase.getInstance().getReference("Member").child(uID); //points to the address
df.setValue(member).addOnCompleteListener(new OnCompleteListener<Void>() {
#Override
public void onComplete(#NonNull Task<Void> task) {
startActivity(new Intent(Register.this, Login.class));
Toast.makeText(Register.this, "Registered successfully, please verify your email.", Toast.LENGTH_LONG).show();
}
});
RprogressBar.setVisibility(View.INVISIBLE);
}
}).addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
Toast.makeText(Register.this, e.getMessage(), Toast.LENGTH_LONG).show();
RprogressBar.setVisibility(View.INVISIBLE);
}
});
} else {
Toast.makeText(Register.this, task.getException().getMessage(), Toast.LENGTH_LONG).show();
RprogressBar.setVisibility(View.INVISIBLE);
}
}
});
} else {
Toast.makeText(Register.this, task.getException().getMessage(), Toast.LENGTH_LONG).show();
RprogressBar.setVisibility(View.INVISIBLE);
}
I still only have the slightest idea of what is happening but I've seen some other answers from a similar post and they suggested using VPN I'm currently in the Philippines so if anyone is having a similar problem try using VPN.
On creating a new account, this code first gives "signup successful" then it gives "user already exists". Everything else is working fine.
Help me out with this. Thank you very much for your time and assistance in this matter.
also tried:
dataSnapshot.child(edtRoll.getText().toString())!=null
but it make the situation more worse, it always shows "user doesn't exist".
btnSignUp.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
if (edtRoll.getText().toString().trim().length()!= 9)
Toast.makeText(SignUp.this, "Roll No. must have 9 characters!", Toast.LENGTH_SHORT).show();
else if (edtName.getText().toString().trim().length() < 3)
Toast.makeText(SignUp.this, "Name is too short!", Toast.LENGTH_SHORT).show();
else if (edtPassword.getText().toString().trim().length() < 8)
Toast.makeText(SignUp.this, "Password must have atleast 8 characters!", Toast.LENGTH_SHORT).show();
else if(!(edtPassword.getText().toString()).equals(edtConfirmPassword.getText().toString()))
Toast.makeText(SignUp.this, "Passwords do not match!", Toast.LENGTH_SHORT).show();
else {
final ProgressDialog mDialog = new ProgressDialog(SignUp.this);
mDialog.setMessage("Please Wait...");
mDialog.show();
table_user.addValueEventListener(new ValueEventListener() {
#Override
public void onDataChange(DataSnapshot dataSnapshot) {
//Check if userRoll already exist
if (dataSnapshot.child(edtRoll.getText().toString()).exists()) {
mDialog.dismiss();
Toast.makeText(SignUp.this, "User already registered!", Toast.LENGTH_SHORT).show();
} else {
mDialog.dismiss();
User user = new User(edtName.getText().toString(), edtPassword.getText().toString());
table_user.child(edtRoll.getText().toString()).setValue(user);
Toast.makeText(SignUp.this, "Sign up Successfull!", Toast.LENGTH_SHORT).show();
finish();
}
}
#Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
}
});
Probably this is happened because whenever the button is clicked and user is in sign up state which giving "signup successful" , you're re-registering the listener for the data change:
btnSignUp.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
if (...) {
...
} else {
table_user.addValueEventListener(new ValueEventListener() {
...
}
}
}
});
Hence you're receiving the "signup successful" then "user already exists" message.
You need to initialize the data change listener outside the click button method. Something like this:
final ProgressDialog mDialog;
private void initDataChangeListener() {
table_user.addValueEventListener(new ValueEventListener() {
#Override
public void onDataChange(DataSnapshot dataSnapshot) {
...
}
#Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
Then call the initDataChangeListener before adding the click listener:
initDataChangeListener();
btnSignUp.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
if (...) {
...
} else {
if(mDialog == null) mDialog = new ProgressDialog(SignUp.this);
mDialog.setMessage("Please Wait...");
mDialog.show();
// no need to handle the data, because it's already handled by the data change listener.
}
}
});
I have done the task on "Inviting users to the app using facebook" in android, used the below codes as a result if i send the invitation, the invite message rarely delivers after many hours and or else not getting delivered, do anybody know the solution for this?
final ImageView facebook1 = (ImageView) findViewById(R.id.facebook1);
facebook1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v){
Facebook mFacebook = new Facebook( APP_ID );
Bundle params = new Bundle();
params.putString("message", "Prova ");
mFacebook.dialog(Singlemenuitem.this, "apprequests", params, new DialogListener() {
public void onComplete(Bundle values) {
Toast toast = Toast.makeText(getApplicationContext(), "Done",
Toast.LENGTH_SHORT);
toast.show();
}
public void onFacebookError(FacebookError error) {
Toast.makeText(getApplicationContext(), "Facebook Error: " + error.getMessage(),
Toast.LENGTH_SHORT).show();
}
public void onCancel() {
Toast toast = Toast.makeText(getApplicationContext(), "App request cancelled",
Toast.LENGTH_SHORT);
toast.show();
}
public void onError(DialogError e) {
// TODO Auto-generated method stub
}
});
} });