Skip to content

Commit a2b2b34

Browse files
README for SwiftUI alpha release
1 parent 027572b commit a2b2b34

File tree

1 file changed

+138
-0
lines changed

1 file changed

+138
-0
lines changed

FirebaseSwiftUI/README.md

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
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 Email provider API.
9+
5. Press `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+
init() {}
37+
38+
var body: some Scene {
39+
WindowGroup {
40+
ContentView()
41+
}
42+
}
43+
}
44+
45+
struct ContentView: View {
46+
let authService: AuthService
47+
48+
init() {
49+
let configuration = AuthConfiguration()
50+
51+
authService = AuthService(
52+
configuration: configuration,
53+
)
54+
.withEmailSignIn()
55+
}
56+
57+
var body: some View {
58+
AuthPickerView().environment(authService)
59+
}
60+
}
61+
```
62+
63+
3. For a more complete example, see the [SwiftUI sample app](https://github.com/firebase/FirebaseUI-iOS/tree/main/samples/swiftui/FirebaseSwiftUIExample).
64+
65+
## Configuration options
66+
67+
You can create an `AuthConfiguration` instance and pass it to the `AuthService` as demonstrated above. Here are the options:
68+
69+
```swift
70+
public struct AuthConfiguration {
71+
// hides cancel buttons when you don't want a flow to be interrupted
72+
let shouldHideCancelButton: Bool
73+
// stop users from being able to swipe away sheets/modal
74+
let interactiveDismissEnabled: Bool
75+
// automatically upgrade anonymous users so that they are linked with account being used to sign-in
76+
let shouldAutoUpgradeAnonymousUsers: Bool
77+
// custom string bundle for string localizations
78+
let customStringsBundle: Bundle?
79+
// terms of service URL
80+
let tosUrl: URL
81+
// privacy policy URL
82+
let privacyPolicyUrl: URL
83+
// action code settings for email sign in link
84+
let emailLinkSignInActionCodeSettings: ActionCodeSettings?
85+
// action code settings verifying email address
86+
let verifyEmailActionCodeSettings: ActionCodeSettings?
87+
88+
public init(shouldHideCancelButton: Bool = false,
89+
interactiveDismissEnabled: Bool = true,
90+
shouldAutoUpgradeAnonymousUsers: Bool = false,
91+
customStringsBundle: Bundle? = nil,
92+
tosUrl: URL = URL(string: "https://example.com/tos")!,
93+
privacyPolicyUrl: URL = URL(string: "https://example.com/privacy")!,
94+
emailLinkSignInActionCodeSettings: ActionCodeSettings? = nil,
95+
verifyEmailActionCodeSettings: ActionCodeSettings? = nil)
96+
}
97+
```
98+
99+
## Configuring providers
100+
101+
1. Ensure the provider is installed from step 1 (e.g. if configuring Google provider, you need to install `FirebaseGoogleSwiftUI` package).
102+
2. Ensure you have called the relevant API on `AuthService` to initialise provider. Example of Email and Google provider initialization:
103+
104+
```swift
105+
let authService = AuthService()
106+
.withEmailSignIn()
107+
.withGoogleSignIn()
108+
```
109+
110+
> 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)
111+
112+
113+
## API available for alpha release
114+
1. General API
115+
- Auto upgrade anonymous user account linking (if configured).
116+
- Sign out
117+
2. Email/Password
118+
- Sign-in/Create user
119+
- Password recovery
120+
- Email link sign-in
121+
3. Google
122+
- Sign in with Google
123+
4. Facebook
124+
1. Sign in with Facebook limited login
125+
2. Sign in with Facebook classic login
126+
5. Phone Auth
127+
- Verify phone number
128+
- Sign in with phone number
129+
6. User
130+
- Update password
131+
- Delete user
132+
- Verify email address
133+
134+
## Notes for Alpha release
135+
1. Customization/theming for Views is not yet available.
136+
2. The providers available are Email, Phone, Google and Facebook.
137+
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.
138+
4. The UI has not been polished and is subject to change once design has been finalized.

0 commit comments

Comments
 (0)