Skip to content

Commit ea7039c

Browse files
committed
Add Phone Auth readme
1 parent 0dfa345 commit ea7039c

File tree

2 files changed

+75
-1
lines changed

2 files changed

+75
-1
lines changed

FirebasePhoneAuthUI/README.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# FirebaseUI for iOS — Phone Auth
2+
3+
You can use Firebase Phone Authentication to sign in a user by sending an SMS message to the user's phone.The user signs in using a one-time code contained in the SMS message.
4+
5+
## Table of Contents
6+
7+
1. [Installation](#installation)
8+
1. [Integration](#using-firebasephoneui-for-authentication)
9+
1. [Customization](#customizing)
10+
11+
## Installation
12+
### Importing FirebaseUI Phone Auth components
13+
Add the following to your `Podfile`:
14+
```ruby
15+
pod 'FirebaseUI/Auth'
16+
pod 'FirebaseUI/Phone'
17+
```
18+
19+
### Configuring sign-in provider
20+
To use FirebaseUI to authenticate users you first need to configure each provider you want to use in
21+
their own developer app settings. Please read the *Before you begin* section of the [Firebase
22+
Phone Auth configuration guides](https://firebase.google.com/docs/auth/ios/phone-auth#before_you_begin).
23+
24+
## Using FirebasePhoneUI for Authentication
25+
26+
### Integration
27+
28+
In order to use Phone Auth you should initialize Phone provider and add it to the list of FUIAuth providers. Please notice that you should use only one instance of Phone Auth providers. It can be retrieved form FUIAuth providers list.
29+
30+
```swift
31+
// Swift
32+
import Firebase
33+
import FirebaseAuthUI
34+
import FirebasePhoneAuthUI
35+
36+
/* ... */
37+
38+
FUIAuth.defaultAuthUI()?.delegate = self
39+
let phoneProvider = FUIPhoneAuth.init(authUI: FUIAuth.defaultAuthUI()!)
40+
FUIAuth.defaultAuthUI()?.providers = [phoneProvider]
41+
```
42+
43+
```objective-c
44+
// Objective-C
45+
@import FirebaseAuthUI; // OR #import <FirebaseAuthUI/FirebaseAuthUI.h>
46+
@import FirebasePhoneAuthUI; // OR #import <FirebasePhoneAuthUI/FUIPhoneAuth.h>
47+
48+
/* ... */
49+
50+
[FUIAuth defaultAuthUI].delegate = self; // delegate should be retained by you!
51+
FUIPhoneAuth *phoneProvider = [[FUIPhoneAuth alloc] initWithAuthUI:[FUIAuth defaultAuthUI]];
52+
[FUIAuth defaultAuthUI].providers = @[phoneProvider];
53+
```
54+
55+
### Sign In
56+
57+
To start the authentication flow:
58+
59+
```swift
60+
// Swift
61+
let phoneProvider = FUIAuth.defaultAuthUI()?.providers.first as! FUIPhoneAuth
62+
phoneProvider.signIn(withPresenting: currentlyVisibleController, phoneNumber: nil)
63+
}
64+
```
65+
66+
```objective-c
67+
// Objective-C
68+
FUIPhoneAuth *phoneProvider = [FUIAuth defaultAuthUI].providers.firstObject;
69+
[phoneProvider signInWithPresentingViewController:currentlyVisibleController phoneNumber:nil];
70+
```
71+
72+
## Customizing
73+
Customizing of Phone Auth is planned to be implemented in 2017 Q4

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,10 @@ framework](https://firebase.google.com/docs/ios/setup) to your project.
5959
The READMEs for components of FirebaseUI can be found in their respective
6060
project folders.
6161

62+
- [Auth](FirebaseAuthUI/README.md)
63+
- [PhoneAuth](FirebasePhoneAuthUI/README.md)
6264
- [Database](FirebaseDatabaseUI/README.md)
6365
- [Firestore](FirebaseFirestoreUI/README.md)
64-
- [Auth](FirebaseAuthUI/README.md)
6566
- [Storage](FirebaseStorageUI/README.md)
6667

6768
## Local Setup

0 commit comments

Comments
 (0)