firebase OTP is not receiving for international numbers











up vote
0
down vote

favorite












I am from India, am working on an android app, In this the Indian mobile numbers are successfully getting OTP from the firebase where the international mobile numbers that are used in physical devices in their respective countries are not getting OTP. I have tried using the international dummy numbers from this portal online sms OTP portal are getting OTP through online except United states numbers, but the OTP not receiving for international numbers in their physical devices.
I have followed the steps from the firebase Documentation but it didn't help me.



Thanks in advance



activity_number.xml



<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.pmkmap.Activities.NumberActivity">


<LinearLayout
android:id="@+id/number_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@drawable/pmk_background_pic" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:text="PMK"
android:textColor="@color/blue"
android:textSize="15sp"
android:textStyle="bold"
android:visibility="gone" />


<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">

<com.hbb20.CountryCodePicker
android:id="@+id/ccp"
android:layout_width="130dp"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="40dp" />

<EditText
android:id="@+id/enter_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="20dp"
android:layout_marginTop="40dp"
android:digits="0123456789"
android:hint="@string/enter_your_no"
android:inputType="phone"
android:textSize="15dp" />
</LinearLayout>

<Button
android:id="@+id/generate_otp"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:background="@drawable/button_background"
android:text="@string/genrate_otp"
android:textColor="@color/white" />


<EditText
android:id="@+id/enter_otp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="60dp"
android:layout_marginRight="30dp"
android:layout_marginTop="20dp"
android:hint="@string/enterur_otp"
android:inputType="numberPassword"
android:maxLength="6"
android:visibility="gone" />

<Button
android:id="@+id/verify"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:background="@drawable/button_background"
android:text="@string/verify"
android:textColor="@color/white"
android:visibility="gone" />

<TextView
android:id="@+id/resend_otp"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:gravity="center"
android:text="@string/resend_otp"
android:textColor="@color/blue"
android:visibility="gone" />

</LinearLayout>

</LinearLayout>


NumberActivity.java



package com.pmkmap.Activities;

import android.app.Activity;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.RequiresApi;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import com.google.android.gms.analytics.HitBuilders;
import com.google.android.gms.analytics.Tracker;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.FirebaseException;
import com.google.firebase.FirebaseTooManyRequestsException;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseAuthInvalidCredentialsException;
import com.google.firebase.auth.PhoneAuthCredential;
import com.google.firebase.auth.PhoneAuthProvider;
import com.google.firebase.firestore.DocumentSnapshot;
import com.google.firebase.firestore.FirebaseFirestore;
import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.perf.metrics.AddTrace;
import com.hbb20.CountryCodePicker;
import com.pmkmap.Modals.UserTokenModal;
import com.pmkmap.R;
import com.pmkmap.Utility;

import java.util.Map;
import java.util.concurrent.TimeUnit;

public class NumberActivity extends AppCompatActivity implements View.OnClickListener {
private static final String TAG = "PhoneAuthActivity";
EditText enterNoEdt, enterOtpEdt;
Button generateOpt, verifyOtp;
TextView resendOtp;
String mVerificationId, countryCode, countryName, mobileNo;
CountryCodePicker countryCodePicker;
private FirebaseAuth mAuth;
private PhoneAuthProvider.ForceResendingToken mResendToken;
private PhoneAuthProvider.OnVerificationStateChangedCallbacks mCallBacks;
private FirebaseFirestore firestoreDB;
private Tracker mTracker;

public static void hideSoftKeyboard(Activity activity) {
try {
InputMethodManager inputMethodManager =
(InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
} catch (Exception e) {
e.printStackTrace();
}
}

@AddTrace(name = "NumberInput_trace", enabled = true)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_number);
getSupportActionBar().hide();
findID();
clickListener();
AnalyticsApplication application = (AnalyticsApplication) getApplication();
mTracker = application.getDefaultTracker();
mAuth = FirebaseAuth.getInstance();
firestoreDB = FirebaseFirestore.getInstance();
mCallBacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
@Override
public void onVerificationCompleted(PhoneAuthCredential phoneAuthCredential) {
Log.e(TAG, "onVerificationCompleted:" + phoneAuthCredential);
if (mVerificationId == null) {
signInWithPhoneAuthCredential(phoneAuthCredential);
}
}

@Override
public void onVerificationFailed(FirebaseException e) {
Log.e(TAG, "onVerificationFailed", e);
Utility.hideProgressDialog();
if (e instanceof FirebaseAuthInvalidCredentialsException) {
enterNoEdt.setError("தவறான அலைபேசி எண் !");
} else if (e instanceof FirebaseTooManyRequestsException) {
Toast.makeText(NumberActivity.this, "Quota exceeded.", Toast.LENGTH_SHORT).show();
}
}

@Override
public void onCodeSent(String verificationId, PhoneAuthProvider.ForceResendingToken forceResendingToken) {
Log.d(TAG, "onCodeSent:" + verificationId);
Toast.makeText(NumberActivity.this, "உங்கள் அலைபேசி எண்ணிற்கு OTP வெற்றிகரமாக அனுப்பப்பட்டது", Toast.LENGTH_SHORT).show();
mVerificationId = verificationId;
mResendToken = forceResendingToken;
Utility.hideProgressDialog();
generateOpt.setVisibility(View.GONE);
enterOtpEdt.setVisibility(View.VISIBLE);
verifyOtp.setVisibility(View.VISIBLE);
resendOtp.setVisibility(View.VISIBLE);
}
};

}

@Override
protected void onResume() {
super.onResume();
mTracker.setScreenName("Image~" + "Mobile_Number_Input");
mTracker.send(new HitBuilders.ScreenViewBuilder().build());
}

public void findID() {
enterNoEdt = findViewById(R.id.enter_number);
generateOpt = findViewById(R.id.generate_otp);
verifyOtp = findViewById(R.id.verify);
enterOtpEdt = findViewById(R.id.enter_otp);
resendOtp = findViewById(R.id.resend_otp);

countryCodePicker = findViewById(R.id.ccp);
}

private void signInWithPhoneAuthCredential(final PhoneAuthCredential credential) {
mAuth.signInWithCredential(credential).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
if (countryCode.equalsIgnoreCase("+91")) {
getUsers();
} else {
getIntUsers();
}

} else {
Log.w(TAG, "signInWithCredential:failure", task.getException());
if (task.getException() instanceof FirebaseAuthInvalidCredentialsException) {
Utility.hideProgressDialog();
Toast.makeText(NumberActivity.this, task.getException().getMessage(), Toast.LENGTH_SHORT).show();
enterOtpEdt.setError("Invalid code");
}
}
}
});
}

private void startPhoneNumberVerification(String phoneNumber) {
PhoneAuthProvider.getInstance().verifyPhoneNumber(
phoneNumber,
30,
TimeUnit.SECONDS,
this,
mCallBacks);
}

private void verifyPhoneNumberWithCode(String verificationId, String code) {
PhoneAuthCredential credential = PhoneAuthProvider.getCredential(verificationId, code);
signInWithPhoneAuthCredential(credential);
}

private void resendVerificationCode(String phoneNumber, PhoneAuthProvider.ForceResendingToken token) {
PhoneAuthProvider.getInstance().verifyPhoneNumber(
phoneNumber,
30,
TimeUnit.SECONDS,
this,
mCallBacks,
token);
}

public void clickListener() {
generateOpt.setOnClickListener(this);
verifyOtp.setOnClickListener(this);
resendOtp.setOnClickListener(this);
}

@AddTrace(name = "Number_trace", enabled = true)
@Override
public void onClick(View v) {
if (v == generateOpt) {
try {
if (Utility.isNetworkAvailable(NumberActivity.this)) {
if (enterNoEdt.getText().toString().equalsIgnoreCase("")) {
Toast.makeText(this, "தாங்கள் அலைபேசி எண்ணை பதிவு செய்யவும்", Toast.LENGTH_SHORT).show();
} else {
hideSoftKeyboard(NumberActivity.this);
Utility.showProgressDialog(NumberActivity.this);
mobileNo = enterNoEdt.getText().toString();
getCountryCode();
startPhoneNumberVerification(countryCode + mobileNo);
}
} else {
Toast.makeText(this, "தாங்கள் இணையதள இணைப்பை சரி பார்க்கவும்", Toast.LENGTH_SHORT).show();
Utility.hideProgressDialog();
}
} catch (Exception e) {
e.printStackTrace();
Utility.hideProgressDialog();
}
}
if (v == verifyOtp) {
try {
if (Utility.isNetworkAvailable(NumberActivity.this)) {

if (enterOtpEdt.getText().toString().equalsIgnoreCase("")) {
Toast.makeText(this, "OTP ஐ பதிவு செய்க", Toast.LENGTH_SHORT).show();
} else {
hideSoftKeyboard(NumberActivity.this);
Utility.showProgressDialog(NumberActivity.this);
verifyPhoneNumberWithCode(mVerificationId, enterOtpEdt.getText().toString());
}

} else {
Toast.makeText(this, "தாங்கள் இணையதள இணைப்பை சரி பார்க்கவும்", Toast.LENGTH_SHORT).show();
Utility.hideProgressDialog();
}
} catch (Exception e) {
e.printStackTrace();
Utility.hideProgressDialog();
}
}
if (v == resendOtp) {
try {
if (Utility.isNetworkAvailable(NumberActivity.this)) {
if (enterNoEdt.getText().toString().equalsIgnoreCase("")) {
Toast.makeText(this, "தாங்கள் அலைபேசி எண்ணை பதிவு செய்யவும்", Toast.LENGTH_SHORT).show();
} else {
hideSoftKeyboard(NumberActivity.this);
Utility.showProgressDialog(NumberActivity.this);
mobileNo = enterNoEdt.getText().toString();
getCountryCode();
resendVerificationCode(countryCode + mobileNo, mResendToken);
}
} else {
Toast.makeText(this, "தாங்கள் இணையதள இணைப்பை சரி பார்க்கவும்", Toast.LENGTH_SHORT).show();
Utility.hideProgressDialog();
}
} catch (Exception e) {
e.printStackTrace();
Utility.hideProgressDialog();
}
}
}

private void getUsers() {
firestoreDB.collection("users").document(countryCode + mobileNo).get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
@Override
public void onComplete(@NonNull Task<DocumentSnapshot> task) {
try {
if (task.isSuccessful()) {
sendToken();
DocumentSnapshot document = task.getResult();
if (document.exists()) {
Map<String, Object> array = document.getData();
if (array.get("blocked").toString().equalsIgnoreCase("no")) {
Log.e(">>>", array.toString());
checkLoginStatus();
getMyAccountDetailPref();
Log.e(">>>>", document.getId());
startActivity(new Intent(NumberActivity.this, HomeActivity.class));
finish();
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(NumberActivity.this);
builder.setMessage("Your account is blocked by admin.")
.setCancelable(false)
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
NumberActivity.this.finish();
}
});
AlertDialog alert = builder.create();
alert.show();
}

} else {
gotoNextActivity();
}
} else {
try {
sendToken();
gotoNextActivity();
Log.d(TAG, "Error getting documents: ", task.getException());
} catch (Exception e) {
Toast.makeText(NumberActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
}
} catch (Exception e) {
Toast.makeText(NumberActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
e.printStackTrace();
e.printStackTrace();
}
}

}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.e(">>>", e.toString());
}
});
}

