Skip to content

Commit 96c4743

Browse files
committed
Adds documentation for limiting countries in phone auth's country selector
1 parent 44b1a4f commit 96c4743

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

auth/README.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ startActivityForResult(
291291

292292
##### Phone number authentication customization
293293

294+
###### Setting a default phone number
294295
When using the phone verification provider and the number is known in advance, it is possible to
295296
provide a default phone number (in international format) that will be used to prepopulate the
296297
country code and phone number input fields. The user is still able to edit the number if desired.
@@ -301,7 +302,7 @@ IdpConfig phoneConfigWithDefaultNumber = new IdpConfig.PhoneBuilder()
301302
.build();
302303
```
303304

304-
Alternatively, you can set only the default phone number country.
305+
Alternatively, you can set the default country (alpha-2 format) to be shown in the country selector.
305306

306307
```java
307308
IdpConfig phoneConfigWithDefaultNumber = new IdpConfig.PhoneBuilder()
@@ -319,6 +320,45 @@ IdpConfig phoneConfigWithDefaultNumber = new IdpConfig.PhoneBuilder()
319320
.build();
320321
```
321322

323+
###### Limiting the list of available countries in the country selector
324+
325+
You can limit the countries shown in the country selector list. By default, all countries are shown.
326+
327+
You can provide a list of countries to whitelist or blacklist. You can populate these lists with
328+
ISO (alpha-2) and E164 formatted country codes.
329+
330+
```java
331+
List<String> whitelistedCountries = new ArrayList<String>();
332+
whitelistedCountries.add("+1");
333+
whitelistedCountries.add("gr");
334+
335+
IdpConfig phoneConfigWithWhitelistedCountries = new IdpConfig.PhoneBuilder()
336+
.setWhitelistedCountries(whitelistedCountries)
337+
.build();
338+
```
339+
All countries with the country code +1 will be present in the selector as well as Greece ('gr').
340+
341+
You may want to exclude a few countries from the list and avoid creating a whitelist with
342+
many countries. You can instead provide a list of countries to blacklist. By doing so, all countries
343+
excluding the ones you provide will be in the selector.
344+
345+
```java
346+
List<String> blacklistedCountries = new ArrayList<String>();
347+
blacklistedCountries.add("+1");
348+
blacklistedCountries.add("gr");
349+
350+
IdpConfig phoneConfigWithBlacklistedCountries = new IdpConfig.PhoneBuilder()
351+
.setBlacklistedCountries(blacklistedCountries)
352+
.build();
353+
```
354+
355+
The country code selector will exclude all countries with a country code of +1 and Greece ('gr').
356+
357+
Note: You can't provide both a list of countries to whitelist and blacklist. If you do, a runtime
358+
exception will be thrown.
359+
360+
#####
361+
322362
### Handling the sign-in response
323363

324364
#### Response codes

0 commit comments

Comments
 (0)