diff --git a/RxFireAuth.podspec b/RxFireAuth.podspec index 888b5c7..2b9e946 100644 --- a/RxFireAuth.podspec +++ b/RxFireAuth.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'RxFireAuth' - s.version = '1.5.1' + s.version = '1.6.0' s.summary = 'A smart Rx wrapper around Firebase Authentication SDK' # This description is used to generate tags and improve search results. diff --git a/docs/Classes.html b/docs/Classes.html index b438100..62e442c 100644 --- a/docs/Classes.html +++ b/docs/Classes.html @@ -8,13 +8,21 @@ + + +
UserManager
when you ask it to signInWithApple(in:updateUserDisplayName:allowMigration:)
.
You can use it also without a user manager associated.
-Sign in with Apple is only available on iOS 13 or later.
+Sign in with Apple is only available on iOS 13 and macOS 10.15 or later.
See moreSwift
-@available(iOS 13.0, *)
+ @available(iOS 13.0, OSX 10.15, *)
public class SignInWithAppleHandler : NSObject
extension SignInWithAppleHandler: ASAuthorizationControllerDelegate
extension SignInWithAppleHandler: ASAuthorizationControllerPresentationContextProviding
@@ -178,8 +192,8 @@ Declaration
@available(iOS 13.0, *)
+
+ @available(iOS 13.0, OSX 10.15, *)
public class SignInWithAppleHandler : NSObject
extension SignInWithAppleHandler: ASAuthorizationControllerDelegate
extension SignInWithAppleHandler: ASAuthorizationControllerPresentationContextProviding
@@ -111,7 +126,7 @@ SignInWithAppleHandler
by UserManager
when you ask it to signInWithApple(in:updateUserDisplayName:allowMigration:)
.
You can use it also without a user manager associated.
-Sign in with Apple is only available on iOS 13 or later.
+Sign in with Apple is only available on iOS 13 and macOS 10.15 or later.
@@ -275,8 +290,8 @@ Declaration
public class UserManager : UserManagerType
extension UserManager: LoginProviderManagerType
@@ -718,8 +733,8 @@ Sign in with Apple
Swift
-@available(iOS 13.0, *)
-public func signInWithApple(in viewController: UIViewController, updateUserDisplayName: Bool, allowMigration: Bool?) -> Single<LoginDescriptor>
+ @available(iOS 13.0, OSX 10.15, *)
+public func signInWithApple(in viewController: ViewController, updateUserDisplayName: Bool, allowMigration: Bool?) -> Single<LoginDescriptor>
Swift
-@available(iOS 13.0, *)
-public func confirmAuthenticationWithApple(in viewController: UIViewController) -> Completable
+ @available(iOS 13.0, OSX 10.15, *)
+public func confirmAuthenticationWithApple(in viewController: ViewController) -> Completable
Google Sign-in
Swift
-public func signInWithGoogle(as clientId: String, in viewController: UIViewController, updateUserDisplayName: Bool, allowMigration: Bool?) -> Single<LoginDescriptor>
+ public func signInWithGoogle(as clientId: String, in viewController: ViewController, updateUserDisplayName: Bool, allowMigration: Bool?) -> Single<LoginDescriptor>
Swift
-public func confirmAuthenticationWithGoogle(as clientId: String, in viewController: UIViewController) -> Completable
+ public func confirmAuthenticationWithGoogle(as clientId: String, in viewController: ViewController) -> Completable
+
+ Swift
+@available(iOS 13.0, OSX 10.15, *)
+public func signInWithApple(in viewController: ViewController, updateUserDisplayName: Bool, allowMigration: Bool?) -> Single<LoginDescriptor>
+
+
+
+
+ confirmAuthenticationWithApple(in:)
+
+ Swift
+@available(iOS 13.0, OSX 10.15, *)
+public func confirmAuthenticationWithApple(in viewController: ViewController) -> Completable
+
+ Swift
+public func signInWithGoogle(as clientId: String, in viewController: ViewController, updateUserDisplayName: Bool, allowMigration: Bool?) -> Single<LoginDescriptor>
+
+
+
+
+ confirmAuthenticationWithGoogle(as:in:)
+
+ Swift
+public func confirmAuthenticationWithGoogle(as clientId: String, in viewController: ViewController) -> Completable
public enum UserError : LocalizedError
public protocol LoginHandlerType
public protocol LoginProviderManagerType
Swift
-@available(iOS 13.0, *)
-func signInWithApple(in viewController: UIViewController, updateUserDisplayName: Bool, allowMigration: Bool?) -> Single<LoginDescriptor>
+ @available(iOS 13.0, OSX 10.15, *)
+func signInWithApple(in viewController: ViewController, updateUserDisplayName: Bool, allowMigration: Bool?) -> Single<LoginDescriptor>
Swift
-@available(iOS 13.0, *)
-func confirmAuthenticationWithApple(in viewController: UIViewController) -> Completable
+ @available(iOS 13.0, OSX 10.15, *)
+func confirmAuthenticationWithApple(in viewController: ViewController) -> Completable
Swift
-func signInWithGoogle(as clientId: String, in viewController: UIViewController, updateUserDisplayName: Bool, allowMigration: Bool?) -> Single<LoginDescriptor>
+ func signInWithGoogle(as clientId: String, in viewController: ViewController, updateUserDisplayName: Bool, allowMigration: Bool?) -> Single<LoginDescriptor>
Swift
-func confirmAuthenticationWithGoogle(as clientId: String, in viewController: UIViewController) -> Completable
+ func confirmAuthenticationWithGoogle(as clientId: String, in viewController: ViewController) -> Completable
+
+
+
+ clientId
+
+ |
+
+
+
+ Google client ID, generally obtainable using |
+
+
+ viewController
+
+ |
+
+
+
+ The view controller over which the Google Sign-in UI should be displayed. + |
+
A Completable action to observe.
+Sign in with Apple in the passed view controller.
+ +Before using this function, you must enable Sign in with Apple under the “Signing & Capabilities” tab of +your target. Also, you must turn on Sign in with Apple in your Firebase Console, if you haven’t already.
+ +The Sign in with Apple flow will be different for new users and returning users; as a result, in the latter case, the library +will not be able to retrieve the user’s display name, as Apple does not provide this information for returning users. +Keep in mind that the account you are creating using this function will be linked to the user’s Apple ID, but that link +will only work in one direction: from Apple to Firebase; if you delete the Firebase account, the user will still find your app +in their Apple ID settings, under “Apps Using Your Apple ID”.
+ +To use Sign in with Apple, your app must comply with specific terms. We strongly suggest you to review them before +starting the implementation: you can find those on the Apple Developer Portal. +Additionally, if your app also provides the option to sign in/sign up with another provider (such as Google) and you’re targeting the public App Store, +you must also support Sign in with Apple.
+ +Swift
+@available(iOS 13.0, OSX 10.15, *)
+func signInWithApple(in viewController: ViewController, updateUserDisplayName: Bool, allowMigration: Bool?) -> Single<LoginDescriptor>
+
+
+
+ viewController
+
+ |
+
+
+
+ The view controller over which the Sign in with Apple UI should be displayed. + |
+
+
+ updateUserDisplayName
+
+ |
+
+
+
+ If set to |
+
+
+ allowMigration
+
+ |
+
+
+
+ An optional boolean that defines the behavior in case there is an anonymous user logged-in and the user is trying to login in an existing account. This option will be passed back to the caller
+in the resulting |
+
A Single that emits errors or a LoginDescriptor
instance.
+
+
+ confirmAuthenticationWithApple(in:)
+
+ Confirm the authentication of the currently signed in user with Sign in with Apple.
+ +You can use this function to renew the user authentication in order to perform sensitive actions such as +updating the password or deleting the account. This function will emit an error if the user does not have +Sign in with Apple among their authentication providers.
+Since
+version 1.5.0
+ +Swift
+@available(iOS 13.0, OSX 10.15, *)
+func confirmAuthenticationWithApple(in viewController: ViewController) -> Completable
+
+
+
+ viewController
+
+ |
+
+
+
+ The view controller over which the Sign in with Apple UI should be displayed. + |
+
A Completable action to observe.
+Sign in with Google in the passed view controller.
+ +Google Sign In works by opening a Safari view over the specified view controller. At some point,
+a redirect will happen and will be sent to your AppDelegate or SceneDelegate: when it does, you must forward
+the URL by calling loginHandler.handle(url:)
on your UserManagerType
instance.
Since
+version 1.5.0
+ +Swift
+func signInWithGoogle(as clientId: String, in viewController: ViewController, updateUserDisplayName: Bool, allowMigration: Bool?) -> Single<LoginDescriptor>
+
+
+
+ clientId
+
+ |
+
+
+
+ Google client ID, generally obtainable using |
+
+
+ viewController
+
+ |
+
+
+
+ The view controller over which the Google Sign-in UI should be displayed. + |
+
+
+ updateUserDisplayName
+
+ |
+
+
+
+ If set to |
+
+
+ allowMigration
+
+ |
+
+
+
+ An optional boolean that defines the behavior in case there is an anonymous user logged-in and the user is trying to login in an existing account. This option will be passed back to the caller
+in the resulting |
+
A Single that emits errors or a LoginDescriptor
instance.
+
+
+ confirmAuthenticationWithGoogle(as:in:)
+
+ Confirm the authentication of the currently logged-in user with Google Sign-in.
+ +You can use this function to renew the user authentication in order to perform sensitive actions such as +updating the password or deleting the account. This function will emit an error if the user does not have +Google Sign In among their authentication providers.
+Since
+version 1.5.0
+ +Swift
+func confirmAuthenticationWithGoogle(as clientId: String, in viewController: ViewController) -> Completable
public protocol UserManagerType
public struct LoginCredentials
public enum Provider : String
public struct LoginDescriptor
public struct UserData
-
-
- GoogleSignInCompletionHandler
+
+
+ ViewController
+
+
+
+
+ ViewController
Swift
-public typealias GoogleSignInCompletionHandler = (_ idToken: String?, _ accessToken: String?, _ email: String?, _ fullName: String?, _ error: Error?) -> Void
+ public typealias ViewController = UIViewController
+
+
+ GoogleSignInCompletionHandler
+
+ Undocumented
+ +Swift
+public typealias GoogleSignInCompletionHandler = (_ idToken: String?, _ accessToken: String?, _ email: String?, _ fullName: String?, _ error: Error?) -> Void
+
+ UserManager
when you ask it to signInWithApple(in:updateUserDisplayName:allowMigration:)
.
You can use it also without a user manager associated.
-Sign in with Apple is only available on iOS 13 or later.
+Sign in with Apple is only available on iOS 13 and macOS 10.15 or later.
See moreSwift
-@available(iOS 13.0, *)
+ @available(iOS 13.0, OSX 10.15, *)
public class SignInWithAppleHandler : NSObject
extension SignInWithAppleHandler: ASAuthorizationControllerDelegate
extension SignInWithAppleHandler: ASAuthorizationControllerPresentationContextProviding
@@ -178,8 +192,8 @@ Declaration
@available(iOS 13.0, *)
+
+ @available(iOS 13.0, OSX 10.15, *)
public class SignInWithAppleHandler : NSObject
extension SignInWithAppleHandler: ASAuthorizationControllerDelegate
extension SignInWithAppleHandler: ASAuthorizationControllerPresentationContextProviding
@@ -111,7 +126,7 @@ SignInWithAppleHandler
by UserManager
when you ask it to signInWithApple(in:updateUserDisplayName:allowMigration:)
.
You can use it also without a user manager associated.
-Sign in with Apple is only available on iOS 13 or later.
+Sign in with Apple is only available on iOS 13 and macOS 10.15 or later.
@@ -275,8 +290,8 @@ Declaration
public class UserManager : UserManagerType
extension UserManager: LoginProviderManagerType
@@ -718,8 +733,8 @@ Sign in with Apple
Swift
-@available(iOS 13.0, *)
-public func signInWithApple(in viewController: UIViewController, updateUserDisplayName: Bool, allowMigration: Bool?) -> Single<LoginDescriptor>
+ @available(iOS 13.0, OSX 10.15, *)
+public func signInWithApple(in viewController: ViewController, updateUserDisplayName: Bool, allowMigration: Bool?) -> Single<LoginDescriptor>
Swift
-@available(iOS 13.0, *)
-public func confirmAuthenticationWithApple(in viewController: UIViewController) -> Completable
+ @available(iOS 13.0, OSX 10.15, *)
+public func confirmAuthenticationWithApple(in viewController: ViewController) -> Completable
Google Sign-in
Swift
-public func signInWithGoogle(as clientId: String, in viewController: UIViewController, updateUserDisplayName: Bool, allowMigration: Bool?) -> Single<LoginDescriptor>
+ public func signInWithGoogle(as clientId: String, in viewController: ViewController, updateUserDisplayName: Bool, allowMigration: Bool?) -> Single<LoginDescriptor>
Swift
-public func confirmAuthenticationWithGoogle(as clientId: String, in viewController: UIViewController) -> Completable
+ public func confirmAuthenticationWithGoogle(as clientId: String, in viewController: ViewController) -> Completable
+
+ Swift
+@available(iOS 13.0, OSX 10.15, *)
+public func signInWithApple(in viewController: ViewController, updateUserDisplayName: Bool, allowMigration: Bool?) -> Single<LoginDescriptor>
+
+
+
+
+ confirmAuthenticationWithApple(in:)
+
+ Swift
+@available(iOS 13.0, OSX 10.15, *)
+public func confirmAuthenticationWithApple(in viewController: ViewController) -> Completable
+
+ Swift
+public func signInWithGoogle(as clientId: String, in viewController: ViewController, updateUserDisplayName: Bool, allowMigration: Bool?) -> Single<LoginDescriptor>
+
+
+
+
+ confirmAuthenticationWithGoogle(as:in:)
+
+ Swift
+public func confirmAuthenticationWithGoogle(as clientId: String, in viewController: ViewController) -> Completable
public enum UserError : LocalizedError
public protocol LoginHandlerType
public protocol LoginProviderManagerType
Swift
-@available(iOS 13.0, *)
-func signInWithApple(in viewController: UIViewController, updateUserDisplayName: Bool, allowMigration: Bool?) -> Single<LoginDescriptor>
+ @available(iOS 13.0, OSX 10.15, *)
+func signInWithApple(in viewController: ViewController, updateUserDisplayName: Bool, allowMigration: Bool?) -> Single<LoginDescriptor>
Swift
-@available(iOS 13.0, *)
-func confirmAuthenticationWithApple(in viewController: UIViewController) -> Completable
+ @available(iOS 13.0, OSX 10.15, *)
+func confirmAuthenticationWithApple(in viewController: ViewController) -> Completable
Swift
-func signInWithGoogle(as clientId: String, in viewController: UIViewController, updateUserDisplayName: Bool, allowMigration: Bool?) -> Single<LoginDescriptor>
+ func signInWithGoogle(as clientId: String, in viewController: ViewController, updateUserDisplayName: Bool, allowMigration: Bool?) -> Single<LoginDescriptor>
Swift
-func confirmAuthenticationWithGoogle(as clientId: String, in viewController: UIViewController) -> Completable
+ func confirmAuthenticationWithGoogle(as clientId: String, in viewController: ViewController) -> Completable
+
+
+
+ clientId
+
+ |
+
+
+
+ Google client ID, generally obtainable using |
+
+
+ viewController
+
+ |
+
+
+
+ The view controller over which the Google Sign-in UI should be displayed. + |
+
A Completable action to observe.
+Sign in with Apple in the passed view controller.
+ +Before using this function, you must enable Sign in with Apple under the “Signing & Capabilities” tab of +your target. Also, you must turn on Sign in with Apple in your Firebase Console, if you haven’t already.
+ +The Sign in with Apple flow will be different for new users and returning users; as a result, in the latter case, the library +will not be able to retrieve the user’s display name, as Apple does not provide this information for returning users. +Keep in mind that the account you are creating using this function will be linked to the user’s Apple ID, but that link +will only work in one direction: from Apple to Firebase; if you delete the Firebase account, the user will still find your app +in their Apple ID settings, under “Apps Using Your Apple ID”.
+ +To use Sign in with Apple, your app must comply with specific terms. We strongly suggest you to review them before +starting the implementation: you can find those on the Apple Developer Portal. +Additionally, if your app also provides the option to sign in/sign up with another provider (such as Google) and you’re targeting the public App Store, +you must also support Sign in with Apple.
+ +Swift
+@available(iOS 13.0, OSX 10.15, *)
+func signInWithApple(in viewController: ViewController, updateUserDisplayName: Bool, allowMigration: Bool?) -> Single<LoginDescriptor>
+
+
+
+ viewController
+
+ |
+
+
+
+ The view controller over which the Sign in with Apple UI should be displayed. + |
+
+
+ updateUserDisplayName
+
+ |
+
+
+
+ If set to |
+
+
+ allowMigration
+
+ |
+
+
+
+ An optional boolean that defines the behavior in case there is an anonymous user logged-in and the user is trying to login in an existing account. This option will be passed back to the caller
+in the resulting |
+
A Single that emits errors or a LoginDescriptor
instance.
+
+
+ confirmAuthenticationWithApple(in:)
+
+ Confirm the authentication of the currently signed in user with Sign in with Apple.
+ +You can use this function to renew the user authentication in order to perform sensitive actions such as +updating the password or deleting the account. This function will emit an error if the user does not have +Sign in with Apple among their authentication providers.
+Since
+version 1.5.0
+ +Swift
+@available(iOS 13.0, OSX 10.15, *)
+func confirmAuthenticationWithApple(in viewController: ViewController) -> Completable
+
+
+
+ viewController
+
+ |
+
+
+
+ The view controller over which the Sign in with Apple UI should be displayed. + |
+
A Completable action to observe.
+Sign in with Google in the passed view controller.
+ +Google Sign In works by opening a Safari view over the specified view controller. At some point,
+a redirect will happen and will be sent to your AppDelegate or SceneDelegate: when it does, you must forward
+the URL by calling loginHandler.handle(url:)
on your UserManagerType
instance.
Since
+version 1.5.0
+ +Swift
+func signInWithGoogle(as clientId: String, in viewController: ViewController, updateUserDisplayName: Bool, allowMigration: Bool?) -> Single<LoginDescriptor>
+
+
+
+ clientId
+
+ |
+
+
+
+ Google client ID, generally obtainable using |
+
+
+ viewController
+
+ |
+
+
+
+ The view controller over which the Google Sign-in UI should be displayed. + |
+
+
+ updateUserDisplayName
+
+ |
+
+
+
+ If set to |
+
+
+ allowMigration
+
+ |
+
+
+
+ An optional boolean that defines the behavior in case there is an anonymous user logged-in and the user is trying to login in an existing account. This option will be passed back to the caller
+in the resulting |
+
A Single that emits errors or a LoginDescriptor
instance.
+
+
+ confirmAuthenticationWithGoogle(as:in:)
+
+ Confirm the authentication of the currently logged-in user with Google Sign-in.
+ +You can use this function to renew the user authentication in order to perform sensitive actions such as +updating the password or deleting the account. This function will emit an error if the user does not have +Google Sign In among their authentication providers.
+Since
+version 1.5.0
+ +Swift
+func confirmAuthenticationWithGoogle(as clientId: String, in viewController: ViewController) -> Completable
public protocol UserManagerType
public struct LoginCredentials
public enum Provider : String
public struct LoginDescriptor
public struct UserData
-
-
- GoogleSignInCompletionHandler
+
+
+ ViewController
+
+
+
+
+ ViewController
Swift
-public typealias GoogleSignInCompletionHandler = (_ idToken: String?, _ accessToken: String?, _ email: String?, _ fullName: String?, _ error: Error?) -> Void
+ public typealias ViewController = UIViewController
+
+
+ GoogleSignInCompletionHandler
+
+ Undocumented
+ +Swift
+public typealias GoogleSignInCompletionHandler = (_ idToken: String?, _ accessToken: String?, _ email: String?, _ fullName: String?, _ error: Error?) -> Void
+
+ + + +
@@ -106,33 +123,56 @@Looking for the Android version? You can find it right here.
RxFireAuth is available through CocoaPods. We don’t support other package managers at the moment, mainly because the Firebase SDK is available through CocoaPods only.
+RxFireAuth is available through CocoaPods and Swift Package Manager (in Beta).
+To install RxFireAuth in your project add:
pod 'RxFireAuth'
+To install RxFireAuth in your project, add this repository as dependency using Xcode or add the following in your Package.swift
file:
.package(url: "https://github.com/MrAsterisco/RxFireAuth", branch: "develop")
+
+
+Please note that Swift Package Manager support relies on the Firebase SDK Swift Package Manager beta branch, which is not yet officially supported by the Firebase team. You can find more information here.
+ +The Google SignIn SDK is not available through Swift Package Manager and it is automatically replaced by a standard implementation of AppAuth.
+To find out the latest version, look at the Releases tab of this repository.
To get started with RxFireAuth, you can download the example project or dive right into the documentation.
-This library includes a sample project that shows how to support a user log in, including anonymous accounts.
+This library includes a sample project that shows how to implement all the functions of the library on both iOS and macOS.
To see it in action, follow these steps:
io.mrasterisco.github.RxFireAuth-Example
as bundle identifier (or change the bundle identifier to match the one of a project you already have).GoogleService-Info.plist
and place it in the Example/RxFireAuth
folder.pod install
inside the Example
folder.RxFireAuth.xcworkspace
, select a valid Signing Identity, build and run.io.mrasterisco.github.RxFireAuth-Example
and io.mrasterisco.github.RxFireAuth-Example-macOS
. If you are not interested in both platforms, you can also add just one of the two.GoogleService-Info.plist
per each platform and place the first one (iOS) under Example/RxFireAuth
and the second one (macOS) under Example\RxFireAuth macOS
.To test Sign in with Apple, you need a valid signing identity. If you don’t have one now, you can turn off Sign in with Apple under the “Signing & Capabilities” tab of the Xcode project.
-Example
folder and run pod install
.RxFireAuth.xcworkspace
, select a valid Signing Identity, build and run.RxFireAuth.xcodeproj
under the Example-SwiftPM
folder.**Note: the Firebase Console does not support macOS apps, so you’ll have to add the macOS version as an iOS app. Please also note that the Firebase SDK for macOS is not officially part of the Firebase product, but it is community supported. You can find further info here.
+ +**Note 2: to test Sign in with Apple, you need a valid signing identity. If you don’t have one now, you can turn off Sign in with Apple under the “Signing & Capabilities” tab of the Xcode project.
+The whole library is built around the UserManagerType
protocol. The library provides the default implementation of it through the UserManager
class, that you can instantiate directly or get through Dependency Injection.
GoogleService-Info.plist
file.FirebaseApp.configure()
in your application:didFinishLaunchingWithOptions:
function in the AppDelegate, as described here.FirebaseApp.configure()
in your application:didFinishLaunchingWithOptions:
function in the AppDelegate, as described here.
+– macOS: you have already called FirebaseApp.configure()
in your awakeFromNib
function in the AppDelegate.In your Podfile, you can omit the Firebase/Auth
reference as it is already a dependency of this library and will be included automatically.
To support OAuth providers (such as Google Sign-in), add the following method into your AppDelegate
:
To support OAuth providers such as Google SignIn, you also have to add the following to your AppDelegate
:
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
- return self.userManager.loginHandler?.handle(url: url) ?? false
+ return self.userManager.loginHandler?.handle(url: url) ?? false
+}
+
+
+Or, if you’re using the library on macOS, add the following to your AppDelegate
:
func applicationDidFinishLaunching(_ notification: Notification) {
+ NSAppleEventManager.shared().setEventHandler(self, andSelector: #selector(AppDelegate.handleGetURLEvent(event:replyEvent:)), forEventClass: AEEventClass(kInternetEventClass), andEventID: AEEventID(kAEGetURL))
+}
+
+@objc func handleGetURLEvent(event: NSAppleEventDescriptor, replyEvent: NSAppleEventDescriptor) {
+ let urlString = event.paramDescriptor(forKeyword: AEKeyword(keyDirectObject))?.stringValue!
+ let url = URL(string: urlString!)!
+ _ = userManager.loginHandler?.handle(url: url)
}
-One of the things that RxFireAuth aims to simplify is the ability to build a Register/Login screen that works seamlessly for new and returning users, also considering the ability of Firebase to create anonymous accounts.
+You also have to register the redirect URL for your app in the Info.plist
:
<key>CFBundleURLTypes</key>
+<array>
+ <dict>
+ <key>CFBundleTypeRole</key>
+ <string>Editor</string>
+ <key>CFBundleURLSchemes</key>
+ <array>
+ <string>{{FIREBASE_REVERSED_CLIENT_ID}}</string>
+ </array>
+ </dict>
+</array>
+
+
+You can find your FIREBASE_REVERSED_CLIENT_ID
in the GoogleService-Info.plist
file.
RxFireAuth offers several ways to interact with Firebase Authentication in a simple and reactive way.
+One of the things that RxFireAuth aims to simplify is the ability to build a Register/Login screen that works seamlessly for new and returning users, also considering the ability of Firebase to create anonymous accounts.
Modern applications should always try to delay sign-in as long as possible. From Apple Human Interface Guidelines:
@@ -175,7 +249,7 @@UserManager
class will automatically check if the specified credentials already exist and will use those to login; it’ll also delete the anonymous account that is no longer needed.UserManager
class will automatically check if the specified credentials already exist and will use those to login; it’ll also delete the anonymous account that is no longer needed and report everything back to you.When the user has made a choice, pass either true
or false
to get the same value circled back to your code after the login procedure has completed successfully.
When the user has made a choice, pass either true
or false
to get the same value circled back to your code after the sign in procedure completed successfully.
To support the migration, all login methods return an instance of LoginDescriptor
which gives you the allowMigration
parameter that you’ve passed, the User ID of the anonymous account, and the User ID of the account that is now logged-in. With this information, you can go ahead and migrate the data from the anonymous account to the newly logged-in account.
To support the migration, all sign in methods return an instance of LoginDescriptor
which gives you the allowMigration
parameter that you’ve passed, the User ID of the anonymous account, and the User ID of the account that is now logged-in. With this information, you can go ahead and migrate the data from the anonymous account to the newly logged-in account.
If you are thinking of providing alternatives ways to login into your app, RxFireAuth’s got you covered.
+If you are thinking of providing alternative ways to login into your app, RxFireAuth’s got you covered.
-When signing in with an external provider, it is always good to just let the user sign-in and then figure out later if this is their first time or not. Additionally, it is common practice to let people connect different providers along with their email and password credentials. Giving people flexibility is always a good choice.
+When signing in with an external provider, it is always good to just let the user sign in and then figure out later if this is their first time or not. Additionally, it is common practice to let people connect different providers along with their email and password credentials. Giving people flexibility is always a good choice.
-Let’s use the same short story from before, but Mike is now going to use Sign-in with Apple.
+Let’s use the same short story from before, but Mike is now going to use Sign in with Apple.
When using Sign-in with Apple (or any other provider, such as Google), you’ll find yourself in one of these cases:
-With RxFireAuth’s login
method family, all of these cases are handled automagically for you.
All of these cases are handled automatically for you by calling:
+All of the possible cases are handled automatically for you by calling:
func signInWithApple(in viewController: UIViewController, updateUserDisplayName: Bool, allowMigration: Bool?) -> Single<LoginDescriptor>
@@ -224,30 +300,41 @@ These functions are available in implementations of LoginProviderManagerType
, such as the UserManager
class that we’re already using.
You can use the updateUserDisplayName
parameter to automatically set the Firebase User displayName
property to the full name associated with the provider account. Keep in mind that some providers, such as Apple, allow the user to change this information while signing-in for the first time.
You can use the updateUserDisplayName
parameter to automatically set the Firebase User displayName
property to the full name associated with the provider account. Keep in mind that some providers, such as Apple, allow the user to change this information while signing in for the first time and may return it for new users only that have never signed into your app before.
This function will behave as the normal login, returning UserError.migrationRequired
, if an anonymous account is going to be deleted and allowMigration
is not set. When this happens, you can use the following function to continue signing-in after having asked the user what they would like to do:
This function will behave as the normal sign in, returning UserError.migrationRequired
, if an anonymous account will have to be deleted and allowMigration
is not set. When this happens, you can use the following function to continue signing in after having asked the user what they’d like to do:
func login(with credentials: LoginCredentials, updateUserDisplayName: Bool, allowMigration: Bool?) -> Single<LoginDescriptor>
The login credentials are embedded in the migrationRequired
error and, except for particular cases, you shouldn’t need to inspect them.
If you don’t want to support the anonymous authentication, you can use this library anyway as all of the methods are built to work even when no account is logged-in.
+You can get the profile of the currently logged-in user by calling:
+self.userManager.user
+
-You can make explicit calls to:
-func register(email: String, password: String) -> Completable
+or by subscribing to:
+self.userManager.autoupdatingUser
-and to:
-func loginWithoutChecking(email: String, password: String, allowMigration: Bool?) -> Single<LoginDescriptor>
+This Observable will emit new values every time something on the user profile has changed.
+
+Once signed in, you can inspect the authentication providers of the user by cycling through the authenticationProviders
array of the UserData
instance. For a list of the supported providers, see the Provider
enum, in LoginCredentials
.
+Authentication Confirmation
+
+When performing sensitive actions, such as changing the user password, linking new authentication providers or deleting the user account, Firebase will require you to get a new refresh token by forcing the user to login again. RxFireAuth offers convenient methods to confirm the authentication using one the supported providers.
+
+You can confirm the authentication using email and password:
+func confirmAuthentication(email: String, password: String) -> Completable
-and also to:
-func linkAnonymousAccount(toEmail email: String, password: String) -> Completable
+Sign in with Apple:
+func confirmAuthenticationWithApple(in viewController: UIViewController) -> Completable
-These methods will bypass the logic around anonymous and existing/non-existing accounts and will let you use the bare Firebase SDK through RxSwift.
+or Google Sign In:
+func confirmAuthenticationWithGoogle(as clientId: String, in viewController: UIViewController) -> Completable
+
Documentation
Always refer to the UserManagerType
and LoginProviderManagerType
protocols in your code, because the UserManager
implementation may introduce breaking changes over time even if the library major version hasn’t changed.
@@ -257,16 +344,25 @@ Documentation
You can find the autogenerated documentation here.
Compatibility
-RxFireAuth targets iOS 9.0 or later and has the following dependencies:
+RxFireAuth targets iOS 9.0 or later and macOS 10.11 or later and has the following shared dependencies:
Firebase/Auth
version 6.5.
-GoogleSignIn
version 5.0.2.
JWTDecode
version 2.4.
RxCocoa
version 5.
-Compatibility with macOS is planned. Don’t hesitate to open an issue to prioritize it.
+On iOS, when included via CocoaPods, it also needs:
+
+
+GoogleSignIn
version 5.0.2.
+
+
+On macOS and when included via Swift Package Manager, GoogleSignIn
is replaced by:
+
+
+AppAuth
version 1.4.
+
Contributions
All contributions to expand the library are welcome. Fork the repo, make the changes you want, and open a Pull Request.
@@ -284,8 +380,8 @@ License
+ + +
@@ -106,33 +123,56 @@Looking for the Android version? You can find it right here.
RxFireAuth is available through CocoaPods. We don’t support other package managers at the moment, mainly because the Firebase SDK is available through CocoaPods only.
+RxFireAuth is available through CocoaPods and Swift Package Manager (in Beta).
+To install RxFireAuth in your project add:
pod 'RxFireAuth'
+To install RxFireAuth in your project, add this repository as dependency using Xcode or add the following in your Package.swift
file:
.package(url: "https://github.com/MrAsterisco/RxFireAuth", branch: "develop")
+
+
+Please note that Swift Package Manager support relies on the Firebase SDK Swift Package Manager beta branch, which is not yet officially supported by the Firebase team. You can find more information here.
+ +The Google SignIn SDK is not available through Swift Package Manager and it is automatically replaced by a standard implementation of AppAuth.
+To find out the latest version, look at the Releases tab of this repository.
To get started with RxFireAuth, you can download the example project or dive right into the documentation.
-This library includes a sample project that shows how to support a user log in, including anonymous accounts.
+This library includes a sample project that shows how to implement all the functions of the library on both iOS and macOS.
To see it in action, follow these steps:
io.mrasterisco.github.RxFireAuth-Example
as bundle identifier (or change the bundle identifier to match the one of a project you already have).GoogleService-Info.plist
and place it in the Example/RxFireAuth
folder.pod install
inside the Example
folder.RxFireAuth.xcworkspace
, select a valid Signing Identity, build and run.io.mrasterisco.github.RxFireAuth-Example
and io.mrasterisco.github.RxFireAuth-Example-macOS
. If you are not interested in both platforms, you can also add just one of the two.GoogleService-Info.plist
per each platform and place the first one (iOS) under Example/RxFireAuth
and the second one (macOS) under Example\RxFireAuth macOS
.To test Sign in with Apple, you need a valid signing identity. If you don’t have one now, you can turn off Sign in with Apple under the “Signing & Capabilities” tab of the Xcode project.
-Example
folder and run pod install
.RxFireAuth.xcworkspace
, select a valid Signing Identity, build and run.RxFireAuth.xcodeproj
under the Example-SwiftPM
folder.**Note: the Firebase Console does not support macOS apps, so you’ll have to add the macOS version as an iOS app. Please also note that the Firebase SDK for macOS is not officially part of the Firebase product, but it is community supported. You can find further info here.
+ +**Note 2: to test Sign in with Apple, you need a valid signing identity. If you don’t have one now, you can turn off Sign in with Apple under the “Signing & Capabilities” tab of the Xcode project.
+The whole library is built around the UserManagerType
protocol. The library provides the default implementation of it through the UserManager
class, that you can instantiate directly or get through Dependency Injection.
GoogleService-Info.plist
file.FirebaseApp.configure()
in your application:didFinishLaunchingWithOptions:
function in the AppDelegate, as described here.FirebaseApp.configure()
in your application:didFinishLaunchingWithOptions:
function in the AppDelegate, as described here.
+– macOS: you have already called FirebaseApp.configure()
in your awakeFromNib
function in the AppDelegate.In your Podfile, you can omit the Firebase/Auth
reference as it is already a dependency of this library and will be included automatically.
To support OAuth providers (such as Google Sign-in), add the following method into your AppDelegate
:
To support OAuth providers such as Google SignIn, you also have to add the following to your AppDelegate
:
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
- return self.userManager.loginHandler?.handle(url: url) ?? false
+ return self.userManager.loginHandler?.handle(url: url) ?? false
+}
+
+
+Or, if you’re using the library on macOS, add the following to your AppDelegate
:
func applicationDidFinishLaunching(_ notification: Notification) {
+ NSAppleEventManager.shared().setEventHandler(self, andSelector: #selector(AppDelegate.handleGetURLEvent(event:replyEvent:)), forEventClass: AEEventClass(kInternetEventClass), andEventID: AEEventID(kAEGetURL))
+}
+
+@objc func handleGetURLEvent(event: NSAppleEventDescriptor, replyEvent: NSAppleEventDescriptor) {
+ let urlString = event.paramDescriptor(forKeyword: AEKeyword(keyDirectObject))?.stringValue!
+ let url = URL(string: urlString!)!
+ _ = userManager.loginHandler?.handle(url: url)
}
-One of the things that RxFireAuth aims to simplify is the ability to build a Register/Login screen that works seamlessly for new and returning users, also considering the ability of Firebase to create anonymous accounts.
+You also have to register the redirect URL for your app in the Info.plist
:
<key>CFBundleURLTypes</key>
+<array>
+ <dict>
+ <key>CFBundleTypeRole</key>
+ <string>Editor</string>
+ <key>CFBundleURLSchemes</key>
+ <array>
+ <string>{{FIREBASE_REVERSED_CLIENT_ID}}</string>
+ </array>
+ </dict>
+</array>
+
+
+You can find your FIREBASE_REVERSED_CLIENT_ID
in the GoogleService-Info.plist
file.
RxFireAuth offers several ways to interact with Firebase Authentication in a simple and reactive way.
+One of the things that RxFireAuth aims to simplify is the ability to build a Register/Login screen that works seamlessly for new and returning users, also considering the ability of Firebase to create anonymous accounts.
Modern applications should always try to delay sign-in as long as possible. From Apple Human Interface Guidelines:
@@ -175,7 +249,7 @@UserManager
class will automatically check if the specified credentials already exist and will use those to login; it’ll also delete the anonymous account that is no longer needed.UserManager
class will automatically check if the specified credentials already exist and will use those to login; it’ll also delete the anonymous account that is no longer needed and report everything back to you.When the user has made a choice, pass either true
or false
to get the same value circled back to your code after the login procedure has completed successfully.
When the user has made a choice, pass either true
or false
to get the same value circled back to your code after the sign in procedure completed successfully.
To support the migration, all login methods return an instance of LoginDescriptor
which gives you the allowMigration
parameter that you’ve passed, the User ID of the anonymous account, and the User ID of the account that is now logged-in. With this information, you can go ahead and migrate the data from the anonymous account to the newly logged-in account.
To support the migration, all sign in methods return an instance of LoginDescriptor
which gives you the allowMigration
parameter that you’ve passed, the User ID of the anonymous account, and the User ID of the account that is now logged-in. With this information, you can go ahead and migrate the data from the anonymous account to the newly logged-in account.
If you are thinking of providing alternatives ways to login into your app, RxFireAuth’s got you covered.
+If you are thinking of providing alternative ways to login into your app, RxFireAuth’s got you covered.
-When signing in with an external provider, it is always good to just let the user sign-in and then figure out later if this is their first time or not. Additionally, it is common practice to let people connect different providers along with their email and password credentials. Giving people flexibility is always a good choice.
+When signing in with an external provider, it is always good to just let the user sign in and then figure out later if this is their first time or not. Additionally, it is common practice to let people connect different providers along with their email and password credentials. Giving people flexibility is always a good choice.
-Let’s use the same short story from before, but Mike is now going to use Sign-in with Apple.
+Let’s use the same short story from before, but Mike is now going to use Sign in with Apple.
When using Sign-in with Apple (or any other provider, such as Google), you’ll find yourself in one of these cases:
-With RxFireAuth’s login
method family, all of these cases are handled automagically for you.
All of these cases are handled automatically for you by calling:
+All of the possible cases are handled automatically for you by calling:
func signInWithApple(in viewController: UIViewController, updateUserDisplayName: Bool, allowMigration: Bool?) -> Single<LoginDescriptor>
@@ -224,30 +300,41 @@ These functions are available in implementations of LoginProviderManagerType
, such as the UserManager
class that we’re already using.
You can use the updateUserDisplayName
parameter to automatically set the Firebase User displayName
property to the full name associated with the provider account. Keep in mind that some providers, such as Apple, allow the user to change this information while signing-in for the first time.
You can use the updateUserDisplayName
parameter to automatically set the Firebase User displayName
property to the full name associated with the provider account. Keep in mind that some providers, such as Apple, allow the user to change this information while signing in for the first time and may return it for new users only that have never signed into your app before.
This function will behave as the normal login, returning UserError.migrationRequired
, if an anonymous account is going to be deleted and allowMigration
is not set. When this happens, you can use the following function to continue signing-in after having asked the user what they would like to do:
This function will behave as the normal sign in, returning UserError.migrationRequired
, if an anonymous account will have to be deleted and allowMigration
is not set. When this happens, you can use the following function to continue signing in after having asked the user what they’d like to do:
func login(with credentials: LoginCredentials, updateUserDisplayName: Bool, allowMigration: Bool?) -> Single<LoginDescriptor>
The login credentials are embedded in the migrationRequired
error and, except for particular cases, you shouldn’t need to inspect them.
If you don’t want to support the anonymous authentication, you can use this library anyway as all of the methods are built to work even when no account is logged-in.
+You can get the profile of the currently logged-in user by calling:
+self.userManager.user
+
-You can make explicit calls to:
-func register(email: String, password: String) -> Completable
+or by subscribing to:
+self.userManager.autoupdatingUser
-and to:
-func loginWithoutChecking(email: String, password: String, allowMigration: Bool?) -> Single<LoginDescriptor>
+This Observable will emit new values every time something on the user profile has changed.
+
+Once signed in, you can inspect the authentication providers of the user by cycling through the authenticationProviders
array of the UserData
instance. For a list of the supported providers, see the Provider
enum, in LoginCredentials
.
+Authentication Confirmation
+
+When performing sensitive actions, such as changing the user password, linking new authentication providers or deleting the user account, Firebase will require you to get a new refresh token by forcing the user to login again. RxFireAuth offers convenient methods to confirm the authentication using one the supported providers.
+
+You can confirm the authentication using email and password:
+func confirmAuthentication(email: String, password: String) -> Completable
-and also to:
-func linkAnonymousAccount(toEmail email: String, password: String) -> Completable
+Sign in with Apple:
+func confirmAuthenticationWithApple(in viewController: UIViewController) -> Completable
-These methods will bypass the logic around anonymous and existing/non-existing accounts and will let you use the bare Firebase SDK through RxSwift.
+or Google Sign In:
+func confirmAuthenticationWithGoogle(as clientId: String, in viewController: UIViewController) -> Completable
+
Documentation
Always refer to the UserManagerType
and LoginProviderManagerType
protocols in your code, because the UserManager
implementation may introduce breaking changes over time even if the library major version hasn’t changed.
@@ -257,16 +344,25 @@ Documentation
You can find the autogenerated documentation here.
Compatibility
-RxFireAuth targets iOS 9.0 or later and has the following dependencies:
+RxFireAuth targets iOS 9.0 or later and macOS 10.11 or later and has the following shared dependencies:
Firebase/Auth
version 6.5.
-GoogleSignIn
version 5.0.2.
JWTDecode
version 2.4.
RxCocoa
version 5.
-Compatibility with macOS is planned. Don’t hesitate to open an issue to prioritize it.
+On iOS, when included via CocoaPods, it also needs:
+
+
+GoogleSignIn
version 5.0.2.
+
+
+On macOS and when included via Swift Package Manager, GoogleSignIn
is replaced by:
+
+
+AppAuth
version 1.4.
+
Contributions
All contributions to expand the library are welcome. Fork the repo, make the changes you want, and open a Pull Request.
@@ -284,8 +380,8 @@ License