Skip to content

Commit 3f2551e

Browse files
Merge pull request #1251 from firebase/readme-alpha-release
2 parents 027572b + b20de63 commit 3f2551e

File tree

1 file changed

+137
-0
lines changed

1 file changed

+137
-0
lines changed

FirebaseSwiftUI/README.md

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# FirebaseUI for SwiftUI (Alpha release)
2+
3+
## Installation
4+
5+
1. Launch Xcode and open the project or workspace where you want to add the packages.
6+
2. In the menu bar, go to: `File > Add Package Dependencies...`
7+
3. Enter the Package URL: `https://github.com/firebase/FirebaseUI-iOS`
8+
4. Select target(s) you wish to add to your app (currently `FirebaseAuthSwiftUI`, `FirebaseGoogleSwiftUI`, `FirebaseFacebookSwiftUI` and `FirebasePhoneAuthSwiftUI` are available). `FirebaseAuthSwiftUI` is required and contains the Email provider API.
9+
5. Press the `Add Packages` button to complete installation.
10+
11+
12+
## Getting started
13+
14+
1. Follow step 2, 3 & 5 on [adding Firebase to your SwiftUI app](https://firebase.google.com/docs/ios/setup).
15+
2. You should now update your app entry point to look like this:
16+
17+
```swift
18+
import FirebaseAuthSwiftUI
19+
import FirebaseCore
20+
import SwiftUI
21+
22+
class AppDelegate: NSObject, UIApplicationDelegate {
23+
func application(_ application: UIApplication,
24+
didFinishLaunchingWithOptions launchOptions: [
25+
UIApplication.LaunchOptionsKey: Any
26+
]?) -> Bool {
27+
FirebaseApp.configure()
28+
return true
29+
}
30+
}
31+
32+
@main
33+
struct FirebaseSwiftUIExampleApp: App {
34+
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
35+
36+
var body: some Scene {
37+
WindowGroup {
38+
ContentView()
39+
}
40+
}
41+
}
42+
43+
struct ContentView: View {
44+
let authService: AuthService
45+
46+
init() {
47+
let configuration = AuthConfiguration()
48+
49+
authService = AuthService(
50+
configuration: configuration,
51+
)
52+
.withEmailSignIn()
53+
}
54+
55+
var body: some View {
56+
AuthPickerView().environment(authService)
57+
}
58+
}
59+
```
60+
61+
3. For a more complete example, see the [SwiftUI sample app](https://github.com/firebase/FirebaseUI-iOS/tree/main/samples/swiftui/FirebaseSwiftUIExample).
62+
63+
## Configuration options
64+
65+
You can create an `AuthConfiguration` instance and pass it to the `AuthService` as demonstrated above. Here are the options:
66+
67+
```swift
68+
public struct AuthConfiguration {
69+
// hides cancel buttons when you don't want a flow to be interrupted
70+
let shouldHideCancelButton: Bool
71+
// stop users from being able to swipe away sheets/modal
72+
let interactiveDismissEnabled: Bool
73+
// automatically upgrade anonymous users so that they are linked with account being used to sign-in
74+
let shouldAutoUpgradeAnonymousUsers: Bool
75+
// custom string bundle for string localizations
76+
let customStringsBundle: Bundle?
77+
// terms of service URL
78+
let tosUrl: URL
79+
// privacy policy URL
80+
let privacyPolicyUrl: URL
81+
// action code settings for email sign in link
82+
let emailLinkSignInActionCodeSettings: ActionCodeSettings?
83+
// action code settings verifying email address
84+
let verifyEmailActionCodeSettings: ActionCodeSettings?
85+
86+
public init(shouldHideCancelButton: Bool = false,
87+
interactiveDismissEnabled: Bool = true,
88+
shouldAutoUpgradeAnonymousUsers: Bool = false,
89+
customStringsBundle: Bundle? = nil,
90+
tosUrl: URL = URL(string: "https://example.com/tos")!,
91+
privacyPolicyUrl: URL = URL(string: "https://example.com/privacy")!,
92+
emailLinkSignInActionCodeSettings: ActionCodeSettings? = nil,
93+
verifyEmailActionCodeSettings: ActionCodeSettings? = nil)
94+
}
95+
```
96+
97+
## Configuring providers
98+
99+
1. Ensure the provider is installed from step 1 (e.g. if configuring Google provider, you need to install `FirebaseGoogleSwiftUI` package).
100+
2. Ensure you have called the relevant API on `AuthService` to initialise the provider. Example of Email and Google provider initialization:
101+
102+
```swift
103+
let authService = AuthService()
104+
.withEmailSignIn()
105+
.withGoogleSignIn()
106+
```
107+
108+
> Note: There may be additional setup for each provider typically in the AppDelegate. [See example app for setup.](https://github.com/firebase/FirebaseUI-iOS/tree/main/samples/swiftui/FirebaseSwiftUIExample)
109+
110+
111+
## API available for alpha release
112+
1. General API
113+
- Auto upgrade anonymous user account linking (if configured).
114+
- Sign out
115+
2. Email/Password
116+
- Sign-in/Create user
117+
- Password recovery
118+
- Email link sign-in
119+
3. Google
120+
- Sign in with Google
121+
4. Facebook
122+
1. Sign in with Facebook limited login
123+
2. Sign in with Facebook classic login
124+
5. Phone Auth
125+
- Verify phone number
126+
- Sign in with phone number
127+
6. User
128+
- Update password
129+
- Delete user
130+
- Verify email address
131+
132+
133+
## Notes for Alpha release
134+
1. Customization/theming for Views is not yet available.
135+
2. The providers available are Email, Phone, Google and Facebook.
136+
3. String localizations have been ported over and used where possible from the previous implementation, but new strings will only have English translations for the time being.
137+
4. The UI has not been polished and is subject to change once design has been finalized.

0 commit comments

Comments
 (0)