private void getIntUsers() {
firestoreDB.collection("int_users").document(countryCode + mobileNo).get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
@Override
public void onComplete(@NonNull Task<DocumentSnapshot> task) {
try {
if (task.isSuccessful()) {
sendToken();
DocumentSnapshot document = task.getResult();
if (document.exists()) {
Map<String, Object> array = document.getData();
if (array.get("blocked").toString().equalsIgnoreCase("no")) {
Log.e(">>>", array.toString());
checkLoginStatus();
getMyAccountDetailPref();
Log.e(">>>>", document.getId());
startActivity(new Intent(NumberActivity.this, HomeActivity.class));
finish();
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(NumberActivity.this);
builder.setMessage("Your account is blocked by admin.")
.setCancelable(false)
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
NumberActivity.this.finish();
}
});
AlertDialog alert = builder.create();
alert.show();
}

} else {
gotoNextActivity();
}
} else {
try {
sendToken();
gotoNextActivity();
Log.d(TAG, "Error getting documents: ", task.getException());
} catch (Exception e) {
Toast.makeText(NumberActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
}
} catch (Exception e) {
Toast.makeText(NumberActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
e.printStackTrace();
e.printStackTrace();
}
}

}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.e(">>>", e.toString());
}
});
}

public void gotoNextActivity() {
if (countryCode.equalsIgnoreCase("+91")) {
getMyAccountDetailPref();
} else {
getMyIntAccountDetailPref();
}

if (countryCode.equalsIgnoreCase("+91")) {
startActivity(new Intent(NumberActivity.this, SaveInformationActivity.class).putExtra("mobile_no", countryCode + mobileNo));
finish();
} else {
startActivity(new Intent(NumberActivity.this, IntSaveInformationActivity.class).putExtra("mobile_no", countryCode + mobileNo)
.putExtra("countryName", countryName));
finish();
}

}

