diff --git a/FirebaseUI.podspec b/FirebaseUI.podspec index f4b892defdf..992eb148f40 100644 --- a/FirebaseUI.podspec +++ b/FirebaseUI.podspec @@ -1,21 +1,29 @@ Pod::Spec.new do |s| s.name = "FirebaseUI" - s.version = "0.3.0" + s.version = "0.3.1" s.summary = "UI binding libraries for Firebase." s.homepage = "https://github.com/firebase/FirebaseUI-iOS" s.license = { :type => 'MIT', :file => 'LICENSE' } s.author = { "Firebase" => "support@firebase.com" } s.social_media_url = "https://twitter.com/firebase" - s.source = { :git => "https://github.com/firebase/FirebaseUI-iOS.git", :tag => 'v0.3.0' } - s.source_files = "FirebaseUI/**/*.{h,m}" - s.resources = "FirebaseUI/**/Resources/*" - s.dependency "Firebase", "~>2.2" - s.dependency "FBSDKCoreKit" - s.dependency "FBSDKLoginKit" - s.dependency "Google/SignIn" + s.source = { :git => "https://github.com/firebase/FirebaseUI-iOS.git", :tag => 'v0.3.1' } s.platform = :ios s.ios.deployment_target = "8.0" - s.ios.framework = "UIKit", "Accounts" + s.dependency "Firebase", "~>2.2" + s.ios.framework = "UIKit" s.xcconfig = { 'FRAMEWORK_SEARCH_PATHS' => '"$(PODS_ROOT)/Firebase"' } s.requires_arc = true -end + + s.subspec 'Core' do |core| + core.source_files = "FirebaseUI/{Core,Util}/**/*.{h,m}" + end + + s.subspec 'Auth' do |auth| + auth.source_files = "FirebaseUI/Auth/**/*.{h,m}" + auth.resources = "FirebaseUI/Auth/Resources/*" + auth.dependency "FBSDKCoreKit" + auth.dependency "FBSDKLoginKit" + auth.dependency "Google/SignIn" + auth.ios.framework = "Accounts" + end + end diff --git a/FirebaseUI.xcodeproj/project.pbxproj b/FirebaseUI.xcodeproj/project.pbxproj index 9648c54037c..668075d4c97 100644 --- a/FirebaseUI.xcodeproj/project.pbxproj +++ b/FirebaseUI.xcodeproj/project.pbxproj @@ -23,7 +23,6 @@ /* Begin PBXBuildFile section */ BB372B551B8BE4890046905E /* FirebaseTwitterAuthProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = BB372B541B8BE4890046905E /* FirebaseTwitterAuthProvider.m */; }; - BB372B5B1B8CF7DC0046905E /* FirebaseAuthDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = BB372B5A1B8CF7DC0046905E /* FirebaseAuthDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; }; BB372B601B8D1B580046905E /* FirebaseTwitterAuthProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = BB372B531B8BE4510046905E /* FirebaseTwitterAuthProvider.h */; settings = {ATTRIBUTES = (Public, ); }; }; BB4877901BA8A0C000FD3D4D /* GoogleSignIn.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BB48778F1BA8A0C000FD3D4D /* GoogleSignIn.framework */; }; BB48779B1BA8A0D600FD3D4D /* Core.h in Headers */ = {isa = PBXBuildFile; fileRef = BB4877931BA8A0D600FD3D4D /* Core.h */; }; @@ -41,13 +40,13 @@ BBF6D4161BA19CDF00C644A7 /* FirebaseFacebookAuthProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = BB6AC2131BA06AC300A10461 /* FirebaseFacebookAuthProvider.h */; settings = {ATTRIBUTES = (Public, ); }; }; BBF6D41B1BA1FFAD00C644A7 /* FirebaseGoogleAuthProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = BBF6D41A1BA1FFAD00C644A7 /* FirebaseGoogleAuthProvider.m */; }; BBF6D5771BA345E600C644A7 /* FirebaseAuthProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = BBF6D5761BA33AC300C644A7 /* FirebaseAuthProvider.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D809A11E1BF67095000257AA /* FirebaseAuthConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = D809A11D1BF67095000257AA /* FirebaseAuthConstants.m */; settings = {ASSET_TAGS = (); }; }; + D809A11E1BF67095000257AA /* FirebaseAuthConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = D809A11D1BF67095000257AA /* FirebaseAuthConstants.m */; }; D809A1271BF6FF6C000257AA /* FirebaseLoginViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = D809A1241BF6FF6C000257AA /* FirebaseLoginViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D809A1311BF7ECB0000257AA /* FirebaseLoginViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D809A1301BF7ECB0000257AA /* FirebaseLoginViewController.m */; settings = {ASSET_TAGS = (); }; }; - D809A1661BFBAC7F000257AA /* FirebaseLoginViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = D809A1651BFBAC7F000257AA /* FirebaseLoginViewController.xib */; settings = {ASSET_TAGS = (); }; }; - D809A16A1BFBAECA000257AA /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D809A1691BFBAECA000257AA /* Assets.xcassets */; settings = {ASSET_TAGS = (); }; }; + D809A1311BF7ECB0000257AA /* FirebaseLoginViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D809A1301BF7ECB0000257AA /* FirebaseLoginViewController.m */; }; + D809A1661BFBAC7F000257AA /* FirebaseLoginViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = D809A1651BFBAC7F000257AA /* FirebaseLoginViewController.xib */; }; + D809A16A1BFBAECA000257AA /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D809A1691BFBAECA000257AA /* Assets.xcassets */; }; D809A16D1BFBE242000257AA /* FirebaseLoginButton.h in Headers */ = {isa = PBXBuildFile; fileRef = D809A16B1BFBE242000257AA /* FirebaseLoginButton.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D809A1701BFBE5F9000257AA /* FirebaseLoginButton.m in Sources */ = {isa = PBXBuildFile; fileRef = D809A16F1BFBE5F9000257AA /* FirebaseLoginButton.m */; settings = {ASSET_TAGS = (); }; }; + D809A1701BFBE5F9000257AA /* FirebaseLoginButton.m in Sources */ = {isa = PBXBuildFile; fileRef = D809A16F1BFBE5F9000257AA /* FirebaseLoginButton.m */; }; D809A1721BFCF23B000257AA /* Accounts.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D809A1711BFCF23B000257AA /* Accounts.framework */; }; D8124F441B72C94E003441AD /* Firebase.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D8124F401B72A90C003441AD /* Firebase.framework */; }; D81495F11BF5AF280099AE10 /* FirebaseArray.h in Headers */ = {isa = PBXBuildFile; fileRef = D81495EB1BF5AF280099AE10 /* FirebaseArray.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -55,14 +54,13 @@ D81495F31BF5AF280099AE10 /* FirebaseCollectionViewDataSource.h in Headers */ = {isa = PBXBuildFile; fileRef = D81495ED1BF5AF280099AE10 /* FirebaseCollectionViewDataSource.h */; settings = {ATTRIBUTES = (Public, ); }; }; D81495F41BF5AF280099AE10 /* FirebaseDataSource.h in Headers */ = {isa = PBXBuildFile; fileRef = D81495EE1BF5AF280099AE10 /* FirebaseDataSource.h */; settings = {ATTRIBUTES = (Public, ); }; }; D81495F51BF5AF280099AE10 /* FirebaseTableViewDataSource.h in Headers */ = {isa = PBXBuildFile; fileRef = D81495EF1BF5AF280099AE10 /* FirebaseTableViewDataSource.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D81495F61BF5AF280099AE10 /* FirebaseUI.h in Headers */ = {isa = PBXBuildFile; fileRef = D81495F01BF5AF280099AE10 /* FirebaseUI.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D81495FC1BF5AF460099AE10 /* FirebaseArray.m in Sources */ = {isa = PBXBuildFile; fileRef = D81495F71BF5AF460099AE10 /* FirebaseArray.m */; settings = {ASSET_TAGS = (); }; }; - D81495FD1BF5AF460099AE10 /* FirebaseCollectionViewDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = D81495F81BF5AF460099AE10 /* FirebaseCollectionViewDataSource.m */; settings = {ASSET_TAGS = (); }; }; - D81495FE1BF5AF460099AE10 /* FirebaseDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = D81495F91BF5AF460099AE10 /* FirebaseDataSource.m */; settings = {ASSET_TAGS = (); }; }; - D81495FF1BF5AF460099AE10 /* FirebaseTableViewDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = D81495FA1BF5AF460099AE10 /* FirebaseTableViewDataSource.m */; settings = {ASSET_TAGS = (); }; }; - D81496001BF5AF460099AE10 /* FirebaseUI.m in Sources */ = {isa = PBXBuildFile; fileRef = D81495FB1BF5AF460099AE10 /* FirebaseUI.m */; settings = {ASSET_TAGS = (); }; }; - D81496061BF5B92C0099AE10 /* FirebasePasswordAuthProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = D81496051BF5B92C0099AE10 /* FirebasePasswordAuthProvider.m */; settings = {ASSET_TAGS = (); }; }; + D81495FC1BF5AF460099AE10 /* FirebaseArray.m in Sources */ = {isa = PBXBuildFile; fileRef = D81495F71BF5AF460099AE10 /* FirebaseArray.m */; }; + D81495FD1BF5AF460099AE10 /* FirebaseCollectionViewDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = D81495F81BF5AF460099AE10 /* FirebaseCollectionViewDataSource.m */; }; + D81495FE1BF5AF460099AE10 /* FirebaseDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = D81495F91BF5AF460099AE10 /* FirebaseDataSource.m */; }; + D81495FF1BF5AF460099AE10 /* FirebaseTableViewDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = D81495FA1BF5AF460099AE10 /* FirebaseTableViewDataSource.m */; }; + D81496061BF5B92C0099AE10 /* FirebasePasswordAuthProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = D81496051BF5B92C0099AE10 /* FirebasePasswordAuthProvider.m */; }; D81496071BF5B9BE0099AE10 /* FirebasePasswordAuthProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = D81496041BF5B9110099AE10 /* FirebasePasswordAuthProvider.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D8680D901C0631FD001987EB /* FirebaseAuthDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = D8680D8F1C0631FD001987EB /* FirebaseAuthDelegate.h */; }; D87943371BF51FF000525DFD /* FirebaseAuthProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = D87943361BF51FF000525DFD /* FirebaseAuthProvider.m */; }; D87943461BF59E1F00525DFD /* FirebaseAuthConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = D879433E1BF5654000525DFD /* FirebaseAuthConstants.h */; settings = {ATTRIBUTES = (Public, ); }; }; D87943471BF59E4F00525DFD /* TwitterAuthDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = D879433D1BF5593800525DFD /* TwitterAuthDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -97,7 +95,6 @@ /* Begin PBXFileReference section */ BB372B531B8BE4510046905E /* FirebaseTwitterAuthProvider.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FirebaseTwitterAuthProvider.h; path = Auth/API/FirebaseTwitterAuthProvider.h; sourceTree = ""; }; BB372B541B8BE4890046905E /* FirebaseTwitterAuthProvider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FirebaseTwitterAuthProvider.m; path = Auth/Implementation/FirebaseTwitterAuthProvider.m; sourceTree = ""; }; - BB372B5A1B8CF7DC0046905E /* FirebaseAuthDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FirebaseAuthDelegate.h; path = Auth/Implementation/FirebaseAuthDelegate.h; sourceTree = ""; }; BB48778F1BA8A0C000FD3D4D /* GoogleSignIn.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GoogleSignIn.framework; path = sdk/google_signin_sdk_2_2_0/GoogleSignIn.framework; sourceTree = ""; }; BB4877931BA8A0D600FD3D4D /* Core.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Core.h; sourceTree = ""; }; BB4877941BA8A0D600FD3D4D /* GGLConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GGLConfiguration.h; sourceTree = ""; }; @@ -128,14 +125,13 @@ D81495ED1BF5AF280099AE10 /* FirebaseCollectionViewDataSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FirebaseCollectionViewDataSource.h; path = Core/API/FirebaseCollectionViewDataSource.h; sourceTree = ""; }; D81495EE1BF5AF280099AE10 /* FirebaseDataSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FirebaseDataSource.h; path = Core/API/FirebaseDataSource.h; sourceTree = ""; }; D81495EF1BF5AF280099AE10 /* FirebaseTableViewDataSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FirebaseTableViewDataSource.h; path = Core/API/FirebaseTableViewDataSource.h; sourceTree = ""; }; - D81495F01BF5AF280099AE10 /* FirebaseUI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FirebaseUI.h; path = Core/API/FirebaseUI.h; sourceTree = ""; }; D81495F71BF5AF460099AE10 /* FirebaseArray.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FirebaseArray.m; path = Core/Implementation/FirebaseArray.m; sourceTree = ""; }; D81495F81BF5AF460099AE10 /* FirebaseCollectionViewDataSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FirebaseCollectionViewDataSource.m; path = Core/Implementation/FirebaseCollectionViewDataSource.m; sourceTree = ""; }; D81495F91BF5AF460099AE10 /* FirebaseDataSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FirebaseDataSource.m; path = Core/Implementation/FirebaseDataSource.m; sourceTree = ""; }; D81495FA1BF5AF460099AE10 /* FirebaseTableViewDataSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FirebaseTableViewDataSource.m; path = Core/Implementation/FirebaseTableViewDataSource.m; sourceTree = ""; }; - D81495FB1BF5AF460099AE10 /* FirebaseUI.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FirebaseUI.m; path = Core/Implementation/FirebaseUI.m; sourceTree = ""; }; D81496041BF5B9110099AE10 /* FirebasePasswordAuthProvider.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FirebasePasswordAuthProvider.h; path = Auth/API/FirebasePasswordAuthProvider.h; sourceTree = ""; }; D81496051BF5B92C0099AE10 /* FirebasePasswordAuthProvider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FirebasePasswordAuthProvider.m; path = Auth/Implementation/FirebasePasswordAuthProvider.m; sourceTree = ""; }; + D8680D8F1C0631FD001987EB /* FirebaseAuthDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FirebaseAuthDelegate.h; path = Auth/API/FirebaseAuthDelegate.h; sourceTree = ""; }; D87943361BF51FF000525DFD /* FirebaseAuthProvider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FirebaseAuthProvider.m; path = Auth/Implementation/FirebaseAuthProvider.m; sourceTree = ""; }; D879433D1BF5593800525DFD /* TwitterAuthDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = TwitterAuthDelegate.h; path = Auth/API/TwitterAuthDelegate.h; sourceTree = ""; }; D879433E1BF5654000525DFD /* FirebaseAuthConstants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FirebaseAuthConstants.h; path = Auth/API/FirebaseAuthConstants.h; sourceTree = ""; }; @@ -185,13 +181,13 @@ BB372B4D1B8BE33A0046905E /* API */ = { isa = PBXGroup; children = ( + D8680D8F1C0631FD001987EB /* FirebaseAuthDelegate.h */, BB372B531B8BE4510046905E /* FirebaseTwitterAuthProvider.h */, BB6AC2131BA06AC300A10461 /* FirebaseFacebookAuthProvider.h */, BBF6D4191BA1FF9200C644A7 /* FirebaseGoogleAuthProvider.h */, D81496041BF5B9110099AE10 /* FirebasePasswordAuthProvider.h */, BBF6D5761BA33AC300C644A7 /* FirebaseAuthProvider.h */, D879433E1BF5654000525DFD /* FirebaseAuthConstants.h */, - BB372B5A1B8CF7DC0046905E /* FirebaseAuthDelegate.h */, D879433D1BF5593800525DFD /* TwitterAuthDelegate.h */, BB62DD091BA6F3A1001BD539 /* FirebaseAppDelegate.h */, D809A1241BF6FF6C000257AA /* FirebaseLoginViewController.h */, @@ -287,7 +283,6 @@ D81495ED1BF5AF280099AE10 /* FirebaseCollectionViewDataSource.h */, D81495EE1BF5AF280099AE10 /* FirebaseDataSource.h */, D81495EF1BF5AF280099AE10 /* FirebaseTableViewDataSource.h */, - D81495F01BF5AF280099AE10 /* FirebaseUI.h */, ); name = API; sourceTree = ""; @@ -299,7 +294,6 @@ D81495F81BF5AF460099AE10 /* FirebaseCollectionViewDataSource.m */, D81495F91BF5AF460099AE10 /* FirebaseDataSource.m */, D81495FA1BF5AF460099AE10 /* FirebaseTableViewDataSource.m */, - D81495FB1BF5AF460099AE10 /* FirebaseUI.m */, ); name = Implementation; sourceTree = ""; @@ -350,8 +344,6 @@ D87943471BF59E4F00525DFD /* TwitterAuthDelegate.h in Headers */, BB48779D1BA8A0D600FD3D4D /* GGLContext.h in Headers */, D87943461BF59E1F00525DFD /* FirebaseAuthConstants.h in Headers */, - D81495F61BF5AF280099AE10 /* FirebaseUI.h in Headers */, - BB372B5B1B8CF7DC0046905E /* FirebaseAuthDelegate.h in Headers */, BB62DD7A1BA6F84C001BD539 /* FirebaseAppDelegate.h in Headers */, D81495F41BF5AF280099AE10 /* FirebaseDataSource.h in Headers */, D81495F51BF5AF280099AE10 /* FirebaseTableViewDataSource.h in Headers */, @@ -365,6 +357,7 @@ BB4877A01BA8A0D600FD3D4D /* SignIn.h in Headers */, BB372B601B8D1B580046905E /* FirebaseTwitterAuthProvider.h in Headers */, BB48779F1BA8A0D600FD3D4D /* GGLContext+SignIn.h in Headers */, + D8680D901C0631FD001987EB /* FirebaseAuthDelegate.h in Headers */, BBF6D4161BA19CDF00C644A7 /* FirebaseFacebookAuthProvider.h in Headers */, D809A1271BF6FF6C000257AA /* FirebaseLoginViewController.h in Headers */, D81496071BF5B9BE0099AE10 /* FirebasePasswordAuthProvider.h in Headers */, @@ -493,7 +486,6 @@ D81495FF1BF5AF460099AE10 /* FirebaseTableViewDataSource.m in Sources */, D809A11E1BF67095000257AA /* FirebaseAuthConstants.m in Sources */, BBF6D41B1BA1FFAD00C644A7 /* FirebaseGoogleAuthProvider.m in Sources */, - D81496001BF5AF460099AE10 /* FirebaseUI.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/FirebaseUI/Auth/API/FirebaseAuthConstants.h b/FirebaseUI/Auth/API/FirebaseAuthConstants.h index d88ccb388ea..78c9a29335f 100644 --- a/FirebaseUI/Auth/API/FirebaseAuthConstants.h +++ b/FirebaseUI/Auth/API/FirebaseAuthConstants.h @@ -36,20 +36,12 @@ #ifndef FirebaseAuthConstants_h #define FirebaseAuthConstants_h -FOUNDATION_EXPORT NSString *const kFWPRequestType; - -FOUNDATION_EXPORT NSString *const kTwitterAuthProvider; FOUNDATION_EXPORT NSString *const kTwitterApiKey; -FOUNDATION_EXPORT NSString *const kFacebookAuthProvider; FOUNDATION_EXPORT NSString *const kFacebookAppId; FOUNDATION_EXPORT NSString *const kFacebookDisplayName; FOUNDATION_EXPORT NSString *const kFacebookEmailScope; -FOUNDATION_EXPORT NSString *const kGoogleAuthProvider; - -FOUNDATION_EXPORT NSString *const kPasswordAuthProvider; - FOUNDATION_EXPORT CGFloat const kHeaderWidth; FOUNDATION_EXPORT CGFloat const kHeaderHeight; FOUNDATION_EXPORT CGFloat const kHeaderSpace; @@ -66,4 +58,11 @@ FOUNDATION_EXPORT CGFloat const kSeparatorWidth; FOUNDATION_EXPORT CGFloat const kSeparatorHeight; FOUNDATION_EXPORT CGFloat const kSeparatorSpace; +typedef NS_ENUM(NSInteger, FAuthProvider) { + FAuthProviderFacebook, + FAuthProviderGoogle, + FAuthProviderTwitter, + FAuthProviderPassword +}; + #endif /* FirebaseAuthConstants_h */ diff --git a/FirebaseUI/Auth/Implementation/FirebaseAuthDelegate.h b/FirebaseUI/Auth/API/FirebaseAuthDelegate.h similarity index 100% rename from FirebaseUI/Auth/Implementation/FirebaseAuthDelegate.h rename to FirebaseUI/Auth/API/FirebaseAuthDelegate.h diff --git a/FirebaseUI/Auth/API/FirebaseAuthProvider.h b/FirebaseUI/Auth/API/FirebaseAuthProvider.h index 713638976ef..4462d974d5c 100644 --- a/FirebaseUI/Auth/API/FirebaseAuthProvider.h +++ b/FirebaseUI/Auth/API/FirebaseAuthProvider.h @@ -54,10 +54,10 @@ @property(strong, nonatomic) FAuthData *authData; /** - * A string which represents the chosen authentication provider. + * An enum which represents the chosen authentication provider. * See FAuthenticationConstants.h for a full list. */ -@property(strong, nonatomic) NSString *provider; +@property(nonatomic) FAuthProvider provider; /** * FirebaseAuthDelegate delegate to handle all login, logout, and error events diff --git a/FirebaseUI/Auth/API/FirebaseLoginButton.h b/FirebaseUI/Auth/API/FirebaseLoginButton.h index 4f14363cf66..5b2e5c5a0a3 100644 --- a/FirebaseUI/Auth/API/FirebaseLoginButton.h +++ b/FirebaseUI/Auth/API/FirebaseLoginButton.h @@ -42,15 +42,15 @@ @interface FirebaseLoginButton : UIButton /** - * A string representing a valid identity provider (see FirebaseAuthConstants.h for a full list). + * An enum representing a valid identity provider (see FirebaseAuthConstants.h for a full list). */ -@property(strong, nonatomic) NSString *provider; +@property(nonatomic) FAuthProvider provider; /** * Creates a button styled for the appropriate provider. - * @param provider A string representing the desired identity provider to log in with + * @param provider An enum representing the desired identity provider to log in with * @return FirebaseLoginButton */ -- (instancetype)initWithProvider:(NSString *)provider; +- (instancetype)initWithProvider:(FAuthProvider)provider; @end diff --git a/FirebaseUI/Auth/API/FirebaseLoginViewController.h b/FirebaseUI/Auth/API/FirebaseLoginViewController.h index 9be0abeac0e..a747fed43a4 100644 --- a/FirebaseUI/Auth/API/FirebaseLoginViewController.h +++ b/FirebaseUI/Auth/API/FirebaseLoginViewController.h @@ -113,6 +113,11 @@ */ @property(weak, nonatomic) IBOutlet NSLayoutConstraint *totalHeightConstraint; +/** + * Dismissal callback on success or failure. + */ +@property (nonatomic, copy) void (^dismissCallback)(FAuthData *user, NSError *error); + /** * The Firebase database reference which to authenticate against. */ @@ -157,10 +162,18 @@ /** * Enables a given identity provider and allows for login and logout actions against it. - * @param provider A string representing the desired identity provider to log in with + * @param provider An enum representing the desired identity provider to log in with * @return FirebaseLoginViewController */ -- (instancetype)enableProvider:(NSString *)provider; +- (instancetype)enableProvider:(FAuthProvider)provider; + +/** + * Callback that fires when after the controller is dismissed (either on success or on failure). + * If successful, the user field will be populated; if an error occurred the error field will be populated. + * @param callback A block that returns a user on success or an error on failure. + * @return void + */ +- (void)didDismissWithBlock:(void (^)(FAuthData *user, NSError *error))callback; /** * Logs the currently authenticated user out of both Firebase and the currently logged in identity diff --git a/FirebaseUI/Auth/Implementation/FirebaseAuthConstants.m b/FirebaseUI/Auth/Implementation/FirebaseAuthConstants.m index c976d148c69..bb8f866b287 100644 --- a/FirebaseUI/Auth/Implementation/FirebaseAuthConstants.m +++ b/FirebaseUI/Auth/Implementation/FirebaseAuthConstants.m @@ -20,7 +20,7 @@ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * EVENT SHALL FIREBASE BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,f * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE @@ -32,18 +32,12 @@ #import "FirebaseAuthConstants.h" -NSString *const kTwitterAuthProvider = @"twitter"; NSString *const kTwitterApiKey = @"TwitterApiKey"; -NSString *const kFacebookAuthProvider = @"facebook"; NSString *const kFacebookAppId = @"FacebookAppID"; NSString *const kFacebookDisplayName = @"FacebookDisplayName"; NSString *const kFacebookEmailScope = @"email"; -NSString *const kGoogleAuthProvider = @"google"; - -NSString *const kPasswordAuthProvider = @"password"; - CGFloat const kHeaderWidth = 258.0f; CGFloat const kHeaderHeight = 60.0f; CGFloat const kHeaderSpace = 10.0f; diff --git a/FirebaseUI/Auth/Implementation/FirebaseFacebookAuthProvider.m b/FirebaseUI/Auth/Implementation/FirebaseFacebookAuthProvider.m index 1d97c01c52f..794d7c7c752 100644 --- a/FirebaseUI/Auth/Implementation/FirebaseFacebookAuthProvider.m +++ b/FirebaseUI/Auth/Implementation/FirebaseFacebookAuthProvider.m @@ -39,7 +39,7 @@ @implementation FirebaseFacebookAuthProvider { - (instancetype)initWithRef:(Firebase *)ref authDelegate:(id)authDelegate { self = [super initWithRef:ref authDelegate:authDelegate]; if (self) { - self.provider = kFacebookAuthProvider; + self.provider = FAuthProviderFacebook; [self configureProvider]; } return self; @@ -77,7 +77,7 @@ - (void)login { NSString *accessToken = [[FBSDKAccessToken currentAccessToken] tokenString]; - [self.ref authWithOAuthProvider:kFacebookAuthProvider + [self.ref authWithOAuthProvider:@"facebook" token:accessToken withCompletionBlock:^(NSError *error, FAuthData *authData) { if (error) { diff --git a/FirebaseUI/Auth/Implementation/FirebaseGoogleAuthProvider.m b/FirebaseUI/Auth/Implementation/FirebaseGoogleAuthProvider.m index 95c2166908b..988229a4b0a 100644 --- a/FirebaseUI/Auth/Implementation/FirebaseGoogleAuthProvider.m +++ b/FirebaseUI/Auth/Implementation/FirebaseGoogleAuthProvider.m @@ -39,7 +39,7 @@ - (instancetype)initWithRef:(Firebase *)ref uiDelegate:(UIViewController *)uiDelegate { self = [super initWithRef:ref authDelegate:authDelegate]; if (self) { - self.provider = kGoogleAuthProvider; + self.provider = FAuthProviderGoogle; [self configureProvider]; [GIDSignIn sharedInstance].delegate = self; [GIDSignIn sharedInstance].uiDelegate = uiDelegate; @@ -79,7 +79,7 @@ - (void)logout { - (void)signIn:(GIDSignIn *)signIn didSignInForUser:(GIDGoogleUser *)user withError:(NSError *)error { - [self.ref authWithOAuthProvider:kGoogleAuthProvider + [self.ref authWithOAuthProvider:@"google" token:user.authentication.accessToken withCompletionBlock:^(NSError *error, FAuthData *authData) { if (error) { diff --git a/FirebaseUI/Auth/Implementation/FirebaseLoginButton.m b/FirebaseUI/Auth/Implementation/FirebaseLoginButton.m index 9115aeeb8c5..85b2ea52796 100644 --- a/FirebaseUI/Auth/Implementation/FirebaseLoginButton.m +++ b/FirebaseUI/Auth/Implementation/FirebaseLoginButton.m @@ -34,7 +34,7 @@ @implementation FirebaseLoginButton -- (instancetype)initWithProvider:(NSString *)provider { +- (instancetype)initWithProvider:(FAuthProvider)provider { self = [super initWithFrame:CGRectZero]; if (self) { self.provider = provider; @@ -45,43 +45,63 @@ - (instancetype)initWithProvider:(NSString *)provider { return self; } -- (UIColor *)backgroundColorForProvider:(NSString *)provider { - if ([provider isEqualToString:kGoogleAuthProvider]) { - return [UIColor colorWithRed:221.0f / 255.0f - green:75.0f / 255.0f - blue:57.0f / 255.0f - alpha:255.0f / 255.0f]; - } else if ([provider isEqualToString:kFacebookAuthProvider]) { - return [UIColor colorWithRed:59.0f / 255.0f - green:89.0f / 255.0f - blue:152.0f / 255.0f - alpha:255.0f / 255.0f]; - } else if ([provider isEqualToString:kTwitterAuthProvider]) { - return [UIColor colorWithRed:0.0f / 255.0f - green:172.0f / 255.0f - blue:237.0f / 255.0f - alpha:255.0f / 255.0f]; - } else if ([provider isEqualToString:kPasswordAuthProvider]) { - return [UIColor colorWithRed:22.0f / 255.0f - green:150.0f / 255.0f - blue:243.0f / 255.0f - alpha:255.0f / 255.0f]; - } else { - return [UIColor blackColor]; +- (UIColor *)backgroundColorForProvider:(FAuthProvider)provider { + switch (provider) { + case FAuthProviderFacebook: + return [UIColor colorWithRed:59.0f / 255.0f + green:89.0f / 255.0f + blue:152.0f / 255.0f + alpha:255.0f / 255.0f]; + break; + + case FAuthProviderGoogle: + return [UIColor colorWithRed:221.0f / 255.0f + green:75.0f / 255.0f + blue:57.0f / 255.0f + alpha:255.0f / 255.0f]; + break; + + case FAuthProviderTwitter: + return [UIColor colorWithRed:0.0f / 255.0f + green:172.0f / 255.0f + blue:237.0f / 255.0f + alpha:255.0f / 255.0f]; + break; + + case FAuthProviderPassword: + return [UIColor colorWithRed:22.0f / 255.0f + green:150.0f / 255.0f + blue:243.0f / 255.0f + alpha:255.0f / 255.0f]; + break; + + default: + return [UIColor blackColor]; + break; } } -- (NSString *)titleForProvider:(NSString *)provider { - if ([provider isEqualToString:kGoogleAuthProvider]) { - return @"Google"; - } else if ([provider isEqualToString:kFacebookAuthProvider]) { - return @"Facebook"; - } else if ([provider isEqualToString:kTwitterAuthProvider]) { - return @"Twitter"; - } else if ([provider isEqualToString:kPasswordAuthProvider]) { - return @"Login"; - } else { - return @"Unknown Provider"; +- (NSString *)titleForProvider:(FAuthProvider)provider { + switch (provider) { + case FAuthProviderFacebook: + return @"Facebook"; + break; + + case FAuthProviderGoogle: + return @"Google"; + break; + + case FAuthProviderTwitter: + return @"Twitter"; + break; + + case FAuthProviderPassword: + return @"Log In"; + break; + + default: + return @"Unknown Provider"; + break; } } diff --git a/FirebaseUI/Auth/Implementation/FirebaseLoginViewController.m b/FirebaseUI/Auth/Implementation/FirebaseLoginViewController.m index 19fb7b0912f..6109e1b31eb 100644 --- a/FirebaseUI/Auth/Implementation/FirebaseLoginViewController.m +++ b/FirebaseUI/Auth/Implementation/FirebaseLoginViewController.m @@ -42,6 +42,7 @@ - (instancetype)initWithRef:(Firebase *)ref; self = [super init]; if (self) { self.ref = ref; + self.dismissCallback = ^(FAuthData *user, NSError *error){}; _socialProviders = [[NSMutableArray alloc] initWithCapacity:3]; } return self; @@ -50,6 +51,12 @@ - (instancetype)initWithRef:(Firebase *)ref; - (void)viewDidLoad { [super viewDidLoad]; + // Throw an exception if no IDPs are enabled + if (self.passwordAuthProvider == nil && [_socialProviders count] == 0) { + [NSException raise:NSInternalInconsistencyException + format:@"Please enable at least one authentication provider in your FirebaseLoginViewController"]; + } + // Add cancel button UIImage *image = [[UIImage imageNamed:@"ic_clear_18pt"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; @@ -57,22 +64,18 @@ - (void)viewDidLoad { self.cancelButton.imageView.tintColor = [UIColor colorWithRed:158.0f / 255.0f green:158.0f / 255.0f blue:158.0f / 255.0f alpha:1.0f]; [self.cancelButton addTarget:self - action:@selector(dismissViewController) + action:@selector(cancelButtonPressed) forControlEvents:UIControlEventTouchUpInside]; - // If we're already logged in, cancel this + // If we're already logged in, dismiss the view controller and return the currently logged in user if (_selectedAuthProvider) { - [self dismissViewController]; - } - - if (self.passwordAuthProvider == nil && [_socialProviders count] == 0) { - [self dismissViewController]; // Or throw an exception--you need to have at least one provider + [self dismissViewControllerWithUser:self.currentUser andError:nil]; } // Populate email/password view if (self.passwordAuthProvider != nil) { FirebaseLoginButton *emailLoginButton = - [[FirebaseLoginButton alloc] initWithProvider:kPasswordAuthProvider]; + [[FirebaseLoginButton alloc] initWithProvider:FAuthProviderPassword]; CGRect buttonFrame = CGRectMake(0, 2 * kTextFieldHeight + 2 * kTextFieldSpace, kButtonWidth, kButtonHeight); emailLoginButton.frame = buttonFrame; @@ -94,7 +97,7 @@ - (void)viewDidLoad { NSUInteger numProviders = [_socialProviders count]; if (numProviders == 0) { [self.socialView removeFromSuperview]; - self.totalHeightConstraint.constant -= (3 * kButtonHeight + 2 * kButtonSpace); + self.totalHeightConstraint.constant -= (3 * kButtonHeight + 3 * kButtonSpace); } else { // Add buttons to social view CGRect buttonFrame = CGRectMake(0, 0, kButtonWidth, kButtonHeight); @@ -125,49 +128,76 @@ - (void)viewDidLoad { [self.view layoutIfNeeded]; } -- (instancetype)enableProvider:(NSString *)provider { - if ([provider isEqualToString:kGoogleAuthProvider]) { - if (!self.googleAuthProvider) { - self.googleAuthProvider = - [[FirebaseGoogleAuthProvider alloc] initWithRef:self.ref authDelegate:self uiDelegate:self]; - [_socialProviders addObject:self.googleAuthProvider]; - } - } else if ([provider isEqualToString:kFacebookAuthProvider]) { - if (!self.facebookAuthProvider) { - self.facebookAuthProvider = - [[FirebaseFacebookAuthProvider alloc] initWithRef:self.ref authDelegate:self]; - [_socialProviders addObject:self.facebookAuthProvider]; - } - } else if ([provider isEqualToString:kTwitterAuthProvider]) { - if (!self.twitterAuthProvider) { - self.twitterAuthProvider = [[FirebaseTwitterAuthProvider alloc] initWithRef:self.ref - authDelegate:self - twitterDelegate:self]; - [_socialProviders addObject:self.twitterAuthProvider]; - } - } else if ([provider isEqualToString:kPasswordAuthProvider]) { - if (!self.passwordAuthProvider) { - self.passwordAuthProvider = - [[FirebasePasswordAuthProvider alloc] initWithRef:self.ref authDelegate:self]; - } +- (instancetype)enableProvider:(FAuthProvider)provider { + switch (provider) { + case FAuthProviderFacebook: + if (!self.facebookAuthProvider) { + self.facebookAuthProvider = + [[FirebaseFacebookAuthProvider alloc] initWithRef:self.ref authDelegate:self]; + [_socialProviders addObject:self.facebookAuthProvider]; + } + break; + + case FAuthProviderGoogle: + if (!self.googleAuthProvider) { + self.googleAuthProvider = + [[FirebaseGoogleAuthProvider alloc] initWithRef:self.ref authDelegate:self uiDelegate:self]; + [_socialProviders addObject:self.googleAuthProvider]; + } + break; + + case FAuthProviderTwitter: + if (!self.twitterAuthProvider) { + self.twitterAuthProvider = [[FirebaseTwitterAuthProvider alloc] initWithRef:self.ref + authDelegate:self + twitterDelegate:self]; + [_socialProviders addObject:self.twitterAuthProvider]; + } + break; + + case FAuthProviderPassword: + if (!self.passwordAuthProvider) { + self.passwordAuthProvider = + [[FirebasePasswordAuthProvider alloc] initWithRef:self.ref authDelegate:self]; + } + break; + + default: + [NSException raise:NSInternalInconsistencyException + format:@"Cannot enable non-existent provider!"]; + break; } return self; } +- (void)didDismissWithBlock:(void (^)(FAuthData *user, NSError *error))callback { + self.dismissCallback = callback; +} + - (void)loginButtonPressed:(id)button { if ([button isKindOfClass:[FirebaseLoginButton class]]) { FirebaseLoginButton *loginButton = (FirebaseLoginButton *)button; - if ([loginButton.provider isEqualToString:kGoogleAuthProvider]) { - [self.googleAuthProvider login]; - } else if ([loginButton.provider isEqualToString:kFacebookAuthProvider]) { - [self.facebookAuthProvider login]; - } else if ([loginButton.provider isEqualToString:kTwitterAuthProvider]) { - [self.twitterAuthProvider login]; - } else if ([loginButton.provider isEqualToString:kPasswordAuthProvider]) { - // We assume that if it wasn't a social provider, it was for email/password - NSString *email = self.emailTextField.text; - NSString *password = self.passwordTextField.text; - [self.passwordAuthProvider loginWithEmail:email andPassword:password]; + switch (loginButton.provider) { + case FAuthProviderFacebook: + [self.facebookAuthProvider login]; + break; + + case FAuthProviderGoogle: + [self.googleAuthProvider login]; + break; + + case FAuthProviderTwitter: + [self.twitterAuthProvider login]; + break; + + case FAuthProviderPassword: + [self.passwordAuthProvider loginWithEmail:self.emailTextField.text andPassword:self.passwordTextField.text]; + break; + + default: + [NSException raise:NSInternalInconsistencyException + format:@"Cannot log in using non-existent provider!"]; + break; } } } @@ -179,11 +209,17 @@ - (void)logout { } - (FAuthData *)currentUser { - return _selectedAuthProvider.authData; + return [self.ref authData]; +} + +- (void)cancelButtonPressed { + [self dismissViewControllerWithUser:nil andError:nil]; } -- (void)dismissViewController { - [self dismissViewControllerAnimated:YES completion:nil]; +- (void)dismissViewControllerWithUser:(FAuthData *)user andError:(NSError *)error { + [self dismissViewControllerAnimated:YES completion:^{ + self.dismissCallback(user, error); + }]; } #pragma mark - @@ -193,7 +229,7 @@ - (void)authProvider:(id)provider onLogin:(FAuthData *)authData { _selectedAuthProvider = provider; self.emailTextField.text = @""; self.passwordTextField.text = @""; - [self dismissViewController]; + [self dismissViewControllerWithUser:authData andError:nil]; } - (void)authProvider:(id)provider onProviderError:(NSError *)error { diff --git a/FirebaseUI/Auth/Implementation/FirebasePasswordAuthProvider.m b/FirebaseUI/Auth/Implementation/FirebasePasswordAuthProvider.m index 0b4d6e5f680..f5ab1d326df 100644 --- a/FirebaseUI/Auth/Implementation/FirebasePasswordAuthProvider.m +++ b/FirebaseUI/Auth/Implementation/FirebasePasswordAuthProvider.m @@ -37,7 +37,7 @@ @implementation FirebasePasswordAuthProvider - (instancetype)initWithRef:(Firebase *)ref authDelegate:(id)authDelegate { self = [super initWithRef:ref authDelegate:authDelegate]; if (self) { - self.provider = kPasswordAuthProvider; + self.provider = FAuthProviderPassword; } return self; } diff --git a/FirebaseUI/Auth/Implementation/FirebaseTwitterAuthProvider.m b/FirebaseUI/Auth/Implementation/FirebaseTwitterAuthProvider.m index 56a94213a1f..40546807b3b 100644 --- a/FirebaseUI/Auth/Implementation/FirebaseTwitterAuthProvider.m +++ b/FirebaseUI/Auth/Implementation/FirebaseTwitterAuthProvider.m @@ -42,7 +42,7 @@ - (instancetype)initWithRef:(Firebase *)ref twitterDelegate:(id)twitterDelegate { self = [super initWithRef:ref authDelegate:authDelegate]; if (self) { - self.provider = kTwitterAuthProvider; + self.provider = FAuthProviderTwitter; self.twitterDelegate = twitterDelegate; [self configureProvider]; } @@ -140,7 +140,7 @@ - (void)twitterAccountsFromStore:(ACAccountStore *)store // Step 1b -- get request token from Twitter - (void)makeReverseRequestForAccount:(ACAccount *)account { [self.ref - makeReverseOAuthRequestTo:kTwitterAuthProvider + makeReverseOAuthRequestTo:@"twitter" withCompletionBlock:^(NSError *error, NSDictionary *json) { if (error != nil) { [self.delegate authProvider:self onProviderError:error]; diff --git a/FirebaseUI/Core/API/FirebaseCollectionViewDataSource.h b/FirebaseUI/Core/API/FirebaseCollectionViewDataSource.h index b91ff810417..1eb335d23fd 100644 --- a/FirebaseUI/Core/API/FirebaseCollectionViewDataSource.h +++ b/FirebaseUI/Core/API/FirebaseCollectionViewDataSource.h @@ -253,6 +253,156 @@ cellReuseIdentifier:(__NON_NULL NSString *)identifier view:(__NON_NULL UICollectionView *)collectionView; +/** + * Initialize an instance of FirebaseCollectionViewDataSource that populates + * UICollectionViewCells + * with FDataSnapshots. + * @param query A Firebase query to bind the datasource to + * @param identifier A string to use as a CellReuseIdentifier + * @param collectionView An instance of a UICollectionView to bind to + * @return An instance of FirebaseCollectionViewDataSource that populates + * UICollectionViewCells with + * FDataSnapshots + */ +- (__NON_NULL instancetype)initWithQuery:(__NON_NULL FQuery *)query + cellReuseIdentifier:(__NON_NULL NSString *)identifier + view:(__NON_NULL UICollectionView *)collectionView; + +/** + * Initialize an instance of FirebaseCollectionViewDataSource that populates + * UICollectionViewCells + * with FDataSnapshots. Note that this method is used when using prototype + * cells, where the cells + * don't need to be registered in the class. + * @param query A Firebase query to bind the datasource to + * @param identifier A string to use as a CellReuseIdentifier + * @param collectionView An instance of a UICollectionView to bind to + * @return An instance of FirebaseCollectionViewDataSource that populates + * UICollectionViewCells with + * FDataSnapshots + */ +- (__NON_NULL instancetype)initWithQuery:(__NON_NULL FQuery *)query + prototypeReuseIdentifier:(__NON_NULL NSString *)identifier + view:(__NON_NULL UICollectionView *)collectionView; + +/** + * Initialize an instance of FirebaseCollectionViewDataSource that populates a + * custom subclass of + * UICollectionViewCell with FDataSnapshots. + * @param query A Firebase query to bind the datasource to + * @param cell A subclass of UICollectionViewCell used to populate the + * UICollectionView, defaults to + * UICollectionViewCell if nil + * @param identifier A string to use as a CellReuseIdentifier + * @param collectionView An instance of a UICollectionView to bind to + * @return An instance of FirebaseCollectionViewDataSource that populates a + * custom subclass of + * UICollectionViewCell with FDataSnapshots + */ +- (__NON_NULL instancetype)initWithQuery:(__NON_NULL FQuery *)query + cellClass:(__NULLABLE Class)cell + cellReuseIdentifier:(__NON_NULL NSString *)identifier + view:(__NON_NULL UICollectionView *)collectionView; + +/** + * Initialize an instance of FirebaseCollectionViewDataSource that populates a + * custom xib with + * FDataSnapshots. + * @param query A Firebase query to bind the datasource to + * @param nibName The name of a xib file to create the layout for a + * UICollectionViewCell + * @param identifier A string to use as a CellReuseIdentifier + * @param collectionView An instance of a UICollectionView to bind to + * @return An instance of FirebaseCollectionViewDataSource that populates a + * custom xib with + * FDataSnapshots + */ +- (__NON_NULL instancetype)initWithQuery:(__NON_NULL FQuery *)query + nibNamed:(__NON_NULL NSString *)nibName + cellReuseIdentifier:(__NON_NULL NSString *)identifier + view:(__NON_NULL UICollectionView *)collectionView; + +/** + * Initialize an instance of FirebaseCollectionViewDataSource that populates + * UICollectionViewCells + * with a custom model class. + * @param query A Firebase query to bind the datasource to + * @param model A custom class that FDataSnapshots are coerced to, defaults to + * FDataSnapshot if nil + * @param identifier A string to use as a CellReuseIdentifier + * @param collectionView An instance of a UICollectionView to bind to + * @return An instance of FirebaseCollectionViewDataSource that populates + * UICollectionViewCells with + * a custom model class + */ +- (__NON_NULL instancetype)initWithQuery:(__NON_NULL FQuery *)query + modelClass:(__NULLABLE Class)model + cellReuseIdentifier:(__NON_NULL NSString *)identifier + view:(__NON_NULL UICollectionView *)collectionView; + +/** + * Initialize an instance of FirebaseCollectionViewDataSource that populates + * UICollectionViewCells + * with a custom model class. Note that this method is used when using prototype + * cells, where the + * cells don't need to be registered in the class. + * @param query A Firebase query to bind the datasource to + * @param model A custom class that FDataSnapshots are coerced to, defaults to + * FDataSnapshot if nil + * @param identifier A string to use as a CellReuseIdentifier + * @param collectionView An instance of a UICollectionView to bind to + * @return An instance of FirebaseCollectionViewDataSource that populates + * UICollectionViewCells with + * a custom model class + */ +- (__NON_NULL instancetype)initWithQuery:(__NON_NULL FQuery *)query + modelClass:(__NULLABLE Class)model + prototypeReuseIdentifier:(__NON_NULL NSString *)identifier + view:(__NON_NULL UICollectionView *)collectionView; + +/** + * Initialize an instance of FirebaseCollectionViewDataSource that populates a + * custom subclass of + * UICollectionViewCell with a custom model class. + * @param query A Firebase query to bind the datasource to + * @param model A custom class that FDataSnapshots are coerced to, defaults to + * FDataSnapshot if nil + * @param cell A subclass of UICollectionViewCell used to populate the + * UICollectionView, defaults to + * UICollectionViewCell if nil + * @param identifier A string to use as a CellReuseIdentifier + * @param collectionView An instance of a UICollectionView to bind to + * @return An instance of FirebaseCollectionViewDataSource that populates a + * custom subclass of + * UICollectionViewCell with a custom model class + */ +- (__NON_NULL instancetype)initWithQuery:(__NON_NULL FQuery *)query + modelClass:(__NULLABLE Class)model + cellClass:(__NULLABLE Class)cell + cellReuseIdentifier:(__NON_NULL NSString *)identifier + view:(__NON_NULL UICollectionView *)collectionView; + +/** + * Initialize an instance of FirebaseCollectionViewDataSource that populates a + * custom xib with a + * custom model class. + * @param query A Firebase query to bind the datasource to + * @param model A custom class that FDataSnapshots are coerced to, defaults to + * FDataSnapshot if nil + * @param nibName The name of a xib file to create the layout for a + * UICollectionViewCell + * @param identifier A string to use as a CellReuseIdentifier + * @param collectionView An instance of a UICollectionView to bind to + * @return An instance of FirebaseCollectionViewDataSource that populates a + * custom xib with a custom + * model class + */ +- (__NON_NULL instancetype)initWithQuery:(__NON_NULL FQuery *)query + modelClass:(__NULLABLE Class)model + nibNamed:(__NON_NULL NSString *)nibName + cellReuseIdentifier:(__NON_NULL NSString *)identifier + view:(__NON_NULL UICollectionView *)collectionView; + /** * This method populates the fields of a UICollectionViewCell or subclass given * an FDataSnapshot (or diff --git a/FirebaseUI/Core/API/FirebaseTableViewDataSource.h b/FirebaseUI/Core/API/FirebaseTableViewDataSource.h index 418b6209d1a..9703afabb96 100644 --- a/FirebaseUI/Core/API/FirebaseTableViewDataSource.h +++ b/FirebaseUI/Core/API/FirebaseTableViewDataSource.h @@ -240,6 +240,158 @@ cellReuseIdentifier:(__NON_NULL NSString *)identifier view:(__NON_NULL UITableView *)tableView; +/** + * Initialize an instance of FirebaseTableViewDataSource that populates + * UITableViewCells with + * FDataSnapshots. + * @param query A Firebase query to bind the datasource to + * @param identifier A string to use as a CellReuseIdentifier + * @param tableView An instance of a UITableView to bind to + * @return An instance of FirebaseTableViewDataSource that populates + * UITableViewCells with + * FDataSnapshots + */ +- (__NON_NULL instancetype)initWithQuery:(__NON_NULL FQuery *)query + cellReuseIdentifier:(__NON_NULL NSString *)identifier + view:(__NON_NULL UITableView *)tableView; + +/** + * Initialize an instance of FirebaseTableViewDataSource that populates + * UITableViewCells with + * FDataSnapshots. Note that this method is used when using prototype cells, + * where the cells don't + * need to be registered in the class. + * @param query A Firebase query to bind the datasource to + * @param identifier A string to use as a CellReuseIdentifier + * @param tableView An instance of a UITableView to bind to + * @return An instance of FirebaseTableViewDataSource that populates + * UITableViewCells with + * FDataSnapshots + */ +- (__NON_NULL instancetype)initWithQuery:(__NON_NULL FQuery *)query + prototypeReuseIdentifier:(__NON_NULL NSString *)identifier + view:(__NON_NULL UITableView *)tableView; + +/** + * Initialize an instance of FirebaseTableViewDataSource that populates a custom + * subclass of + * UITableViewCell with FDataSnapshots. + * @param query A Firebase query to bind the datasource to + * @param cell A subclass of UITableViewCell used to populate the UITableView, + * defaults to + * UITableViewCell if nil + * @param identifier A string to use as a CellReuseIdentifier + * @param tableView An instance of a UITableView to bind to + * @return An instance of FirebaseTableViewDataSource that populates a custom + * subclass of + * UITableViewCell with FDataSnapshots + */ +- (__NON_NULL instancetype)initWithQuery:(__NON_NULL FQuery *)query + cellClass:(__NULLABLE Class)cell + cellReuseIdentifier:(__NON_NULL NSString *)identifier + view:(__NON_NULL UITableView *)tableView; + +/** + * Initialize an instance of FirebaseTableViewDataSource that populates a custom + * xib with + * FDataSnapshots. + * @param query A Firebase query to bind the datasource to + * @param nibName The name of a xib file to create the layout for a + * UITableViewCell + * @param identifier A string to use as a CellReuseIdentifier + * @param tableView An instance of a UITableView to bind to + * @return An instance of FirebaseTableViewDataSource that populates a custom + * xib with + * FDataSnapshots + */ +- (__NON_NULL instancetype)initWithQuery:(__NON_NULL FQuery *)query + nibNamed:(__NON_NULL NSString *)nibName + cellReuseIdentifier:(__NON_NULL NSString *)identifier + view:(__NON_NULL UITableView *)tableView; + +/** + * Initialize an instance of FirebaseTableViewDataSource that populates + * UITableViewCells with a + * custom model class. + * @param query A Firebase query to bind the datasource to + * @param model A custom class that FDataSnapshots are coerced to, defaults to + * FDataSnapshot if nil + * @param identifier A string to use as a CellReuseIdentifier + * @param tableView An instance of a UITableView to bind to + * @return An instance of FirebaseTableViewDataSource that populates + * UITableViewCells with a custom + * model class + */ +- (__NON_NULL instancetype)initWithQuery:(__NON_NULL FQuery *)query + modelClass:(__NULLABLE Class)model + cellReuseIdentifier:(__NON_NULL NSString *)identifier + view:(__NON_NULL UITableView *)tableView; + +/** + * Initialize an instance of FirebaseTableViewDataSource that populates + * UITableViewCells with a + * custom model class. Note that this method is used when using prototype cells, + * where the cells + * don't need to be registered in the class. + * @param query A Firebase query to bind the datasource to + * @param model A custom class that FDataSnapshots are coerced to, defaults to + * FDataSnapshot if nil + * @param identifier A string to use as a CellReuseIdentifier + * @param tableView An instance of a UITableView to bind to + * @return An instance of FirebaseTableViewDataSource that populates + * UITableViewCells with a custom + * model class + */ +- (__NON_NULL instancetype)initWithQuery:(__NON_NULL FQuery *)query + modelClass:(__NULLABLE Class)model + prototypeReuseIdentifier:(__NON_NULL NSString *)identifier + view:(__NON_NULL UITableView *)tableView; + +/** + * Initialize an instance of FirebaseTableViewDataSource that populates a custom + * subclass of + * UITableViewCell with a custom model class. + * @param query A Firebase query to bind the datasource to + * @param model A custom class that FDataSnapshots are coerced to, defaults to + * FDataSnapshot if nil + * @param cell A subclass of UITableViewCell used to populate the UITableView, + * defaults to + * UITableViewCell if nil + * @param identifier A string to use as a CellReuseIdentifier + * @param tableView An instance of a UITableView to bind to + * @return An instance of FirebaseTableViewDataSource that populates a custom + * subclass of + * UITableViewCell with a custom model class + */ +- (__NON_NULL instancetype)initWithQuery:(__NON_NULL FQuery *)query + modelClass:(__NULLABLE Class)model + cellClass:(__NULLABLE Class)cell + cellReuseIdentifier:(__NON_NULL NSString *)identifier + view:(__NON_NULL UITableView *)tableView; + +/** + * Initialize an instance of FirebaseTableViewDataSource that populates a custom + * xib with a custom + * model class. + * @param query A Firebase query to bind the datasource to + * @param model A custom class that FDataSnapshots are coerced to, defaults to + * FDataSnapshot if nil + * @param nibName The name of a xib file to create the layout for a + * UITableViewCell + * @param identifier A string to use as a CellReuseIdentifier + * @param tableView An instance of a UITableView to bind to + * @return An instance of FirebaseTableViewDataSource that populates a custom + * xib with a custom + * model class + */ +- (__NON_NULL instancetype)initWithQuery:(__NON_NULL FQuery *)query + modelClass:(__NULLABLE Class)model + nibNamed:(__NON_NULL NSString *)nibName + cellReuseIdentifier:(__NON_NULL NSString *)identifier + view:(__NON_NULL UITableView *)tableView; + + + /** * This method populates the fields of a UITableViewCell or subclass given a * model object (or diff --git a/FirebaseUI/Core/API/FirebaseUI.h b/FirebaseUI/Core/API/FirebaseUI.h deleted file mode 100644 index 732066d4718..00000000000 --- a/FirebaseUI/Core/API/FirebaseUI.h +++ /dev/null @@ -1,47 +0,0 @@ -// clang-format off - -/* - * Firebase UI Bindings iOS Library - * - * Copyright © 2015 Firebase - All Rights Reserved - * https://www.firebase.com - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binaryform must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY FIREBASE AS IS AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - * EVENT SHALL FIREBASE BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -// clang-format on - -#import - -#import -#import -#import -#import -#import -#import -#import -#import -#import - -@interface FirebaseUI : NSObject - -@end diff --git a/FirebaseUI/Core/Implementation/FirebaseCollectionViewDataSource.m b/FirebaseUI/Core/Implementation/FirebaseCollectionViewDataSource.m index eedae18ec0c..40d64ee1926 100644 --- a/FirebaseUI/Core/Implementation/FirebaseCollectionViewDataSource.m +++ b/FirebaseUI/Core/Implementation/FirebaseCollectionViewDataSource.m @@ -42,7 +42,7 @@ @implementation FirebaseCollectionViewDataSource - (instancetype)initWithRef:(Firebase *)ref cellReuseIdentifier:(NSString *)identifier view:(UICollectionView *)collectionView { - return [self initWithRef:ref + return [self initWithQuery:ref modelClass:nil cellClass:nil cellReuseIdentifier:identifier @@ -52,11 +52,9 @@ - (instancetype)initWithRef:(Firebase *)ref - (instancetype)initWithRef:(Firebase *)ref prototypeReuseIdentifier:(NSString *)identifier view:(UICollectionView *)collectionView { - self.hasPrototypeCell = YES; - return [self initWithRef:ref + return [self initWithQuery:ref modelClass:nil - cellClass:nil - cellReuseIdentifier:identifier + prototypeReuseIdentifier:identifier view:collectionView]; } @@ -64,7 +62,7 @@ - (instancetype)initWithRef:(Firebase *)ref cellClass:(Class)cell cellReuseIdentifier:(NSString *)identifier view:(UICollectionView *)collectionView { - return [self initWithRef:ref + return [self initWithQuery:ref modelClass:nil cellClass:cell cellReuseIdentifier:identifier @@ -75,7 +73,7 @@ - (instancetype)initWithRef:(Firebase *)ref nibNamed:(NSString *)nibName cellReuseIdentifier:(NSString *)identifier view:(UICollectionView *)collectionView { - return [self initWithRef:ref + return [self initWithQuery:ref modelClass:nil nibNamed:nibName cellReuseIdentifier:identifier @@ -86,7 +84,7 @@ - (instancetype)initWithRef:(Firebase *)ref modelClass:(Class)model cellReuseIdentifier:(NSString *)identifier view:(UICollectionView *)collectionView { - return [self initWithRef:ref + return [self initWithQuery:ref modelClass:model cellClass:nil cellReuseIdentifier:identifier @@ -97,20 +95,108 @@ - (instancetype)initWithRef:(Firebase *)ref modelClass:(Class)model prototypeReuseIdentifier:(NSString *)identifier view:(UICollectionView *)collectionView { - self.hasPrototypeCell = YES; - return [self initWithRef:ref + return [self initWithQuery:ref modelClass:model + prototypeReuseIdentifier:identifier + view:collectionView]; +} + +- (instancetype)initWithRef:(Firebase *)ref + modelClass:(Class)model + cellClass:(Class)cell + cellReuseIdentifier:(NSString *)identifier + view:(UICollectionView *)collectionView { + return [self initWithQuery:ref + modelClass:model + cellClass:cell + cellReuseIdentifier:identifier + view:collectionView]; +} + +- (instancetype)initWithRef:(Firebase *)ref + modelClass:(Class)model + nibNamed:(NSString *)nibName + cellReuseIdentifier:(NSString *)identifier + view:(UICollectionView *)collectionView { + return [self initWithQuery:ref + modelClass:model + nibNamed:nibName + cellReuseIdentifier:identifier + view:collectionView]; +} + +- (instancetype)initWithQuery:(FQuery *)query + cellReuseIdentifier:(NSString *)identifier + view:(UICollectionView *)collectionView { + return [self initWithQuery:query + modelClass:nil cellClass:nil cellReuseIdentifier:identifier view:collectionView]; } -- (instancetype)initWithRef:(Firebase *)ref +- (instancetype)initWithQuery:(FQuery *)query + prototypeReuseIdentifier:(NSString *)identifier + view:(UICollectionView *)collectionView { + self.hasPrototypeCell = YES; + return [self initWithQuery:query + modelClass:nil + cellClass:nil + cellReuseIdentifier:identifier + view:collectionView]; +} + +- (instancetype)initWithQuery:(FQuery *)query + cellClass:(Class)cell + cellReuseIdentifier:(NSString *)identifier + view:(UICollectionView *)collectionView { + return [self initWithQuery:query + modelClass:nil + cellClass:cell + cellReuseIdentifier:identifier + view:collectionView]; +} + +- (instancetype)initWithQuery:(FQuery *)query + nibNamed:(NSString *)nibName + cellReuseIdentifier:(NSString *)identifier + view:(UICollectionView *)collectionView { + return [self initWithQuery:query + modelClass:nil + nibNamed:nibName + cellReuseIdentifier:identifier + view:collectionView]; +} + +- (instancetype)initWithQuery:(FQuery *)query + modelClass:(Class)model + cellReuseIdentifier:(NSString *)identifier + view:(UICollectionView *)collectionView { + return [self initWithQuery:query + modelClass:model + cellClass:nil + cellReuseIdentifier:identifier + view:collectionView]; +} + +- (instancetype)initWithQuery:(FQuery *)query + modelClass:(Class)model + prototypeReuseIdentifier:(NSString *)identifier + view:(UICollectionView *)collectionView { + self.hasPrototypeCell = YES; + return [self initWithQuery:query + modelClass:model + cellClass:nil + cellReuseIdentifier:identifier + view:collectionView]; +} + +- (instancetype)initWithQuery:(FQuery *)query modelClass:(Class)model cellClass:(Class)cell cellReuseIdentifier:(NSString *)identifier view:(UICollectionView *)collectionView { - FirebaseArray *array = [[FirebaseArray alloc] initWithRef:ref]; + FirebaseArray *array = [[FirebaseArray alloc] initWithQuery:query]; self = [super initWithArray:array]; if (self) { if (!model) { @@ -136,12 +222,12 @@ - (instancetype)initWithRef:(Firebase *)ref return self; } -- (instancetype)initWithRef:(Firebase *)ref +- (instancetype)initWithQuery:(FQuery *)query modelClass:(Class)model nibNamed:(NSString *)nibName cellReuseIdentifier:(NSString *)identifier view:(UICollectionView *)collectionView { - FirebaseArray *array = [[FirebaseArray alloc] initWithRef:ref]; + FirebaseArray *array = [[FirebaseArray alloc] initWithQuery:query]; self = [super initWithArray:array]; if (self) { if (!model) { diff --git a/FirebaseUI/Core/Implementation/FirebaseTableViewDataSource.m b/FirebaseUI/Core/Implementation/FirebaseTableViewDataSource.m index fd3c0acacef..d4698f6c537 100644 --- a/FirebaseUI/Core/Implementation/FirebaseTableViewDataSource.m +++ b/FirebaseUI/Core/Implementation/FirebaseTableViewDataSource.m @@ -42,7 +42,7 @@ @implementation FirebaseTableViewDataSource - (instancetype)initWithRef:(Firebase *)ref cellReuseIdentifier:(NSString *)identifier view:(UITableView *)tableView { - return [self initWithRef:ref + return [self initWithQuery:ref modelClass:nil cellClass:nil cellReuseIdentifier:identifier @@ -52,8 +52,7 @@ - (instancetype)initWithRef:(Firebase *)ref - (instancetype)initWithRef:(Firebase *)ref prototypeReuseIdentifier:(NSString *)identifier view:(UITableView *)tableView { - self.hasPrototypeCell = YES; - return [self initWithRef:ref + return [self initWithQuery:ref modelClass:nil cellClass:nil cellReuseIdentifier:identifier @@ -64,7 +63,7 @@ - (instancetype)initWithRef:(Firebase *)ref cellClass:(Class)cell cellReuseIdentifier:(NSString *)identifier view:(UITableView *)tableView { - return [self initWithRef:ref + return [self initWithQuery:ref modelClass:nil cellClass:cell cellReuseIdentifier:identifier @@ -75,7 +74,7 @@ - (instancetype)initWithRef:(Firebase *)ref nibNamed:(NSString *)nibName cellReuseIdentifier:(NSString *)identifier view:(UITableView *)tableView { - return [self initWithRef:ref + return [self initWithQuery:ref modelClass:nil nibNamed:nibName cellReuseIdentifier:identifier @@ -86,7 +85,7 @@ - (instancetype)initWithRef:(Firebase *)ref modelClass:(Class)model cellReuseIdentifier:(NSString *)identifier view:(UITableView *)tableView { - return [self initWithRef:ref + return [self initWithQuery:ref modelClass:model cellClass:nil cellReuseIdentifier:identifier @@ -97,8 +96,7 @@ - (instancetype)initWithRef:(Firebase *)ref modelClass:(Class)model prototypeReuseIdentifier:(NSString *)identifier view:(UITableView *)tableView { - self.hasPrototypeCell = YES; - return [self initWithRef:ref + return [self initWithQuery:ref modelClass:model cellClass:nil cellReuseIdentifier:identifier @@ -110,7 +108,97 @@ - (instancetype)initWithRef:(Firebase *)ref cellClass:(Class)cell cellReuseIdentifier:(NSString *)identifier view:(UITableView *)tableView { - FirebaseArray *array = [[FirebaseArray alloc] initWithRef:ref]; + return [self initWithQuery:ref + modelClass:model + cellClass:cell + cellReuseIdentifier:identifier + view:tableView]; +} + +- (instancetype)initWithRef:(Firebase *)ref + modelClass:(Class)model + nibNamed:(NSString *)nibName + cellReuseIdentifier:(NSString *)identifier + view:(UITableView *)tableView { + return [self initWithQuery:ref + modelClass:model + nibNamed:nibName + cellReuseIdentifier:identifier + view:tableView]; +} + +- (instancetype)initWithQuery:(FQuery *)query + cellReuseIdentifier:(NSString *)identifier + view:(UITableView *)tableView { + return [self initWithQuery:query + modelClass:nil + cellClass:nil + cellReuseIdentifier:identifier + view:tableView]; +} + +- (instancetype)initWithQuery:(FQuery *)query + prototypeReuseIdentifier:(NSString *)identifier + view:(UITableView *)tableView { + self.hasPrototypeCell = YES; + return [self initWithQuery:query + modelClass:nil + cellClass:nil + cellReuseIdentifier:identifier + view:tableView]; +} + +- (instancetype)initWithQuery:(FQuery *)query + cellClass:(Class)cell + cellReuseIdentifier:(NSString *)identifier + view:(UITableView *)tableView { + return [self initWithQuery:query + modelClass:nil + cellClass:cell + cellReuseIdentifier:identifier + view:tableView]; +} + +- (instancetype)initWithQuery:(FQuery *)query + nibNamed:(NSString *)nibName + cellReuseIdentifier:(NSString *)identifier + view:(UITableView *)tableView { + return [self initWithQuery:query + modelClass:nil + nibNamed:nibName + cellReuseIdentifier:identifier + view:tableView]; +} + +- (instancetype)initWithQuery:(FQuery *)query + modelClass:(Class)model + cellReuseIdentifier:(NSString *)identifier + view:(UITableView *)tableView { + return [self initWithQuery:query + modelClass:model + cellClass:nil + cellReuseIdentifier:identifier + view:tableView]; +} + +- (instancetype)initWithQuery:(FQuery *)query + modelClass:(Class)model + prototypeReuseIdentifier:(NSString *)identifier + view:(UITableView *)tableView { + self.hasPrototypeCell = YES; + return [self initWithQuery:query + modelClass:model + cellClass:nil + cellReuseIdentifier:identifier + view:tableView]; +} + +- (instancetype)initWithQuery:(FQuery *)query + modelClass:(Class)model + cellClass:(Class)cell + cellReuseIdentifier:(NSString *)identifier + view:(UITableView *)tableView { + FirebaseArray *array = [[FirebaseArray alloc] initWithQuery:query]; self = [super initWithArray:array]; if (self) { if (!model) { @@ -134,12 +222,12 @@ - (instancetype)initWithRef:(Firebase *)ref return self; } -- (instancetype)initWithRef:(Firebase *)ref - modelClass:(Class)model - nibNamed:(NSString *)nibName - cellReuseIdentifier:(NSString *)identifier - view:(UITableView *)tableView { - FirebaseArray *array = [[FirebaseArray alloc] initWithRef:ref]; +- (instancetype)initWithQuery:(FQuery *)query + modelClass:(Class)model + nibNamed:(NSString *)nibName + cellReuseIdentifier:(NSString *)identifier + view:(UITableView *)tableView { + FirebaseArray *array = [[FirebaseArray alloc] initWithQuery:query]; self = [super initWithArray:array]; if (self) { if (!model) { diff --git a/FirebaseUI/Core/Implementation/FirebaseUI.m b/FirebaseUI/Core/Implementation/FirebaseUI.m deleted file mode 100644 index e1eb71977db..00000000000 --- a/FirebaseUI/Core/Implementation/FirebaseUI.m +++ /dev/null @@ -1,13 +0,0 @@ -// -// FirebaseUI.m -// FirebaseUI -// -// Created by Mike Mcdonald on 7/15/15. -// Copyright © 2015 Firebase, Inc. All rights reserved. -// - -#import "FirebaseUI.h" - -@implementation FirebaseUI - -@end diff --git a/README.md b/README.md index 704607f30a5..d0fd56610ba 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,14 @@ FirebaseUI supports iOS 8.0+. We recommend using [CocoaPods](http://cocoapods.or the following to your `Podfile`: ``` -pod 'FirebaseUI', '~> 0.3' +pod 'FirebaseUI', '~> 0.3' # Pull in all Firebase UI features +``` + +If you don't want to use all of FirebaseUI, there are two subspecs, `Core` and `Auth` which can selectively install subsets of the full feature set. + +``` +pod 'FirebaseUI/Core', '~> 0.3' # Only pull in the "Core" FirebaseUI features +pod 'FirebaseUI/Auth', '~> 0.3' # Only pull in the "Auth" FirebaseUI features ``` If you're including FirebaseUI in a Swift project, make sure you also have: @@ -37,7 +44,7 @@ account](https://www.firebase.com/signup/?utm_source=firebaseui-ios). This is a quickstart on how to use FirebaseUI's core features to speed up iOS development with Firebase. FirebaseUI includes the following features: ### FirebaseUI Core -Provides core data binding capabilities as well as specific datasources for lists of data. Skip to the [Core API overview](https://github.com/firebase/firebaseui-ios#firebaseui-auth-api) for more information. +Provides core data binding capabilities as well as specific datasources for lists of data. Skip to the [Core API overview](https://github.com/firebase/firebaseui-ios#firebaseui-core-api) for more information. Class | Description ------------- | ------------- @@ -47,7 +54,7 @@ FirebaseArray | Keeps an array synchronized to a Firebase query FirebaseDataSource | Generic superclass to create a custom data source ### FirebaseUI Auth -Provides authentication providers as well as concrete implementations for Facebook, Google, Twitter, and Firbase email/password, plus a headful UI that handles auth state and error conditions. Skip to the [Auth API overview](https://github.com/firebase/firebaseui-ios#firebaseui-core-api) for more information. +Provides authentication providers as well as concrete implementations for Facebook, Google, Twitter, and Firbase email/password, plus a headful UI that handles auth state and error conditions. Skip to the [Auth API overview](https://github.com/firebase/firebaseui-ios#firebaseui-auth-api) for more information. Class | Description ------------- | ------------- @@ -350,7 +357,7 @@ FirebaseDataSource acts as a generic data source by providing common information ```objective-c // AppDelegate.h #import -#import +#import @interface AppDelegate : FirebaseAppDelegate @@ -405,43 +412,113 @@ class AppDelegate: FirebaseAppDelegate { ``` ### FirebaseLoginViewController -`FirebaseLoginViewContoller` quickly adds a headful UI flow to your application. This flow supports email/password login, as well as social providers (Facebook, Google, Twitter). Using this, you can easily guide users through the login journey, get the current user's state, and log the user out. This view looks like: +`FirebaseLoginViewContoller` quickly adds a headful UI flow to your application. This flow supports email/password login, as well as social providers (Facebook, Google, Twitter). Using this, you can easily guide users through the login journey, get the current user's state, and log the user out. There are two main scenerios this controller can be used in: + 1. A captive login portal: launches on app start, developer must specify dismissal behavior + 2. A login modal view: launches on user action, developer may specify dismissal behavior or use built in FirebaseUI behavior + +This view looks like: ![FirebaseLoginViewController with all providers enabled](https://github.com/firebase/FirebaseUI-iOS/blob/master/docs/FirebaseLoginViewController.png) -Code to create this view is below: +For creating a captive portal, we recommend creating the `FirebaseLoginViewController` and enabling providers in `viewDidLoad`, but don't display it until the view has been created (`viewWillAppear` or later!). It is best to make the `FirebaseLoginViewController` a property on your view controller so it will be retained and acessible by other methods in your class. #### Objective-C ```objective-c -Firebase *firebaseRef = [[Firebase alloc] initWithUrl:@"https://.firebaseio.com/"]; -FirebaseLoginViewController *loginViewController = [[FirebaseLoginViewController alloc] initWithRef:ref]; - [loginViewController enableProvider:kGoogleAuthProvider]; - [loginViewController enableProvider:kFacebookAuthProvider]; - [loginViewController enableProvider:kTwitterAuthProvider]; - [loginViewController enableProvider:kPasswordAuthProvider]; - [self presentViewController:self.loginViewController animated:YES completion:nil]; - ... - FAuthData *user = [loginViewController currentUser]; // Check the currently logged in user - ... - [loginViewController logout]; // Log the current user out +- (void)viewDidLoad { + [super viewDidLoad]; + + Firebase *firebaseRef = [[Firebase alloc] initWithUrl:@"https://.firebaseio.com/"]; + + self.loginViewController = [[FirebaseLoginViewController alloc] initWithRef:firebaseRef]; + [self.loginViewController enableProvider:FAuthProviderFacebook]; + [self.loginViewController enableProvider:FAuthProviderGoogle]; + [self.loginViewController enableProvider:FAuthProviderTwitter]; + [self.loginViewController enableProvider:FAuthProviderPassword]; + // Scenario 1: Set up captive portal login flow + [self.loginViewController didDismissWithBlock:^(FAuthData *user, NSError *error) { + if (user) { + // Handle user case + } else if (error) { + // Handle error case + } else { + // Handle cancel case + } + }]; + + // Scenario 2: Set up user action based login flow + [loginButton addTarget:self action:@selector(login) forControlEvents:UIControlEventTouchUpInside]; + [logoutButton addTarget:self action:@selector(logout) forControlEvents:UIControlEventTouchUpInside]; +} + +// Scenario 1: Application launches login flow, handles dismissal and routing in `didDismissWithBlock:` +- (void)viewDidAppear:(BOOL)animated { + if (![self.loginViewController currentUser]) { + [self presentViewController:self.loginViewController animated:YES completion:nil]; + } +} + +// Scenario 2: User action launches login flow, dismissal and routing handled by `FirebaseLoginViewController` +- (void)login { + if (![self.loginViewController currentUser]) { + [self presentViewController:self.loginViewController animated:YES completion:nil]; + } +} + +- (void)logout { + if ([self.loginViewController currentUser]) { + [self.loginViewController logout]; + } +} ``` #### Swift ```swift -let firebaseRef = Firebase(url: "https://.firebaseio.com/") -var loginViewController = FirebaseLoginViewController(ref: firebaseRef) -loginViewController.enableProvider(kGoogleAuthProvider) -loginViewController.enableProvider(kFacebookAuthProvider) -loginViewController.enableProvider(kTwitterAuthProvider) -loginViewController.enableProvider(kPasswordAuthProvider) -self.presentViewController(loginViewController, animated: true, completion: nil) -... -var user: FAuthData = loginViewController.currentUser(); // Check the currently logged in user -... -loginViewController.logout(); // Log the current user out -``` +override func viewDidLoad() { + super.viewDidLoad() + + let firebaseRef = Firebase(url: "https://.firebaseio.com/") + + self.loginViewController = FirebaseLoginViewController(ref: firebaseRef) + self.loginViewController.enableProvider(FAuthProvider.Facebook) + self.loginViewController.enableProvider(FAuthProvider.Google) + self.loginViewController.enableProvider(FAuthProvider.Twitter) + self.loginViewController.enableProvider(FAuthProvider.Password) + // Scenario 1: Set up captive portal login flow + self.loginViewController.didDismissWithBlock { (user: FAuthData, error: NSError) -> Void in + if (user) { + // Handle user case + } else if (error) { + // Handle error case + } else { + // Handle cancel case + } + } + + // Scenario 2: Set up user action based login flow + loginButton.addTarget(self, action: "login", forControlEvents: UIControlEvents.TouchUpInside) + logoutButton.addTarget(self, action: "logout", forControlEvents: UIControlEvents.TouchUpInside) +} + +// Scenario 1: Application launches login flow, handles dismissal and routing in `didDismissWithBlock:` +override func viewDidAppear(animated: Bool) { + if (!self.loginViewController.currentUser()) { + self.presentViewController(self.loginViewcontroller, animated: true, completion: nil) + } +} +// Scenario 2: User action launches login flow, dismissal and routing handled by `FirebaseLoginViewController` +func login() { + if (!self.loginViewController.currentUser()) { + self.presentViewController(self.loginViewcontroller, animated: true, completion: nil) + } +} +func logout() { + if (self.loginViewController.currentUser()) { + self.loginViewController.logout() + } +} +``` ### FirebaseFacebookAuthProvider @@ -449,7 +526,7 @@ loginViewController.logout(); // Log the current user out #### Objective-C ```objective-c -Firebase *firebaseRef = [[Firebase alloc] initWithUrl:@"https://.firebaseio.com/"]; +Firebase *firebaseRef = [[Firebase alloc] initWithUrl:@"https://.firebaseio.com/"]; FirebaseFacebookAuthProvider *facebookProvider = [[FirebaseFacebookAuthProvider alloc] initWithRef:firebaseRef authDelegate:self]; [facebookProvider login]; ... @@ -458,7 +535,7 @@ FirebaseFacebookAuthProvider *facebookProvider = [[FirebaseFacebookAuthProvider #### Swift ```swift -let firebaseRef = Firebase(url: "https://.firebaseio.com/") +let firebaseRef = Firebase(url: "https://.firebaseio.com/") let facebookProvider = FirebaseFacebookAuthProvider(ref: firebaseRef, authDelegate: self) facebookProvider.login() ... @@ -470,7 +547,7 @@ facebookProvider.logout() #### Objective-C ```objective-c -Firebase *firebaseRef = [[Firebase alloc] initWithUrl:@"https://.firebaseio.com/"]; +Firebase *firebaseRef = [[Firebase alloc] initWithUrl:@"https://.firebaseio.com/"]; FirebaseGoogleAuthProvider *googleProvider = [[FirebaseGoogleAuthProvider alloc] initWithRef:firebaseRef authDelegate:self uiDelegate:self]; [googleProvider login]; ... @@ -479,7 +556,7 @@ FirebaseGoogleAuthProvider *googleProvider = [[FirebaseGoogleAuthProvider alloc] #### Swift ```swift -let firebaseRef = Firebase(url: "https://.firebaseio.com/") +let firebaseRef = Firebase(url: "https://.firebaseio.com/") let googleProvider = FirebaseGoogleAuthProvider(ref: firebaseRef, authDelegate: self, uiDelegate: self) googleProvider.login() ... @@ -492,7 +569,7 @@ googleProvider.logout() #### Objective-C ```objective-c -Firebase *firebaseRef = [[Firebase alloc] initWithUrl:@"https://.firebaseio.com/"]; +Firebase *firebaseRef = [[Firebase alloc] initWithUrl:@"https://.firebaseio.com/"]; FirebaseTwitterAuthProvider *twitterProvider = [[FirebaseTwitterAuthProvider alloc] initWithRef:firebaseRef authDelegate:self twitterDelegate:self]; [twitterProvider login]; ... @@ -501,7 +578,7 @@ FirebaseTwitterAuthProvider *twitterProvider = [[FirebaseTwitterAuthProvider all #### Swift ```swift -let firebaseRef = Firebase(url: "https://.firebaseio.com/") +let firebaseRef = Firebase(url: "https://.firebaseio.com/") let twitterProvider = FirebaseTwitterAuthProvider(ref: firebaseRef, authDelegate: self, twitterDelegate: self) twitterProvider.login() ... @@ -514,7 +591,7 @@ twitterProvider.logout() #### Objective-C ```objective-c -Firebase *firebaseRef = [[Firebase alloc] initWithUrl:@"https://.firebaseio.com/"]; +Firebase *firebaseRef = [[Firebase alloc] initWithUrl:@"https://.firebaseio.com/"]; FirebasePasswordAuthProvider *passwordProvider = [[FirebasePasswordAuthProvider alloc] initWithRef:firebaseRef authDelegate:self]; [passwordProvider loginWithEmail:@"email" andPassword:@"password"]; ... @@ -523,7 +600,7 @@ FirebasePasswordAuthProvider *passwordProvider = [[FirebasePasswordAuthProvider #### Swift ```swift -let firebaseRef = Firebase(url: "https://.firebaseio.com/") +let firebaseRef = Firebase(url: "https://.firebaseio.com/") let passwordProvider = FirebasePasswordAuthProvider(ref: firebaseRef, authDelegate: self) passwordProvider.login(email: "email", password: "password") ... @@ -568,7 +645,7 @@ $ cd FirebaseUI-iOS $ ./setup.sh ``` -Note that `setup.sh` pulls in a number of provider frameworks (Facebook, Google), which need to be pulled in for local development. The build will also fail due to Google using `#import ` in their pod but `#import ` in the framework, so you can either change the imports, or include `FirebaseUI` in a Cocoapods project and edit there. +Note that `setup.sh` pulls in a number of provider frameworks (Facebook, Google), which need to be pulled in for local development. The debug build and framework release have the flag `LOCAL_BUILD=1` which uses the local frameworks installed via `setup.sh`, while the Cocoapods release doesn't have this flag set, so the appropriate Pod `#import` statements are used. FirebaseUI makes use of XCode 7 features such as lightweight generics and `__kindof` annotations, but it should be backwards compatible to XCode 6 thanks to [XCodeMacros.h](https://github.com/firebase/FirebaseUI-iOS/blob/master/FirebaseUI/XCodeMacros.h). diff --git a/examples/FirebaseUIChat/FirebaseUIChat/AppDelegate.h b/examples/FirebaseUIChat/FirebaseUIChat/AppDelegate.h index 73d16310df8..2e09d154bb9 100644 --- a/examples/FirebaseUIChat/FirebaseUIChat/AppDelegate.h +++ b/examples/FirebaseUIChat/FirebaseUIChat/AppDelegate.h @@ -7,7 +7,7 @@ // #import -#import +#import @interface AppDelegate : FirebaseAppDelegate diff --git a/examples/FirebaseUIChat/FirebaseUIChat/ViewController.h b/examples/FirebaseUIChat/FirebaseUIChat/ViewController.h index 96589dd4d58..9068fb5b9a2 100644 --- a/examples/FirebaseUIChat/FirebaseUIChat/ViewController.h +++ b/examples/FirebaseUIChat/FirebaseUIChat/ViewController.h @@ -8,7 +8,8 @@ #import #import -#import +#import +#import @interface ViewController : UIViewController diff --git a/examples/FirebaseUIChat/FirebaseUIChat/ViewController.m b/examples/FirebaseUIChat/FirebaseUIChat/ViewController.m index e449d30bbb7..2c02e1ce583 100644 --- a/examples/FirebaseUIChat/FirebaseUIChat/ViewController.m +++ b/examples/FirebaseUIChat/FirebaseUIChat/ViewController.m @@ -64,10 +64,10 @@ - (void)viewDidLoad { self.loginViewController = [[FirebaseLoginViewController alloc] initWithRef:self.ref]; // Only enable social providers that you've configured -// [self.loginViewController enableProvider:kFacebookAuthProvider]; -// [self.loginViewController enableProvider:kGoogleAuthProvider]; -// [self.loginViewController enableProvider:kTwitterAuthProvider]; - [self.loginViewController enableProvider:kPasswordAuthProvider]; +// [self.loginViewController enableProvider:FAuthProviderFacebook]; +// [self.loginViewController enableProvider:FAuthProviderGoogle]; +// [self.loginViewController enableProvider:FAuthProviderTwitter]; + [self.loginViewController enableProvider:FAuthProviderPassword]; self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:nil style:UIBarButtonItemStylePlain target:self action:@selector(toggleAuth)]; } diff --git a/setup.sh b/setup.sh index e1a10bf9b31..4a02f9a5aaa 100755 --- a/setup.sh +++ b/setup.sh @@ -4,9 +4,9 @@ set -e # SDK URLs FIREBASE_SDK_URL="https://cdn.firebase.com/ObjC/Firebase.framework-LATEST.zip" -GOOGLE_SDK_URL="https://developers.google.com/identity/sign-in/ios/sdk/google_signin_sdk_2_2_0.zip" +GOOGLE_SDK_URL="https://developers.google.com/identity/sign-in/ios/sdk/google_signin_sdk_2_4_0.zip" GOOGLE_CORE_SDK_URL="https://www.gstatic.com/cpdc/02468137448ba914-Google-1.0.7.zip" -FACEBOOK_SDK_URL="http://fb.me/FacebookSDKs-iOS-20151111.zip" +FACEBOOK_SDK_URL="https://origincache.facebook.com/developers/resources/?id=facebook-ios-sdk-current.zip" # Script directories SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"