public void checkLoginStatus() {
SharedPreferences settings = getSharedPreferences(SaveInformationActivity.PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putBoolean("hasLoggedIn", true);
editor.commit();
}

public void getMyAccountDetailPref() {
SharedPreferences.Editor editor = getSharedPreferences("mobile_no", MODE_PRIVATE).edit();
editor.putString("user_mobile", countryCode + mobileNo);
editor.apply();
}

public void getMyIntAccountDetailPref() {
SharedPreferences.Editor editor = getSharedPreferences("mobile_no", MODE_PRIVATE).edit();
editor.putString("user_mobile", countryCode + mobileNo);
editor.apply();
}

public void getCountryCode() {
countryCode = countryCodePicker.getFullNumberWithPlus();
countryName = countryCodePicker.getSelectedCountryName();
}

public void sendToken() {
try {
String token = FirebaseInstanceId.getInstance().getToken();
SharedPreferences.Editor editor = getSharedPreferences("user_token", MODE_PRIVATE).edit();
editor.putString("token", token);
editor.apply();
UserTokenModal userTokenModal = new UserTokenModal(token);
firestoreDB.collection("userToken").document(countryCode + mobileNo).set(userTokenModal).addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void documentReference) {
try {
Log.e(">>>>", "token sent succefully");

} catch (Exception e) {
e.printStackTrace();
}

}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.w(">>>", "Error adding event document", e);
Toast.makeText(NumberActivity.this,
e.getMessage(),
Toast.LENGTH_SHORT).show();
Utility.hideProgressDialog();
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
}









share|improve this question




























    up vote
    0
    down vote

    favorite












    I am from India, am working on an android app, In this the Indian mobile numbers are successfully getting OTP from the firebase where the international mobile numbers that are used in physical devices in their respective countries are not getting OTP. I have tried using the international dummy numbers from this portal online sms OTP portal are getting OTP through online except United states numbers, but the OTP not receiving for international numbers in their physical devices.
    I have followed the steps from the firebase Documentation but it didn't help me.



    Thanks in advance



    activity_number.xml



    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.pmkmap.Activities.NumberActivity">


    <LinearLayout
    android:id="@+id/number_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <ImageView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:adjustViewBounds="true"
    android:src="@drawable/pmk_background_pic" />

    <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_marginTop="10dp"
    android:text="PMK"
    android:textColor="@color/blue"
    android:textSize="15sp"
    android:textStyle="bold"
    android:visibility="gone" />


    <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal">

    <com.hbb20.CountryCodePicker
    android:id="@+id/ccp"
    android:layout_width="130dp"
    android:layout_height="wrap_content"
    android:layout_marginLeft="20dp"
    android:layout_marginTop="40dp" />

    <EditText
    android:id="@+id/enter_number"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginRight="20dp"
    android:layout_marginTop="40dp"
    android:digits="0123456789"
    android:hint="@string/enter_your_no"
    android:inputType="phone"
    android:textSize="15dp" />
    </LinearLayout>

    <Button
    android:id="@+id/generate_otp"
    android:layout_width="150dp"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_marginTop="20dp"
    android:background="@drawable/button_background"
    android:text="@string/genrate_otp"
    android:textColor="@color/white" />


    <EditText
    android:id="@+id/enter_otp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="60dp"
    android:layout_marginRight="30dp"
    android:layout_marginTop="20dp"
    android:hint="@string/enterur_otp"
    android:inputType="numberPassword"
    android:maxLength="6"
    android:visibility="gone" />

    <Button
    android:id="@+id/verify"
    android:layout_width="150dp"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_marginTop="20dp"
    android:background="@drawable/button_background"
    android:text="@string/verify"
    android:textColor="@color/white"
    android:visibility="gone" />

    <TextView
    android:id="@+id/resend_otp"
    android:layout_width="150dp"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_marginTop="5dp"
    android:gravity="center"
    android:text="@string/resend_otp"
    android:textColor="@color/blue"
    android:visibility="gone" />

    </LinearLayout>

    </LinearLayout>


    NumberActivity.java



    package com.pmkmap.Activities;

    import android.app.Activity;
    import android.content.DialogInterface;
    import android.content.Intent;
    import android.content.SharedPreferences;
    import android.os.Build;
    import android.os.Bundle;
    import android.support.annotation.NonNull;
    import android.support.annotation.RequiresApi;
    import android.support.v7.app.AlertDialog;
    import android.support.v7.app.AppCompatActivity;
    import android.util.Log;
    import android.view.View;
    import android.view.inputmethod.InputMethodManager;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.TextView;
    import android.widget.Toast;

    import com.google.android.gms.analytics.HitBuilders;
    import com.google.android.gms.analytics.Tracker;
    import com.google.android.gms.tasks.OnCompleteListener;
    import com.google.android.gms.tasks.OnFailureListener;
    import com.google.android.gms.tasks.OnSuccessListener;
    import com.google.android.gms.tasks.Task;
    import com.google.firebase.FirebaseException;
    import com.google.firebase.FirebaseTooManyRequestsException;
    import com.google.firebase.auth.AuthResult;
    import com.google.firebase.auth.FirebaseAuth;
    import com.google.firebase.auth.FirebaseAuthInvalidCredentialsException;
    import com.google.firebase.auth.PhoneAuthCredential;
    import com.google.firebase.auth.PhoneAuthProvider;
    import com.google.firebase.firestore.DocumentSnapshot;
    import com.google.firebase.firestore.FirebaseFirestore;
    import com.google.firebase.iid.FirebaseInstanceId;
    import com.google.firebase.perf.metrics.AddTrace;
    import com.hbb20.CountryCodePicker;
    import com.pmkmap.Modals.UserTokenModal;
    import com.pmkmap.R;
    import com.pmkmap.Utility;

    import java.util.Map;
    import java.util.concurrent.TimeUnit;

    public class NumberActivity extends AppCompatActivity implements View.OnClickListener {
    private static final String TAG = "PhoneAuthActivity";
    EditText enterNoEdt, enterOtpEdt;
    Button generateOpt, verifyOtp;
    TextView resendOtp;
    String mVerificationId, countryCode, countryName, mobileNo;
    CountryCodePicker countryCodePicker;
    private FirebaseAuth mAuth;
    private PhoneAuthProvider.ForceResendingToken mResendToken;
    private PhoneAuthProvider.OnVerificationStateChangedCallbacks mCallBacks;
    private FirebaseFirestore firestoreDB;
    private Tracker mTracker;

    public static void hideSoftKeyboard(Activity activity) {
    try {
    InputMethodManager inputMethodManager =
    (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
    inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
    } catch (Exception e) {
    e.printStackTrace();
    }
    }

    @AddTrace(name = "NumberInput_trace", enabled = true)
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_number);
    getSupportActionBar().hide();
    findID();
    clickListener();
    AnalyticsApplication application = (AnalyticsApplication) getApplication();
    mTracker = application.getDefaultTracker();
    mAuth = FirebaseAuth.getInstance();
    firestoreDB = FirebaseFirestore.getInstance();
    mCallBacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
    @Override
    public void onVerificationCompleted(PhoneAuthCredential phoneAuthCredential) {
    Log.e(TAG, "onVerificationCompleted:" + phoneAuthCredential);
    if (mVerificationId == null) {
    signInWithPhoneAuthCredential(phoneAuthCredential);
    }
    }

    @Override
    public void onVerificationFailed(FirebaseException e) {
    Log.e(TAG, "onVerificationFailed", e);
    Utility.hideProgressDialog();
    if (e instanceof FirebaseAuthInvalidCredentialsException) {
    enterNoEdt.setError("தவறான அலைபேசி எண் !");
    } else if (e instanceof FirebaseTooManyRequestsException) {
    Toast.makeText(NumberActivity.this, "Quota exceeded.", Toast.LENGTH_SHORT).show();
    }
    }

    @Override
    public void onCodeSent(String verificationId, PhoneAuthProvider.ForceResendingToken forceResendingToken) {
    Log.d(TAG, "onCodeSent:" + verificationId);
    Toast.makeText(NumberActivity.this, "உங்கள் அலைபேசி எண்ணிற்கு OTP வெற்றிகரமாக அனுப்பப்பட்டது", Toast.LENGTH_SHORT).show();
    mVerificationId = verificationId;
    mResendToken = forceResendingToken;
    Utility.hideProgressDialog();
    generateOpt.setVisibility(View.GONE);
    enterOtpEdt.setVisibility(View.VISIBLE);
    verifyOtp.setVisibility(View.VISIBLE);
    resendOtp.setVisibility(View.VISIBLE);
    }
    };

    }

    @Override
    protected void onResume() {
    super.onResume();
    mTracker.setScreenName("Image~" + "Mobile_Number_Input");
    mTracker.send(new HitBuilders.ScreenViewBuilder().build());
    }

    public void findID() {
    enterNoEdt = findViewById(R.id.enter_number);
    generateOpt = findViewById(R.id.generate_otp);
    verifyOtp = findViewById(R.id.verify);
    enterOtpEdt = findViewById(R.id.enter_otp);
    resendOtp = findViewById(R.id.resend_otp);

    countryCodePicker = findViewById(R.id.ccp);
    }

    private void signInWithPhoneAuthCredential(final PhoneAuthCredential credential) {
    mAuth.signInWithCredential(credential).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
    @RequiresApi(api = Build.VERSION_CODES.KITKAT)
    @Override
    public void onComplete(@NonNull Task<AuthResult> task) {
    if (task.isSuccessful()) {
    if (countryCode.equalsIgnoreCase("+91")) {
    getUsers();
    } else {
    getIntUsers();
    }

    } else {
    Log.w(TAG, "signInWithCredential:failure", task.getException());
    if (task.getException() instanceof FirebaseAuthInvalidCredentialsException) {
    Utility.hideProgressDialog();
    Toast.makeText(NumberActivity.this, task.getException().getMessage(), Toast.LENGTH_SHORT).show();
    enterOtpEdt.setError("Invalid code");
    }
    }
    }
    });
    }

    private void startPhoneNumberVerification(String phoneNumber) {
    PhoneAuthProvider.getInstance().verifyPhoneNumber(
    phoneNumber,
    30,
    TimeUnit.SECONDS,
    this,
    mCallBacks);
    }

    private void verifyPhoneNumberWithCode(String verificationId, String code) {
    PhoneAuthCredential credential = PhoneAuthProvider.getCredential(verificationId, code);
    signInWithPhoneAuthCredential(credential);
    }

    private void resendVerificationCode(String phoneNumber, PhoneAuthProvider.ForceResendingToken token) {
    PhoneAuthProvider.getInstance().verifyPhoneNumber(
    phoneNumber,
    30,
    TimeUnit.SECONDS,
    this,
    mCallBacks,
    token);
    }

    public void clickListener() {
    generateOpt.setOnClickListener(this);
    verifyOtp.setOnClickListener(this);
    resendOtp.setOnClickListener(this);
    }

    @AddTrace(name = "Number_trace", enabled = true)
    @Override
    public void onClick(View v) {
    if (v == generateOpt) {
    try {
    if (Utility.isNetworkAvailable(NumberActivity.this)) {
    if (enterNoEdt.getText().toString().equalsIgnoreCase("")) {
    Toast.makeText(this, "தாங்கள் அலைபேசி எண்ணை பதிவு செய்யவும்", Toast.LENGTH_SHORT).show();
    } else {
    hideSoftKeyboard(NumberActivity.this);
    Utility.showProgressDialog(NumberActivity.this);
    mobileNo = enterNoEdt.getText().toString();
    getCountryCode();
    startPhoneNumberVerification(countryCode + mobileNo);
    }
    } else {
    Toast.makeText(this, "தாங்கள் இணையதள இணைப்பை சரி பார்க்கவும்", Toast.LENGTH_SHORT).show();
    Utility.hideProgressDialog();
    }
    } catch (Exception e) {
    e.printStackTrace();
    Utility.hideProgressDialog();
    }
    }
    if (v == verifyOtp) {
    try {
    if (Utility.isNetworkAvailable(NumberActivity.this)) {

    if (enterOtpEdt.getText().toString().equalsIgnoreCase("")) {
    Toast.makeText(this, "OTP ஐ பதிவு செய்க", Toast.LENGTH_SHORT).show();
    } else {
    hideSoftKeyboard(NumberActivity.this);
    Utility.showProgressDialog(NumberActivity.this);
    verifyPhoneNumberWithCode(mVerificationId, enterOtpEdt.getText().toString());
    }

    } else {
    Toast.makeText(this, "தாங்கள் இணையதள இணைப்பை சரி பார்க்கவும்", Toast.LENGTH_SHORT).show();
    Utility.hideProgressDialog();
    }
    } catch (Exception e) {
    e.printStackTrace();
    Utility.hideProgressDialog();
    }
    }
    if (v == resendOtp) {
    try {
    if (Utility.isNetworkAvailable(NumberActivity.this)) {
    if (enterNoEdt.getText().toString().equalsIgnoreCase("")) {
    Toast.makeText(this, "தாங்கள் அலைபேசி எண்ணை பதிவு செய்யவும்", Toast.LENGTH_SHORT).show();
    } else {
    hideSoftKeyboard(NumberActivity.this);
    Utility.showProgressDialog(NumberActivity.this);
    mobileNo = enterNoEdt.getText().toString();
    getCountryCode();
    resendVerificationCode(countryCode + mobileNo, mResendToken);
    }
    } else {
    Toast.makeText(this, "தாங்கள் இணையதள இணைப்பை சரி பார்க்கவும்", Toast.LENGTH_SHORT).show();
    Utility.hideProgressDialog();
    }
    } catch (Exception e) {
    e.printStackTrace();
    Utility.hideProgressDialog();
    }
    }
    }

    private void getUsers() {
    firestoreDB.collection("users").document(countryCode + mobileNo).get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
    @Override
    public void onComplete(@NonNull Task<DocumentSnapshot> task) {
    try {
    if (task.isSuccessful()) {
    sendToken();
    DocumentSnapshot document = task.getResult();
    if (document.exists()) {
    Map<String, Object> array = document.getData();
    if (array.get("blocked").toString().equalsIgnoreCase("no")) {
    Log.e(">>>", array.toString());
    checkLoginStatus();
    getMyAccountDetailPref();
    Log.e(">>>>", document.getId());
    startActivity(new Intent(NumberActivity.this, HomeActivity.class));
    finish();
    } else {
    AlertDialog.Builder builder = new AlertDialog.Builder(NumberActivity.this);
    builder.setMessage("Your account is blocked by admin.")
    .setCancelable(false)
    .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {
    NumberActivity.this.finish();
    }
    });
    AlertDialog alert = builder.create();
    alert.show();
    }

    } else {
    gotoNextActivity();
    }
    } else {
    try {
    sendToken();
    gotoNextActivity();
    Log.d(TAG, "Error getting documents: ", task.getException());
    } catch (Exception e) {
    Toast.makeText(NumberActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
    e.printStackTrace();
    }
    }
    } catch (Exception e) {
    Toast.makeText(NumberActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
    e.printStackTrace();
    e.printStackTrace();
    }
    }

    }).addOnFailureListener(new OnFailureListener() {
    @Override
    public void onFailure(@NonNull Exception e) {
    Log.e(">>>", e.toString());
    }
    });
    }

    private void getIntUsers() {
    firestoreDB.collection("int_users").document(countryCode + mobileNo).get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
    @Override
    public void onComplete(@NonNull Task<DocumentSnapshot> task) {
    try {
    if (task.isSuccessful()) {
    sendToken();
    DocumentSnapshot document = task.getResult();
    if (document.exists()) {
    Map<String, Object> array = document.getData();
    if (array.get("blocked").toString().equalsIgnoreCase("no")) {
    Log.e(">>>", array.toString());
    checkLoginStatus();
    getMyAccountDetailPref();
    Log.e(">>>>", document.getId());
    startActivity(new Intent(NumberActivity.this, HomeActivity.class));
    finish();
    } else {
    AlertDialog.Builder builder = new AlertDialog.Builder(NumberActivity.this);
    builder.setMessage("Your account is blocked by admin.")
    .setCancelable(false)
    .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {
    NumberActivity.this.finish();
    }
    });
    AlertDialog alert = builder.create();
    alert.show();
    }

    } else {
    gotoNextActivity();
    }
    } else {
    try {
    sendToken();
    gotoNextActivity();
    Log.d(TAG, "Error getting documents: ", task.getException());
    } catch (Exception e) {
    Toast.makeText(NumberActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
    e.printStackTrace();
    }
    }
    } catch (Exception e) {
    Toast.makeText(NumberActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
    e.printStackTrace();
    e.printStackTrace();
    }
    }

    }).addOnFailureListener(new OnFailureListener() {
    @Override
    public void onFailure(@NonNull Exception e) {
    Log.e(">>>", e.toString());
    }
    });
    }

    public void gotoNextActivity() {
    if (countryCode.equalsIgnoreCase("+91")) {
    getMyAccountDetailPref();
    } else {
    getMyIntAccountDetailPref();
    }

    if (countryCode.equalsIgnoreCase("+91")) {
    startActivity(new Intent(NumberActivity.this, SaveInformationActivity.class).putExtra("mobile_no", countryCode + mobileNo));
    finish();
    } else {
    startActivity(new Intent(NumberActivity.this, IntSaveInformationActivity.class).putExtra("mobile_no", countryCode + mobileNo)
    .putExtra("countryName", countryName));
    finish();
    }

    }

    public void checkLoginStatus() {
    SharedPreferences settings = getSharedPreferences(SaveInformationActivity.PREFS_NAME, 0);
    SharedPreferences.Editor editor = settings.edit();
    editor.putBoolean("hasLoggedIn", true);
    editor.commit();
    }

    public void getMyAccountDetailPref() {
    SharedPreferences.Editor editor = getSharedPreferences("mobile_no", MODE_PRIVATE).edit();
    editor.putString("user_mobile", countryCode + mobileNo);
    editor.apply();
    }

    public void getMyIntAccountDetailPref() {
    SharedPreferences.Editor editor = getSharedPreferences("mobile_no", MODE_PRIVATE).edit();
    editor.putString("user_mobile", countryCode + mobileNo);
    editor.apply();
    }

    public void getCountryCode() {
    countryCode = countryCodePicker.getFullNumberWithPlus();
    countryName = countryCodePicker.getSelectedCountryName();
    }

    public void sendToken() {
    try {
    String token = FirebaseInstanceId.getInstance().getToken();
    SharedPreferences.Editor editor = getSharedPreferences("user_token", MODE_PRIVATE).edit();
    editor.putString("token", token);
    editor.apply();
    UserTokenModal userTokenModal = new UserTokenModal(token);
    firestoreDB.collection("userToken").document(countryCode + mobileNo).set(userTokenModal).addOnSuccessListener(new OnSuccessListener<Void>() {
    @Override
    public void onSuccess(Void documentReference) {
    try {
    Log.e(">>>>", "token sent succefully");

    } catch (Exception e) {
    e.printStackTrace();
    }

    }
    }).addOnFailureListener(new OnFailureListener() {
    @Override
    public void onFailure(@NonNull Exception e) {
    Log.w(">>>", "Error adding event document", e);
    Toast.makeText(NumberActivity.this,
    e.getMessage(),
    Toast.LENGTH_SHORT).show();
    Utility.hideProgressDialog();
    }
    });
    } catch (Exception e) {
    e.printStackTrace();
    }
    }
    }









    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I am from India, am working on an android app, In this the Indian mobile numbers are successfully getting OTP from the firebase where the international mobile numbers that are used in physical devices in their respective countries are not getting OTP. I have tried using the international dummy numbers from this portal online sms OTP portal are getting OTP through online except United states numbers, but the OTP not receiving for international numbers in their physical devices.
      I have followed the steps from the firebase Documentation but it didn't help me.



      Thanks in advance



      activity_number.xml



      <?xml version="1.0" encoding="utf-8"?>
      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"
      tools:context="com.pmkmap.Activities.NumberActivity">


      <LinearLayout
      android:id="@+id/number_layout"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:orientation="vertical">

      <ImageView
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:adjustViewBounds="true"
      android:src="@drawable/pmk_background_pic" />

      <TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_gravity="center"
      android:layout_marginTop="10dp"
      android:text="PMK"
      android:textColor="@color/blue"
      android:textSize="15sp"
      android:textStyle="bold"
      android:visibility="gone" />


      <LinearLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="horizontal">

      <com.hbb20.CountryCodePicker
      android:id="@+id/ccp"
      android:layout_width="130dp"
      android:layout_height="wrap_content"
      android:layout_marginLeft="20dp"
      android:layout_marginTop="40dp" />

      <EditText
      android:id="@+id/enter_number"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_marginRight="20dp"
      android:layout_marginTop="40dp"
      android:digits="0123456789"
      android:hint="@string/enter_your_no"
      android:inputType="phone"
      android:textSize="15dp" />
      </LinearLayout>

      <Button
      android:id="@+id/generate_otp"
      android:layout_width="150dp"
      android:layout_height="wrap_content"
      android:layout_gravity="center"
      android:layout_marginTop="20dp"
      android:background="@drawable/button_background"
      android:text="@string/genrate_otp"
      android:textColor="@color/white" />


      <EditText
      android:id="@+id/enter_otp"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_marginLeft="60dp"
      android:layout_marginRight="30dp"
      android:layout_marginTop="20dp"
      android:hint="@string/enterur_otp"
      android:inputType="numberPassword"
      android:maxLength="6"
      android:visibility="gone" />

      <Button
      android:id="@+id/verify"
      android:layout_width="150dp"
      android:layout_height="wrap_content"
      android:layout_gravity="center"
      android:layout_marginTop="20dp"
      android:background="@drawable/button_background"
      android:text="@string/verify"
      android:textColor="@color/white"
      android:visibility="gone" />

      <TextView
      android:id="@+id/resend_otp"
      android:layout_width="150dp"
      android:layout_height="wrap_content"
      android:layout_gravity="center"
      android:layout_marginTop="5dp"
      android:gravity="center"
      android:text="@string/resend_otp"
      android:textColor="@color/blue"
      android:visibility="gone" />

      </LinearLayout>

      </LinearLayout>


      NumberActivity.java



      package com.pmkmap.Activities;

      import android.app.Activity;
      import android.content.DialogInterface;
      import android.content.Intent;
      import android.content.SharedPreferences;
      import android.os.Build;
      import android.os.Bundle;
      import android.support.annotation.NonNull;
      import android.support.annotation.RequiresApi;
      import android.support.v7.app.AlertDialog;
      import android.support.v7.app.AppCompatActivity;
      import android.util.Log;
      import android.view.View;
      import android.view.inputmethod.InputMethodManager;
      import android.widget.Button;
      import android.widget.EditText;
      import android.widget.TextView;
      import android.widget.Toast;

      import com.google.android.gms.analytics.HitBuilders;
      import com.google.android.gms.analytics.Tracker;
      import com.google.android.gms.tasks.OnCompleteListener;
      import com.google.android.gms.tasks.OnFailureListener;
      import com.google.android.gms.tasks.OnSuccessListener;
      import com.google.android.gms.tasks.Task;
      import com.google.firebase.FirebaseException;
      import com.google.firebase.FirebaseTooManyRequestsException;
      import com.google.firebase.auth.AuthResult;
      import com.google.firebase.auth.FirebaseAuth;
      import com.google.firebase.auth.FirebaseAuthInvalidCredentialsException;
      import com.google.firebase.auth.PhoneAuthCredential;
      import com.google.firebase.auth.PhoneAuthProvider;
      import com.google.firebase.firestore.DocumentSnapshot;
      import com.google.firebase.firestore.FirebaseFirestore;
      import com.google.firebase.iid.FirebaseInstanceId;
      import com.google.firebase.perf.metrics.AddTrace;
      import com.hbb20.CountryCodePicker;
      import com.pmkmap.Modals.UserTokenModal;
      import com.pmkmap.R;
      import com.pmkmap.Utility;

      import java.util.Map;
      import java.util.concurrent.TimeUnit;

      public class NumberActivity extends AppCompatActivity implements View.OnClickListener {
      private static final String TAG = "PhoneAuthActivity";
      EditText enterNoEdt, enterOtpEdt;
      Button generateOpt, verifyOtp;
      TextView resendOtp;
      String mVerificationId, countryCode, countryName, mobileNo;
      CountryCodePicker countryCodePicker;
      private FirebaseAuth mAuth;
      private PhoneAuthProvider.ForceResendingToken mResendToken;
      private PhoneAuthProvider.OnVerificationStateChangedCallbacks mCallBacks;
      private FirebaseFirestore firestoreDB;
      private Tracker mTracker;

      public static void hideSoftKeyboard(Activity activity) {
      try {
      InputMethodManager inputMethodManager =
      (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
      inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
      } catch (Exception e) {
      e.printStackTrace();
      }
      }

      @AddTrace(name = "NumberInput_trace", enabled = true)
      @Override
      protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_number);
      getSupportActionBar().hide();
      findID();
      clickListener();
      AnalyticsApplication application = (AnalyticsApplication) getApplication();
      mTracker = application.getDefaultTracker();
      mAuth = FirebaseAuth.getInstance();
      firestoreDB = FirebaseFirestore.getInstance();
      mCallBacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
      @Override
      public void onVerificationCompleted(PhoneAuthCredential phoneAuthCredential) {
      Log.e(TAG, "onVerificationCompleted:" + phoneAuthCredential);
      if (mVerificationId == null) {
      signInWithPhoneAuthCredential(phoneAuthCredential);
      }
      }

      @Override
      public void onVerificationFailed(FirebaseException e) {
      Log.e(TAG, "onVerificationFailed", e);
      Utility.hideProgressDialog();
      if (e instanceof FirebaseAuthInvalidCredentialsException) {
      enterNoEdt.setError("தவறான அலைபேசி எண் !");
      } else if (e instanceof FirebaseTooManyRequestsException) {
      Toast.makeText(NumberActivity.this, "Quota exceeded.", Toast.LENGTH_SHORT).show();
      }
      }

      @Override
      public void onCodeSent(String verificationId, PhoneAuthProvider.ForceResendingToken forceResendingToken) {
      Log.d(TAG, "onCodeSent:" + verificationId);
      Toast.makeText(NumberActivity.this, "உங்கள் அலைபேசி எண்ணிற்கு OTP வெற்றிகரமாக அனுப்பப்பட்டது", Toast.LENGTH_SHORT).show();
      mVerificationId = verificationId;
      mResendToken = forceResendingToken;
      Utility.hideProgressDialog();
      generateOpt.setVisibility(View.GONE);
      enterOtpEdt.setVisibility(View.VISIBLE);
      verifyOtp.setVisibility(View.VISIBLE);
      resendOtp.setVisibility(View.VISIBLE);
      }
      };

      }

      @Override
      protected void onResume() {
      super.onResume();
      mTracker.setScreenName("Image~" + "Mobile_Number_Input");
      mTracker.send(new HitBuilders.ScreenViewBuilder().build());
      }

      public void findID() {
      enterNoEdt = findViewById(R.id.enter_number);
      generateOpt = findViewById(R.id.generate_otp);
      verifyOtp = findViewById(R.id.verify);
      enterOtpEdt = findViewById(R.id.enter_otp);
      resendOtp = findViewById(R.id.resend_otp);

      countryCodePicker = findViewById(R.id.ccp);
      }

      private void signInWithPhoneAuthCredential(final PhoneAuthCredential credential) {
      mAuth.signInWithCredential(credential).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
      @RequiresApi(api = Build.VERSION_CODES.KITKAT)
      @Override
      public void onComplete(@NonNull Task<AuthResult> task) {
      if (task.isSuccessful()) {
      if (countryCode.equalsIgnoreCase("+91")) {
      getUsers();
      } else {
      getIntUsers();
      }

      } else {
      Log.w(TAG, "signInWithCredential:failure", task.getException());
      if (task.getException() instanceof FirebaseAuthInvalidCredentialsException) {
      Utility.hideProgressDialog();
      Toast.makeText(NumberActivity.this, task.getException().getMessage(), Toast.LENGTH_SHORT).show();
      enterOtpEdt.setError("Invalid code");
      }
      }
      }
      });
      }

      private void startPhoneNumberVerification(String phoneNumber) {
      PhoneAuthProvider.getInstance().verifyPhoneNumber(
      phoneNumber,
      30,
      TimeUnit.SECONDS,
      this,
      mCallBacks);
      }

      private void verifyPhoneNumberWithCode(String verificationId, String code) {
      PhoneAuthCredential credential = PhoneAuthProvider.getCredential(verificationId, code);
      signInWithPhoneAuthCredential(credential);
      }

      private void resendVerificationCode(String phoneNumber, PhoneAuthProvider.ForceResendingToken token) {
      PhoneAuthProvider.getInstance().verifyPhoneNumber(
      phoneNumber,
      30,
      TimeUnit.SECONDS,
      this,
      mCallBacks,
      token);
      }

      public void clickListener() {
      generateOpt.setOnClickListener(this);
      verifyOtp.setOnClickListener(this);
      resendOtp.setOnClickListener(this);
      }

      @AddTrace(name = "Number_trace", enabled = true)
      @Override
      public void onClick(View v) {
      if (v == generateOpt) {
      try {
      if (Utility.isNetworkAvailable(NumberActivity.this)) {
      if (enterNoEdt.getText().toString().equalsIgnoreCase("")) {
      Toast.makeText(this, "தாங்கள் அலைபேசி எண்ணை பதிவு செய்யவும்", Toast.LENGTH_SHORT).show();
      } else {
      hideSoftKeyboard(NumberActivity.this);
      Utility.showProgressDialog(NumberActivity.this);
      mobileNo = enterNoEdt.getText().toString();
      getCountryCode();
      startPhoneNumberVerification(countryCode + mobileNo);
      }
      } else {
      Toast.makeText(this, "தாங்கள் இணையதள இணைப்பை சரி பார்க்கவும்", Toast.LENGTH_SHORT).show();
      Utility.hideProgressDialog();
      }
      } catch (Exception e) {
      e.printStackTrace();
      Utility.hideProgressDialog();
      }
      }
      if (v == verifyOtp) {
      try {
      if (Utility.isNetworkAvailable(NumberActivity.this)) {

      if (enterOtpEdt.getText().toString().equalsIgnoreCase("")) {
      Toast.makeText(this, "OTP ஐ பதிவு செய்க", Toast.LENGTH_SHORT).show();
      } else {
      hideSoftKeyboard(NumberActivity.this);
      Utility.showProgressDialog(NumberActivity.this);
      verifyPhoneNumberWithCode(mVerificationId, enterOtpEdt.getText().toString());
      }

      } else {
      Toast.makeText(this, "தாங்கள் இணையதள இணைப்பை சரி பார்க்கவும்", Toast.LENGTH_SHORT).show();
      Utility.hideProgressDialog();
      }
      } catch (Exception e) {
      e.printStackTrace();
      Utility.hideProgressDialog();
      }
      }
      if (v == resendOtp) {
      try {
      if (Utility.isNetworkAvailable(NumberActivity.this)) {
      if (enterNoEdt.getText().toString().equalsIgnoreCase("")) {
      Toast.makeText(this, "தாங்கள் அலைபேசி எண்ணை பதிவு செய்யவும்", Toast.LENGTH_SHORT).show();
      } else {
      hideSoftKeyboard(NumberActivity.this);
      Utility.showProgressDialog(NumberActivity.this);
      mobileNo = enterNoEdt.getText().toString();
      getCountryCode();
      resendVerificationCode(countryCode + mobileNo, mResendToken);
      }
      } else {
      Toast.makeText(this, "தாங்கள் இணையதள இணைப்பை சரி பார்க்கவும்", Toast.LENGTH_SHORT).show();
      Utility.hideProgressDialog();
      }
      } catch (Exception e) {
      e.printStackTrace();
      Utility.hideProgressDialog();
      }
      }
      }

      private void getUsers() {
      firestoreDB.collection("users").document(countryCode + mobileNo).get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
      @Override
      public void onComplete(@NonNull Task<DocumentSnapshot> task) {
      try {
      if (task.isSuccessful()) {
      sendToken();
      DocumentSnapshot document = task.getResult();
      if (document.exists()) {
      Map<String, Object> array = document.getData();
      if (array.get("blocked").toString().equalsIgnoreCase("no")) {
      Log.e(">>>", array.toString());
      checkLoginStatus();
      getMyAccountDetailPref();
      Log.e(">>>>", document.getId());
      startActivity(new Intent(NumberActivity.this, HomeActivity.class));
      finish();
      } else {
      AlertDialog.Builder builder = new AlertDialog.Builder(NumberActivity.this);
      builder.setMessage("Your account is blocked by admin.")
      .setCancelable(false)
      .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
      @Override
      public void onClick(DialogInterface dialog, int which) {
      NumberActivity.this.finish();
      }
      });
      AlertDialog alert = builder.create();
      alert.show();
      }

      } else {
      gotoNextActivity();
      }
      } else {
      try {
      sendToken();
      gotoNextActivity();
      Log.d(TAG, "Error getting documents: ", task.getException());
      } catch (Exception e) {
      Toast.makeText(NumberActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
      e.printStackTrace();
      }
      }
      } catch (Exception e) {
      Toast.makeText(NumberActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
      e.printStackTrace();
      e.printStackTrace();
      }
      }

      }).addOnFailureListener(new OnFailureListener() {
      @Override
      public void onFailure(@NonNull Exception e) {
      Log.e(">>>", e.toString());
      }
      });
      }

      private void getIntUsers() {
      firestoreDB.collection("int_users").document(countryCode + mobileNo).get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
      @Override
      public void onComplete(@NonNull Task<DocumentSnapshot> task) {
      try {
      if (task.isSuccessful()) {
      sendToken();
      DocumentSnapshot document = task.getResult();
      if (document.exists()) {
      Map<String, Object> array = document.getData();
      if (array.get("blocked").toString().equalsIgnoreCase("no")) {
      Log.e(">>>", array.toString());
      checkLoginStatus();
      getMyAccountDetailPref();
      Log.e(">>>>", document.getId());
      startActivity(new Intent(NumberActivity.this, HomeActivity.class));
      finish();
      } else {
      AlertDialog.Builder builder = new AlertDialog.Builder(NumberActivity.this);
      builder.setMessage("Your account is blocked by admin.")
      .setCancelable(false)
      .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
      @Override
      public void onClick(DialogInterface dialog, int which) {
      NumberActivity.this.finish();
      }
      });
      AlertDialog alert = builder.create();
      alert.show();
      }

      } else {
      gotoNextActivity();
      }
      } else {
      try {
      sendToken();
      gotoNextActivity();
      Log.d(TAG, "Error getting documents: ", task.getException());
      } catch (Exception e) {
      Toast.makeText(NumberActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
      e.printStackTrace();
      }
      }
      } catch (Exception e) {
      Toast.makeText(NumberActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
      e.printStackTrace();
      e.printStackTrace();
      }
      }

      }).addOnFailureListener(new OnFailureListener() {
      @Override
      public void onFailure(@NonNull Exception e) {
      Log.e(">>>", e.toString());
      }
      });
      }

      public void gotoNextActivity() {
      if (countryCode.equalsIgnoreCase("+91")) {
      getMyAccountDetailPref();
      } else {
      getMyIntAccountDetailPref();
      }

      if (countryCode.equalsIgnoreCase("+91")) {
      startActivity(new Intent(NumberActivity.this, SaveInformationActivity.class).putExtra("mobile_no", countryCode + mobileNo));
      finish();
      } else {
      startActivity(new Intent(NumberActivity.this, IntSaveInformationActivity.class).putExtra("mobile_no", countryCode + mobileNo)
      .putExtra("countryName", countryName));
      finish();
      }

      }

      public void checkLoginStatus() {
      SharedPreferences settings = getSharedPreferences(SaveInformationActivity.PREFS_NAME, 0);
      SharedPreferences.Editor editor = settings.edit();
      editor.putBoolean("hasLoggedIn", true);
      editor.commit();
      }

      public void getMyAccountDetailPref() {
      SharedPreferences.Editor editor = getSharedPreferences("mobile_no", MODE_PRIVATE).edit();
      editor.putString("user_mobile", countryCode + mobileNo);
      editor.apply();
      }

      public void getMyIntAccountDetailPref() {
      SharedPreferences.Editor editor = getSharedPreferences("mobile_no", MODE_PRIVATE).edit();
      editor.putString("user_mobile", countryCode + mobileNo);
      editor.apply();
      }

      public void getCountryCode() {
      countryCode = countryCodePicker.getFullNumberWithPlus();
      countryName = countryCodePicker.getSelectedCountryName();
      }

      public void sendToken() {
      try {
      String token = FirebaseInstanceId.getInstance().getToken();
      SharedPreferences.Editor editor = getSharedPreferences("user_token", MODE_PRIVATE).edit();
      editor.putString("token", token);
      editor.apply();
      UserTokenModal userTokenModal = new UserTokenModal(token);
      firestoreDB.collection("userToken").document(countryCode + mobileNo).set(userTokenModal).addOnSuccessListener(new OnSuccessListener<Void>() {
      @Override
      public void onSuccess(Void documentReference) {
      try {
      Log.e(">>>>", "token sent succefully");

      } catch (Exception e) {
      e.printStackTrace();
      }

      }
      }).addOnFailureListener(new OnFailureListener() {
      @Override
      public void onFailure(@NonNull Exception e) {
      Log.w(">>>", "Error adding event document", e);
      Toast.makeText(NumberActivity.this,
      e.getMessage(),
      Toast.LENGTH_SHORT).show();
      Utility.hideProgressDialog();
      }
      });
      } catch (Exception e) {
      e.printStackTrace();
      }
      }
      }









      share|improve this question















      I am from India, am working on an android app, In this the Indian mobile numbers are successfully getting OTP from the firebase where the international mobile numbers that are used in physical devices in their respective countries are not getting OTP. I have tried using the international dummy numbers from this portal online sms OTP portal are getting OTP through online except United states numbers, but the OTP not receiving for international numbers in their physical devices.
      I have followed the steps from the firebase Documentation but it didn't help me.



      Thanks in advance



      activity_number.xml



      <?xml version="1.0" encoding="utf-8"?>
      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"
      tools:context="com.pmkmap.Activities.NumberActivity">


      <LinearLayout
      android:id="@+id/number_layout"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:orientation="vertical">

      <ImageView
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:adjustViewBounds="true"
      android:src="@drawable/pmk_background_pic" />

      <TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_gravity="center"
      android:layout_marginTop="10dp"
      android:text="PMK"
      android:textColor="@color/blue"
      android:textSize="15sp"
      android:textStyle="bold"
      android:visibility="gone" />


      <LinearLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="horizontal">

      <com.hbb20.CountryCodePicker
      android:id="@+id/ccp"
      android:layout_width="130dp"
      android:layout_height="wrap_content"
      android:layout_marginLeft="20dp"
      android:layout_marginTop="40dp" />

      <EditText
      android:id="@+id/enter_number"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_marginRight="20dp"
      android:layout_marginTop="40dp"
      android:digits="0123456789"
      android:hint="@string/enter_your_no"
      android:inputType="phone"
      android:textSize="15dp" />
      </LinearLayout>

      <Button
      android:id="@+id/generate_otp"
      android:layout_width="150dp"
      android:layout_height="wrap_content"
      android:layout_gravity="center"
      android:layout_marginTop="20dp"
      android:background="@drawable/button_background"
      android:text="@string/genrate_otp"
      android:textColor="@color/white" />


      <EditText
      android:id="@+id/enter_otp"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_marginLeft="60dp"
      android:layout_marginRight="30dp"
      android:layout_marginTop="20dp"
      android:hint="@string/enterur_otp"
      android:inputType="numberPassword"
      android:maxLength="6"
      android:visibility="gone" />

      <Button
      android:id="@+id/verify"
      android:layout_width="150dp"
      android:layout_height="wrap_content"
      android:layout_gravity="center"
      android:layout_marginTop="20dp"
      android:background="@drawable/button_background"
      android:text="@string/verify"
      android:textColor="@color/white"
      android:visibility="gone" />

      <TextView
      android:id="@+id/resend_otp"
      android:layout_width="150dp"
      android:layout_height="wrap_content"
      android:layout_gravity="center"
      android:layout_marginTop="5dp"
      android:gravity="center"
      android:text="@string/resend_otp"
      android:textColor="@color/blue"
      android:visibility="gone" />

      </LinearLayout>

      </LinearLayout>


      NumberActivity.java



      package com.pmkmap.Activities;

      import android.app.Activity;
      import android.content.DialogInterface;
      import android.content.Intent;
      import android.content.SharedPreferences;
      import android.os.Build;
      import android.os.Bundle;
      import android.support.annotation.NonNull;
      import android.support.annotation.RequiresApi;
      import android.support.v7.app.AlertDialog;
      import android.support.v7.app.AppCompatActivity;
      import android.util.Log;
      import android.view.View;
      import android.view.inputmethod.InputMethodManager;
      import android.widget.Button;
      import android.widget.EditText;
      import android.widget.TextView;
      import android.widget.Toast;

      import com.google.android.gms.analytics.HitBuilders;
      import com.google.android.gms.analytics.Tracker;
      import com.google.android.gms.tasks.OnCompleteListener;
      import com.google.android.gms.tasks.OnFailureListener;
      import com.google.android.gms.tasks.OnSuccessListener;
      import com.google.android.gms.tasks.Task;
      import com.google.firebase.FirebaseException;
      import com.google.firebase.FirebaseTooManyRequestsException;
      import com.google.firebase.auth.AuthResult;
      import com.google.firebase.auth.FirebaseAuth;
      import com.google.firebase.auth.FirebaseAuthInvalidCredentialsException;
      import com.google.firebase.auth.PhoneAuthCredential;
      import com.google.firebase.auth.PhoneAuthProvider;
      import com.google.firebase.firestore.DocumentSnapshot;
      import com.google.firebase.firestore.FirebaseFirestore;
      import com.google.firebase.iid.FirebaseInstanceId;
      import com.google.firebase.perf.metrics.AddTrace;
      import com.hbb20.CountryCodePicker;
      import com.pmkmap.Modals.UserTokenModal;
      import com.pmkmap.R;
      import com.pmkmap.Utility;

      import java.util.Map;
      import java.util.concurrent.TimeUnit;

      public class NumberActivity extends AppCompatActivity implements View.OnClickListener {
      private static final String TAG = "PhoneAuthActivity";
      EditText enterNoEdt, enterOtpEdt;
      Button generateOpt, verifyOtp;
      TextView resendOtp;
      String mVerificationId, countryCode, countryName, mobileNo;
      CountryCodePicker countryCodePicker;
      private FirebaseAuth mAuth;
      private PhoneAuthProvider.ForceResendingToken mResendToken;
      private PhoneAuthProvider.OnVerificationStateChangedCallbacks mCallBacks;
      private FirebaseFirestore firestoreDB;
      private Tracker mTracker;

      public static void hideSoftKeyboard(Activity activity) {
      try {
      InputMethodManager inputMethodManager =
      (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
      inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
      } catch (Exception e) {
      e.printStackTrace();
      }
      }

      @AddTrace(name = "NumberInput_trace", enabled = true)
      @Override
      protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_number);
      getSupportActionBar().hide();
      findID();
      clickListener();
      AnalyticsApplication application = (AnalyticsApplication) getApplication();
      mTracker = application.getDefaultTracker();
      mAuth = FirebaseAuth.getInstance();
      firestoreDB = FirebaseFirestore.getInstance();
      mCallBacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
      @Override
      public void onVerificationCompleted(PhoneAuthCredential phoneAuthCredential) {
      Log.e(TAG, "onVerificationCompleted:" + phoneAuthCredential);
      if (mVerificationId == null) {
      signInWithPhoneAuthCredential(phoneAuthCredential);
      }
      }

      @Override
      public void onVerificationFailed(FirebaseException e) {
      Log.e(TAG, "onVerificationFailed", e);
      Utility.hideProgressDialog();
      if (e instanceof FirebaseAuthInvalidCredentialsException) {
      enterNoEdt.setError("தவறான அலைபேசி எண் !");
      } else if (e instanceof FirebaseTooManyRequestsException) {
      Toast.makeText(NumberActivity.this, "Quota exceeded.", Toast.LENGTH_SHORT).show();
      }
      }

      @Override
      public void onCodeSent(String verificationId, PhoneAuthProvider.ForceResendingToken forceResendingToken) {
      Log.d(TAG, "onCodeSent:" + verificationId);
      Toast.makeText(NumberActivity.this, "உங்கள் அலைபேசி எண்ணிற்கு OTP வெற்றிகரமாக அனுப்பப்பட்டது", Toast.LENGTH_SHORT).show();
      mVerificationId = verificationId;
      mResendToken = forceResendingToken;
      Utility.hideProgressDialog();
      generateOpt.setVisibility(View.GONE);
      enterOtpEdt.setVisibility(View.VISIBLE);
      verifyOtp.setVisibility(View.VISIBLE);
      resendOtp.setVisibility(View.VISIBLE);
      }
      };

      }

      @Override
      protected void onResume() {
      super.onResume();
      mTracker.setScreenName("Image~" + "Mobile_Number_Input");
      mTracker.send(new HitBuilders.ScreenViewBuilder().build());
      }

      public void findID() {
      enterNoEdt = findViewById(R.id.enter_number);
      generateOpt = findViewById(R.id.generate_otp);
      verifyOtp = findViewById(R.id.verify);
      enterOtpEdt = findViewById(R.id.enter_otp);
      resendOtp = findViewById(R.id.resend_otp);

      countryCodePicker = findViewById(R.id.ccp);
      }

      private void signInWithPhoneAuthCredential(final PhoneAuthCredential credential) {
      mAuth.signInWithCredential(credential).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
      @RequiresApi(api = Build.VERSION_CODES.KITKAT)
      @Override
      public void onComplete(@NonNull Task<AuthResult> task) {
      if (task.isSuccessful()) {
      if (countryCode.equalsIgnoreCase("+91")) {
      getUsers();
      } else {
      getIntUsers();
      }

      } else {
      Log.w(TAG, "signInWithCredential:failure", task.getException());
      if (task.getException() instanceof FirebaseAuthInvalidCredentialsException) {
      Utility.hideProgressDialog();
      Toast.makeText(NumberActivity.this, task.getException().getMessage(), Toast.LENGTH_SHORT).show();
      enterOtpEdt.setError("Invalid code");
      }
      }
      }
      });
      }

      private void startPhoneNumberVerification(String phoneNumber) {
      PhoneAuthProvider.getInstance().verifyPhoneNumber(
      phoneNumber,
      30,
      TimeUnit.SECONDS,
      this,
      mCallBacks);
      }

      private void verifyPhoneNumberWithCode(String verificationId, String code) {
      PhoneAuthCredential credential = PhoneAuthProvider.getCredential(verificationId, code);
      signInWithPhoneAuthCredential(credential);
      }

      private void resendVerificationCode(String phoneNumber, PhoneAuthProvider.ForceResendingToken token) {
      PhoneAuthProvider.getInstance().verifyPhoneNumber(
      phoneNumber,
      30,
      TimeUnit.SECONDS,
      this,
      mCallBacks,
      token);
      }

      public void clickListener() {
      generateOpt.setOnClickListener(this);
      verifyOtp.setOnClickListener(this);
      resendOtp.setOnClickListener(this);
      }

      @AddTrace(name = "Number_trace", enabled = true)
      @Override
      public void onClick(View v) {
      if (v == generateOpt) {
      try {
      if (Utility.isNetworkAvailable(NumberActivity.this)) {
      if (enterNoEdt.getText().toString().equalsIgnoreCase("")) {
      Toast.makeText(this, "தாங்கள் அலைபேசி எண்ணை பதிவு செய்யவும்", Toast.LENGTH_SHORT).show();
      } else {
      hideSoftKeyboard(NumberActivity.this);
      Utility.showProgressDialog(NumberActivity.this);
      mobileNo = enterNoEdt.getText().toString();
      getCountryCode();
      startPhoneNumberVerification(countryCode + mobileNo);
      }
      } else {
      Toast.makeText(this, "தாங்கள் இணையதள இணைப்பை சரி பார்க்கவும்", Toast.LENGTH_SHORT).show();
      Utility.hideProgressDialog();
      }
      } catch (Exception e) {
      e.printStackTrace();
      Utility.hideProgressDialog();
      }
      }
      if (v == verifyOtp) {
      try {
      if (Utility.isNetworkAvailable(NumberActivity.this)) {

      if (enterOtpEdt.getText().toString().equalsIgnoreCase("")) {
      Toast.makeText(this, "OTP ஐ பதிவு செய்க", Toast.LENGTH_SHORT).show();
      } else {
      hideSoftKeyboard(NumberActivity.this);
      Utility.showProgressDialog(NumberActivity.this);
      verifyPhoneNumberWithCode(mVerificationId, enterOtpEdt.getText().toString());
      }

      } else {
      Toast.makeText(this, "தாங்கள் இணையதள இணைப்பை சரி பார்க்கவும்", Toast.LENGTH_SHORT).show();
      Utility.hideProgressDialog();
      }
      } catch (Exception e) {
      e.printStackTrace();
      Utility.hideProgressDialog();
      }
      }
      if (v == resendOtp) {
      try {
      if (Utility.isNetworkAvailable(NumberActivity.this)) {
      if (enterNoEdt.getText().toString().equalsIgnoreCase("")) {
      Toast.makeText(this, "தாங்கள் அலைபேசி எண்ணை பதிவு செய்யவும்", Toast.LENGTH_SHORT).show();
      } else {
      hideSoftKeyboard(NumberActivity.this);
      Utility.showProgressDialog(NumberActivity.this);
      mobileNo = enterNoEdt.getText().toString();
      getCountryCode();
      resendVerificationCode(countryCode + mobileNo, mResendToken);
      }
      } else {
      Toast.makeText(this, "தாங்கள் இணையதள இணைப்பை சரி பார்க்கவும்", Toast.LENGTH_SHORT).show();
      Utility.hideProgressDialog();
      }
      } catch (Exception e) {
      e.printStackTrace();
      Utility.hideProgressDialog();
      }
      }
      }

      private void getUsers() {
      firestoreDB.collection("users").document(countryCode + mobileNo).get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
      @Override
      public void onComplete(@NonNull Task<DocumentSnapshot> task) {
      try {
      if (task.isSuccessful()) {
      sendToken();
      DocumentSnapshot document = task.getResult();
      if (document.exists()) {
      Map<String, Object> array = document.getData();
      if (array.get("blocked").toString().equalsIgnoreCase("no")) {
      Log.e(">>>", array.toString());
      checkLoginStatus();
      getMyAccountDetailPref();
      Log.e(">>>>", document.getId());
      startActivity(new Intent(NumberActivity.this, HomeActivity.class));
      finish();
      } else {
      AlertDialog.Builder builder = new AlertDialog.Builder(NumberActivity.this);
      builder.setMessage("Your account is blocked by admin.")
      .setCancelable(false)
      .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
      @Override
      public void onClick(DialogInterface dialog, int which) {
      NumberActivity.this.finish();
      }
      });
      AlertDialog alert = builder.create();
      alert.show();
      }

      } else {
      gotoNextActivity();
      }
      } else {
      try {
      sendToken();
      gotoNextActivity();
      Log.d(TAG, "Error getting documents: ", task.getException());
      } catch (Exception e) {
      Toast.makeText(NumberActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
      e.printStackTrace();
      }
      }
      } catch (Exception e) {
      Toast.makeText(NumberActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
      e.printStackTrace();
      e.printStackTrace();
      }
      }

      }).addOnFailureListener(new OnFailureListener() {
      @Override
      public void onFailure(@NonNull Exception e) {
      Log.e(">>>", e.toString());
      }
      });
      }

      private void getIntUsers() {
      firestoreDB.collection("int_users").document(countryCode + mobileNo).get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
      @Override
      public void onComplete(@NonNull Task<DocumentSnapshot> task) {
      try {
      if (task.isSuccessful()) {
      sendToken();
      DocumentSnapshot document = task.getResult();
      if (document.exists()) {
      Map<String, Object> array = document.getData();
      if (array.get("blocked").toString().equalsIgnoreCase("no")) {
      Log.e(">>>", array.toString());
      checkLoginStatus();
      getMyAccountDetailPref();
      Log.e(">>>>", document.getId());
      startActivity(new Intent(NumberActivity.this, HomeActivity.class));
      finish();
      } else {
      AlertDialog.Builder builder = new AlertDialog.Builder(NumberActivity.this);
      builder.setMessage("Your account is blocked by admin.")
      .setCancelable(false)
      .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
      @Override
      public void onClick(DialogInterface dialog, int which) {
      NumberActivity.this.finish();
      }
      });
      AlertDialog alert = builder.create();
      alert.show();
      }

      } else {
      gotoNextActivity();
      }
      } else {
      try {
      sendToken();
      gotoNextActivity();
      Log.d(TAG, "Error getting documents: ", task.getException());
      } catch (Exception e) {
      Toast.makeText(NumberActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
      e.printStackTrace();
      }
      }
      } catch (Exception e) {
      Toast.makeText(NumberActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
      e.printStackTrace();
      e.printStackTrace();
      }
      }

      }).addOnFailureListener(new OnFailureListener() {
      @Override
      public void onFailure(@NonNull Exception e) {
      Log.e(">>>", e.toString());
      }
      });
      }

      public void gotoNextActivity() {
      if (countryCode.equalsIgnoreCase("+91")) {
      getMyAccountDetailPref();
      } else {
      getMyIntAccountDetailPref();
      }

      if (countryCode.equalsIgnoreCase("+91")) {
      startActivity(new Intent(NumberActivity.this, SaveInformationActivity.class).putExtra("mobile_no", countryCode + mobileNo));
      finish();
      } else {
      startActivity(new Intent(NumberActivity.this, IntSaveInformationActivity.class).putExtra("mobile_no", countryCode + mobileNo)
      .putExtra("countryName", countryName));
      finish();
      }

      }

      public void checkLoginStatus() {
      SharedPreferences settings = getSharedPreferences(SaveInformationActivity.PREFS_NAME, 0);
      SharedPreferences.Editor editor = settings.edit();
      editor.putBoolean("hasLoggedIn", true);
      editor.commit();
      }

      public void getMyAccountDetailPref() {
      SharedPreferences.Editor editor = getSharedPreferences("mobile_no", MODE_PRIVATE).edit();
      editor.putString("user_mobile", countryCode + mobileNo);
      editor.apply();
      }

      public void getMyIntAccountDetailPref() {
      SharedPreferences.Editor editor = getSharedPreferences("mobile_no", MODE_PRIVATE).edit();
      editor.putString("user_mobile", countryCode + mobileNo);
      editor.apply();
      }

      public void getCountryCode() {
      countryCode = countryCodePicker.getFullNumberWithPlus();
      countryName = countryCodePicker.getSelectedCountryName();
      }

      public void sendToken() {
      try {
      String token = FirebaseInstanceId.getInstance().getToken();
      SharedPreferences.Editor editor = getSharedPreferences("user_token", MODE_PRIVATE).edit();
      editor.putString("token", token);
      editor.apply();
      UserTokenModal userTokenModal = new UserTokenModal(token);
      firestoreDB.collection("userToken").document(countryCode + mobileNo).set(userTokenModal).addOnSuccessListener(new OnSuccessListener<Void>() {
      @Override
      public void onSuccess(Void documentReference) {
      try {
      Log.e(">>>>", "token sent succefully");

      } catch (Exception e) {
      e.printStackTrace();
      }

      }
      }).addOnFailureListener(new OnFailureListener() {
      @Override
      public void onFailure(@NonNull Exception e) {
      Log.w(">>>", "Error adding event document", e);
      Toast.makeText(NumberActivity.this,
      e.getMessage(),
      Toast.LENGTH_SHORT).show();
      Utility.hideProgressDialog();
      }
      });
      } catch (Exception e) {
      e.printStackTrace();
      }
      }
      }






      android mobile numbers firebase-authentication one-time-password






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 10 at 4:39

























      asked Nov 9 at 7:47









      Sathish V.A

      12




      12
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          Firebase Authentication supports phone number verification across the world. Here is the list of Firebase supported countries:



          AD  Andorra
          AE United Arab Emirates
          AF Afghanistan
          AG Antigua and Barbuda
          AL Albania
          AM Armenia
          AO Angola
          AR Argentina
          AS American Samoa
          AT Austria
          AU Australia
          AW Aruba
          BA Bosnia and Herzegovina
          BB Barbados
          BD Bangladesh
          BE Belgium
          BF Burkina Faso
          BG Bulgaria
          BJ Benin
          BM Bermuda
          BN Brunei Darussalam
          BO Bolivia
          BR Brazil
          BS Bahamas
          BT Bhutan
          BW Botswana
          BY Belarus
          BZ Belize
          CA Canada
          CD Congo, (Kinshasa)
          CF Central African Republic
          CG Congo (Brazzaville)
          CH Switzerland
          CI Côte d'Ivoire
          CK Cook Islands
          CL Chile
          CM Cameroon
          CO Colombia
          CR Costa Rica
          CV Cape Verde
          CW Curaçao
          CY Cyprus
          CZ Czech Republic
          DE Germany
          DJ Djibouti
          DK Denmark
          DM Dominica
          DO Dominican Republic
          DZ Algeria
          EC Ecuador
          EG Egypt
          ES Spain
          ET Ethiopia
          FI Finland
          FJ Fiji
          FK Falkland Islands (Malvinas)
          FM Micronesia, Federated States of
          FO Faroe Islands
          FR France
          GA Gabon
          GB United Kingdom
          GD Grenada
          GE Georgia
          GF French Guiana
          GG Guernsey
          GH Ghana
          GI Gibraltar
          GL Greenland
          GM Gambia
          GP Guadeloupe
          GQ Equatorial Guinea
          GR Greece
          GT Guatemala
          GY Guyana
          HK Hong Kong, SAR China
          HN Honduras
          HR Croatia
          HT Haiti
          HU Hungary
          ID Indonesia
          IE Ireland
          IL Israel
          IM Isle of Man
          IN India
          IQ Iraq
          IT Italy
          JE Jersey
          JM Jamaica
          JO Jordan
          JP Japan
          KE Kenya
          KG Kyrgyzstan
          KH Cambodia
          KM Comoros
          KN Saint Kitts and Nevis
          KR Korea (South)
          KW Kuwait
          KY Cayman Islands
          KZ Kazakhstan
          LA Lao PDR
          LB Lebanon
          LC Saint Lucia
          LI Liechtenstein
          LK Sri Lanka
          LS Lesotho
          LT Lithuania
          LU Luxembourg
          LV Latvia
          LY Libya
          MA Morocco
          MD Moldova
          ME Montenegro
          MF Saint-Martin (French part)
          MG Madagascar
          MK Macedonia, Republic of
          MM Myanmar
          MN Mongolia
          MO Macao, SAR China
          MS Montserrat
          MT Malta
          MU Mauritius
          MW Malawi
          MX Mexico
          MY Malaysia
          MZ Mozambique
          NA Namibia
          NC New Caledonia
          NE Niger
          NF Norfolk Island
          NG Nigeria
          NI Nicaragua
          NL Netherlands
          NO Norway
          NP Nepal
          NZ New Zealand
          OM Oman
          PA Panama
          PE Peru
          PG Papua New Guinea
          PH Philippines
          PK Pakistan
          PL Poland
          PM Saint Pierre and Miquelon
          PR Puerto Rico
          PS Palestinian Territory
          PT Portugal
          PY Paraguay
          QA Qatar
          RE Réunion
          RO Romania
          RS Serbia
          RU Russian Federation
          RW Rwanda
          SA Saudi Arabia
          SC Seychelles
          SD Sudan
          SE Sweden
          SG Singapore
          SH Saint Helena
          SI Slovenia
          SK Slovakia
          SL Sierra Leone
          SN Senegal
          SR Suriname
          ST Sao Tome and Principe
          SV El Salvador
          SY Syrian Arab Republic (Syria)
          SZ Swaziland
          TC Turks and Caicos Islands
          TG Togo
          TH Thailand
          TL Timor-Leste
          TM Turkmenistan
          TO Tonga
          TR Turkey
          TT Trinidad and Tobago
          TW Taiwan, Republic of China
          TZ Tanzania, United Republic of
          UA Ukraine
          UG Uganda
          US United States of America
          UY Uruguay
          UZ Uzbekistan
          VC Saint Vincent and Grenadines
          VE Venezuela (Bolivarian Republic)
          VG British Virgin Islands
          VI Virgin Islands, US
          VN Viet Nam
          WS Samoa
          YE Yemen
          YT Mayotte
          ZA South Africa
          ZM Zambia
          ZW Zimbabwe


          Show your XML and Java code so we can help you.






          share|improve this answer























          • I have added the codes, kindly reply with the solution.
            – Sathish V.A
            Dec 4 at 5:47











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53221662%2ffirebase-otp-is-not-receiving-for-international-numbers%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          Firebase Authentication supports phone number verification across the world. Here is the list of Firebase supported countries:



          AD  Andorra
          AE United Arab Emirates
          AF Afghanistan
          AG Antigua and Barbuda
          AL Albania
          AM Armenia
          AO Angola
          AR Argentina
          AS American Samoa
          AT Austria
          AU Australia
          AW Aruba
          BA Bosnia and Herzegovina
          BB Barbados
          BD Bangladesh
          BE Belgium
          BF Burkina Faso
          BG Bulgaria
          BJ Benin
          BM Bermuda
          BN Brunei Darussalam
          BO Bolivia
          BR Brazil
          BS Bahamas
          BT Bhutan
          BW Botswana
          BY Belarus
          BZ Belize
          CA Canada
          CD Congo, (Kinshasa)
          CF Central African Republic
          CG Congo (Brazzaville)
          CH Switzerland
          CI Côte d'Ivoire
          CK Cook Islands
          CL Chile
          CM Cameroon
          CO Colombia
          CR Costa Rica
          CV Cape Verde
          CW Curaçao
          CY Cyprus
          CZ Czech Republic
          DE Germany
          DJ Djibouti
          DK Denmark
          DM Dominica
          DO Dominican Republic
          DZ Algeria
          EC Ecuador
          EG Egypt
          ES Spain
          ET Ethiopia
          FI Finland
          FJ Fiji
          FK Falkland Islands (Malvinas)
          FM Micronesia, Federated States of
          FO Faroe Islands
          FR France
          GA Gabon
          GB United Kingdom
          GD Grenada
          GE Georgia
          GF French Guiana
          GG Guernsey
          GH Ghana
          GI Gibraltar
          GL Greenland
          GM Gambia
          GP Guadeloupe
          GQ Equatorial Guinea
          GR Greece
          GT Guatemala
          GY Guyana
          HK Hong Kong, SAR China
          HN Honduras
          HR Croatia
          HT Haiti
          HU Hungary
          ID Indonesia
          IE Ireland
          IL Israel
          IM Isle of Man
          IN India
          IQ Iraq
          IT Italy
          JE Jersey
          JM Jamaica
          JO Jordan
          JP Japan
          KE Kenya
          KG Kyrgyzstan
          KH Cambodia
          KM Comoros
          KN Saint Kitts and Nevis
          KR Korea (South)
          KW Kuwait
          KY Cayman Islands
          KZ Kazakhstan
          LA Lao PDR
          LB Lebanon
          LC Saint Lucia
          LI Liechtenstein
          LK Sri Lanka
          LS Lesotho
          LT Lithuania
          LU Luxembourg
          LV Latvia
          LY Libya
          MA Morocco
          MD Moldova
          ME Montenegro
          MF Saint-Martin (French part)
          MG Madagascar
          MK Macedonia, Republic of
          MM Myanmar
          MN Mongolia
          MO Macao, SAR China
          MS Montserrat
          MT Malta
          MU Mauritius
          MW Malawi
          MX Mexico
          MY Malaysia
          MZ Mozambique
          NA Namibia
          NC New Caledonia
          NE Niger
          NF Norfolk Island
          NG Nigeria
          NI Nicaragua
          NL Netherlands
          NO Norway
          NP Nepal
          NZ New Zealand
          OM Oman
          PA Panama
          PE Peru
          PG Papua New Guinea
          PH Philippines
          PK Pakistan
          PL Poland
          PM Saint Pierre and Miquelon
          PR Puerto Rico
          PS Palestinian Territory
          PT Portugal
          PY Paraguay
          QA Qatar
          RE Réunion
          RO Romania
          RS Serbia
          RU Russian Federation
          RW Rwanda
          SA Saudi Arabia
          SC Seychelles
          SD Sudan
          SE Sweden
          SG Singapore
          SH Saint Helena
          SI Slovenia
          SK Slovakia
          SL Sierra Leone
          SN Senegal
          SR Suriname
          ST Sao Tome and Principe
          SV El Salvador
          SY Syrian Arab Republic (Syria)
          SZ Swaziland
          TC Turks and Caicos Islands
          TG Togo
          TH Thailand
          TL Timor-Leste
          TM Turkmenistan
          TO Tonga
          TR Turkey
          TT Trinidad and Tobago
          TW Taiwan, Republic of China
          TZ Tanzania, United Republic of
          UA Ukraine
          UG Uganda
          US United States of America
          UY Uruguay
          UZ Uzbekistan
          VC Saint Vincent and Grenadines
          VE Venezuela (Bolivarian Republic)
          VG British Virgin Islands
          VI Virgin Islands, US
          VN Viet Nam
          WS Samoa
          YE Yemen
          YT Mayotte
          ZA South Africa
          ZM Zambia
          ZW Zimbabwe


          Show your XML and Java code so we can help you.






          share|improve this answer























          • I have added the codes, kindly reply with the solution.
            – Sathish V.A
            Dec 4 at 5:47















          up vote
          0
          down vote













          Firebase Authentication supports phone number verification across the world. Here is the list of Firebase supported countries:



          AD  Andorra
          AE United Arab Emirates
          AF Afghanistan
          AG Antigua and Barbuda
          AL Albania
          AM Armenia
          AO Angola
          AR Argentina
          AS American Samoa
          AT Austria
          AU Australia
          AW Aruba
          BA Bosnia and Herzegovina
          BB Barbados
          BD Bangladesh
          BE Belgium
          BF Burkina Faso
          BG Bulgaria
          BJ Benin
          BM Bermuda
          BN Brunei Darussalam
          BO Bolivia
          BR Brazil
          BS Bahamas
          BT Bhutan
          BW Botswana
          BY Belarus
          BZ Belize
          CA Canada
          CD Congo, (Kinshasa)
          CF Central African Republic
          CG Congo (Brazzaville)
          CH Switzerland
          CI Côte d'Ivoire
          CK Cook Islands
          CL Chile
          CM Cameroon
          CO Colombia
          CR Costa Rica
          CV Cape Verde
          CW Curaçao
          CY Cyprus
          CZ Czech Republic
          DE Germany
          DJ Djibouti
          DK Denmark
          DM Dominica
          DO Dominican Republic
          DZ Algeria
          EC Ecuador
          EG Egypt
          ES Spain
          ET Ethiopia
          FI Finland
          FJ Fiji
          FK Falkland Islands (Malvinas)
          FM Micronesia, Federated States of
          FO Faroe Islands
          FR France
          GA Gabon
          GB United Kingdom
          GD Grenada
          GE Georgia
          GF French Guiana
          GG Guernsey
          GH Ghana
          GI Gibraltar
          GL Greenland
          GM Gambia
          GP Guadeloupe
          GQ Equatorial Guinea
          GR Greece
          GT Guatemala
          GY Guyana
          HK Hong Kong, SAR China
          HN Honduras
          HR Croatia
          HT Haiti
          HU Hungary
          ID Indonesia
          IE Ireland
          IL Israel
          IM Isle of Man
          IN India
          IQ Iraq
          IT Italy
          JE Jersey
          JM Jamaica
          JO Jordan
          JP Japan
          KE Kenya
          KG Kyrgyzstan
          KH Cambodia
          KM Comoros
          KN Saint Kitts and Nevis
          KR Korea (South)
          KW Kuwait
          KY Cayman Islands
          KZ Kazakhstan
          LA Lao PDR
          LB Lebanon
          LC Saint Lucia
          LI Liechtenstein
          LK Sri Lanka
          LS Lesotho
          LT Lithuania
          LU Luxembourg
          LV Latvia
          LY Libya
          MA Morocco
          MD Moldova
          ME Montenegro
          MF Saint-Martin (French part)
          MG Madagascar
          MK Macedonia, Republic of
          MM Myanmar
          MN Mongolia
          MO Macao, SAR China
          MS Montserrat
          MT Malta
          MU Mauritius
          MW Malawi
          MX Mexico
          MY Malaysia
          MZ Mozambique
          NA Namibia
          NC New Caledonia
          NE Niger
          NF Norfolk Island
          NG Nigeria
          NI Nicaragua
          NL Netherlands
          NO Norway
          NP Nepal
          NZ New Zealand
          OM Oman
          PA Panama
          PE Peru
          PG Papua New Guinea
          PH Philippines
          PK Pakistan
          PL Poland
          PM Saint Pierre and Miquelon
          PR Puerto Rico
          PS Palestinian Territory
          PT Portugal
          PY Paraguay
          QA Qatar
          RE Réunion
          RO Romania
          RS Serbia
          RU Russian Federation
          RW Rwanda
          SA Saudi Arabia
          SC Seychelles
          SD Sudan
          SE Sweden
          SG Singapore
          SH Saint Helena
          SI Slovenia
          SK Slovakia
          SL Sierra Leone
          SN Senegal
          SR Suriname
          ST Sao Tome and Principe
          SV El Salvador
          SY Syrian Arab Republic (Syria)
          SZ Swaziland
          TC Turks and Caicos Islands
          TG Togo
          TH Thailand
          TL Timor-Leste
          TM Turkmenistan
          TO Tonga
          TR Turkey
          TT Trinidad and Tobago
          TW Taiwan, Republic of China
          TZ Tanzania, United Republic of
          UA Ukraine
          UG Uganda
          US United States of America
          UY Uruguay
          UZ Uzbekistan
          VC Saint Vincent and Grenadines
          VE Venezuela (Bolivarian Republic)
          VG British Virgin Islands
          VI Virgin Islands, US
          VN Viet Nam
          WS Samoa
          YE Yemen
          YT Mayotte
          ZA South Africa
          ZM Zambia
          ZW Zimbabwe


          Show your XML and Java code so we can help you.






          share|improve this answer























          • I have added the codes, kindly reply with the solution.
            – Sathish V.A
            Dec 4 at 5:47













          up vote
          0
          down vote










          up vote
          0
          down vote









          Firebase Authentication supports phone number verification across the world. Here is the list of Firebase supported countries:



          AD  Andorra
          AE United Arab Emirates
          AF Afghanistan
          AG Antigua and Barbuda
          AL Albania
          AM Armenia
          AO Angola
          AR Argentina
          AS American Samoa
          AT Austria
          AU Australia
          AW Aruba
          BA Bosnia and Herzegovina
          BB Barbados
          BD Bangladesh
          BE Belgium
          BF Burkina Faso
          BG Bulgaria
          BJ Benin
          BM Bermuda
          BN Brunei Darussalam
          BO Bolivia
          BR Brazil
          BS Bahamas
          BT Bhutan
          BW Botswana
          BY Belarus
          BZ Belize
          CA Canada
          CD Congo, (Kinshasa)
          CF Central African Republic
          CG Congo (Brazzaville)
          CH Switzerland
          CI Côte d'Ivoire
          CK Cook Islands
          CL Chile
          CM Cameroon
          CO Colombia
          CR Costa Rica
          CV Cape Verde
          CW Curaçao
          CY Cyprus
          CZ Czech Republic
          DE Germany
          DJ Djibouti
          DK Denmark
          DM Dominica
          DO Dominican Republic
          DZ Algeria
          EC Ecuador
          EG Egypt
          ES Spain
          ET Ethiopia
          FI Finland
          FJ Fiji
          FK Falkland Islands (Malvinas)
          FM Micronesia, Federated States of
          FO Faroe Islands
          FR France
          GA Gabon
          GB United Kingdom
          GD Grenada
          GE Georgia
          GF French Guiana
          GG Guernsey
          GH Ghana
          GI Gibraltar
          GL Greenland
          GM Gambia
          GP Guadeloupe
          GQ Equatorial Guinea
          GR Greece
          GT Guatemala
          GY Guyana
          HK Hong Kong, SAR China
          HN Honduras
          HR Croatia
          HT Haiti
          HU Hungary
          ID Indonesia
          IE Ireland
          IL Israel
          IM Isle of Man
          IN India
          IQ Iraq
          IT Italy
          JE Jersey
          JM Jamaica
          JO Jordan
          JP Japan
          KE Kenya
          KG Kyrgyzstan
          KH Cambodia
          KM Comoros
          KN Saint Kitts and Nevis
          KR Korea (South)
          KW Kuwait
          KY Cayman Islands
          KZ Kazakhstan
          LA Lao PDR
          LB Lebanon
          LC Saint Lucia
          LI Liechtenstein
          LK Sri Lanka
          LS Lesotho
          LT Lithuania
          LU Luxembourg
          LV Latvia
          LY Libya
          MA Morocco
          MD Moldova
          ME Montenegro
          MF Saint-Martin (French part)
          MG Madagascar
          MK Macedonia, Republic of
          MM Myanmar
          MN Mongolia
          MO Macao, SAR China
          MS Montserrat
          MT Malta
          MU Mauritius
          MW Malawi
          MX Mexico
          MY Malaysia
          MZ Mozambique
          NA Namibia
          NC New Caledonia
          NE Niger
          NF Norfolk Island
          NG Nigeria
          NI Nicaragua
          NL Netherlands
          NO Norway
          NP Nepal
          NZ New Zealand
          OM Oman
          PA Panama
          PE Peru
          PG Papua New Guinea
          PH Philippines
          PK Pakistan
          PL Poland
          PM Saint Pierre and Miquelon
          PR Puerto Rico
          PS Palestinian Territory
          PT Portugal
          PY Paraguay
          QA Qatar
          RE Réunion
          RO Romania
          RS Serbia
          RU Russian Federation
          RW Rwanda
          SA Saudi Arabia
          SC Seychelles
          SD Sudan
          SE Sweden
          SG Singapore
          SH Saint Helena
          SI Slovenia
          SK Slovakia
          SL Sierra Leone
          SN Senegal
          SR Suriname
          ST Sao Tome and Principe
          SV El Salvador
          SY Syrian Arab Republic (Syria)
          SZ Swaziland
          TC Turks and Caicos Islands
          TG Togo
          TH Thailand
          TL Timor-Leste
          TM Turkmenistan
          TO Tonga
          TR Turkey
          TT Trinidad and Tobago
          TW Taiwan, Republic of China
          TZ Tanzania, United Republic of
          UA Ukraine
          UG Uganda
          US United States of America
          UY Uruguay
          UZ Uzbekistan
          VC Saint Vincent and Grenadines
          VE Venezuela (Bolivarian Republic)
          VG British Virgin Islands
          VI Virgin Islands, US
          VN Viet Nam
          WS Samoa
          YE Yemen
          YT Mayotte
          ZA South Africa
          ZM Zambia
          ZW Zimbabwe


          Show your XML and Java code so we can help you.






          share|improve this answer














          Firebase Authentication supports phone number verification across the world. Here is the list of Firebase supported countries:



          AD  Andorra
          AE United Arab Emirates
          AF Afghanistan
          AG Antigua and Barbuda
          AL Albania
          AM Armenia
          AO Angola
          AR Argentina
          AS American Samoa
          AT Austria
          AU Australia
          AW Aruba
          BA Bosnia and Herzegovina
          BB Barbados
          BD Bangladesh
          BE Belgium
          BF Burkina Faso
          BG Bulgaria
          BJ Benin
          BM Bermuda
          BN Brunei Darussalam
          BO Bolivia
          BR Brazil
          BS Bahamas
          BT Bhutan
          BW Botswana
          BY Belarus
          BZ Belize
          CA Canada
          CD Congo, (Kinshasa)
          CF Central African Republic
          CG Congo (Brazzaville)
          CH Switzerland
          CI Côte d'Ivoire
          CK Cook Islands
          CL Chile
          CM Cameroon
          CO Colombia
          CR Costa Rica
          CV Cape Verde
          CW Curaçao
          CY Cyprus
          CZ Czech Republic
          DE Germany
          DJ Djibouti
          DK Denmark
          DM Dominica
          DO Dominican Republic
          DZ Algeria
          EC Ecuador
          EG Egypt
          ES Spain
          ET Ethiopia
          FI Finland
          FJ Fiji
          FK Falkland Islands (Malvinas)
          FM Micronesia, Federated States of
          FO Faroe Islands
          FR France
          GA Gabon
          GB United Kingdom
          GD Grenada
          GE Georgia
          GF French Guiana
          GG Guernsey
          GH Ghana
          GI Gibraltar
          GL Greenland
          GM Gambia
          GP Guadeloupe
          GQ Equatorial Guinea
          GR Greece
          GT Guatemala
          GY Guyana
          HK Hong Kong, SAR China
          HN Honduras
          HR Croatia
          HT Haiti
          HU Hungary
          ID Indonesia
          IE Ireland
          IL Israel
          IM Isle of Man
          IN India
          IQ Iraq
          IT Italy
          JE Jersey
          JM Jamaica
          JO Jordan
          JP Japan
          KE Kenya
          KG Kyrgyzstan
          KH Cambodia
          KM Comoros
          KN Saint Kitts and Nevis
          KR Korea (South)
          KW Kuwait
          KY Cayman Islands
          KZ Kazakhstan
          LA Lao PDR
          LB Lebanon
          LC Saint Lucia
          LI Liechtenstein
          LK Sri Lanka
          LS Lesotho
          LT Lithuania
          LU Luxembourg
          LV Latvia
          LY Libya
          MA Morocco
          MD Moldova
          ME Montenegro
          MF Saint-Martin (French part)
          MG Madagascar
          MK Macedonia, Republic of
          MM Myanmar
          MN Mongolia
          MO Macao, SAR China
          MS Montserrat
          MT Malta
          MU Mauritius
          MW Malawi
          MX Mexico
          MY Malaysia
          MZ Mozambique
          NA Namibia
          NC New Caledonia
          NE Niger
          NF Norfolk Island
          NG Nigeria
          NI Nicaragua
          NL Netherlands
          NO Norway
          NP Nepal
          NZ New Zealand
          OM Oman
          PA Panama
          PE Peru
          PG Papua New Guinea
          PH Philippines
          PK Pakistan
          PL Poland
          PM Saint Pierre and Miquelon
          PR Puerto Rico
          PS Palestinian Territory
          PT Portugal
          PY Paraguay
          QA Qatar
          RE Réunion
          RO Romania
          RS Serbia
          RU Russian Federation
          RW Rwanda
          SA Saudi Arabia
          SC Seychelles
          SD Sudan
          SE Sweden
          SG Singapore
          SH Saint Helena
          SI Slovenia
          SK Slovakia
          SL Sierra Leone
          SN Senegal
          SR Suriname
          ST Sao Tome and Principe
          SV El Salvador
          SY Syrian Arab Republic (Syria)
          SZ Swaziland
          TC Turks and Caicos Islands
          TG Togo
          TH Thailand
          TL Timor-Leste
          TM Turkmenistan
          TO Tonga
          TR Turkey
          TT Trinidad and Tobago
          TW Taiwan, Republic of China
          TZ Tanzania, United Republic of
          UA Ukraine
          UG Uganda
          US United States of America
          UY Uruguay
          UZ Uzbekistan
          VC Saint Vincent and Grenadines
          VE Venezuela (Bolivarian Republic)
          VG British Virgin Islands
          VI Virgin Islands, US
          VN Viet Nam
          WS Samoa
          YE Yemen
          YT Mayotte
          ZA South Africa
          ZM Zambia
          ZW Zimbabwe


          Show your XML and Java code so we can help you.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 10 at 2:44









          Pang

          6,8311563101




          6,8311563101










          answered Nov 9 at 17:52









          Vishal Sharma

          7702212




          7702212












          • I have added the codes, kindly reply with the solution.
            – Sathish V.A
            Dec 4 at 5:47


















          • I have added the codes, kindly reply with the solution.
            – Sathish V.A
            Dec 4 at 5:47
















          I have added the codes, kindly reply with the solution.
          – Sathish V.A
          Dec 4 at 5:47




          I have added the codes, kindly reply with the solution.
          – Sathish V.A
          Dec 4 at 5:47


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53221662%2ffirebase-otp-is-not-receiving-for-international-numbers%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          Academy of Television Arts & Sciences

          L'Équipe

          1995 France bombings