Skip to content

Merge v0.5.6 into master #156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Sep 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions FirebaseAuthUI/FIRAuthUIUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,7 @@ + (NSBundle *)frameworkBundle {
static NSBundle *frameworkBundle = nil;
static dispatch_once_t predicate;
dispatch_once(&predicate, ^{
NSString *mainBundlePath = [[NSBundle mainBundle] resourcePath];
NSString *frameworkBundlePath =
[mainBundlePath stringByAppendingPathComponent:@"FirebaseAuthUIBundle.bundle"];
frameworkBundle = [NSBundle bundleWithPath:frameworkBundlePath];
if (!frameworkBundle) {
frameworkBundle = [NSBundle mainBundle];
}
frameworkBundle = [NSBundle bundleForClass:[self class]];
});
return frameworkBundle;
}
Expand Down
2 changes: 2 additions & 0 deletions FirebaseAuthUITests/FIRAuthUITest.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ @implementation FUILoginProvider
- (NSString *)providerID { return @"provider id"; }
- (NSString *)shortName { return @"login provider"; }
- (NSString *)signInLabel { return @"sign in label"; }
- (NSString *)accessToken { return @"accessToken"; }
- (NSString *)idToken { return @"idToken"; }

- (UIImage *)icon {
return [[UIImage alloc] init];
Expand Down
2 changes: 1 addition & 1 deletion FirebaseAuthUITests/GoogleService-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<key>IS_SIGNIN_ENABLED</key>
<true/>
<key>GOOGLE_APP_ID</key>
<string>google-app-id</string>
<string>0:000000000000:ios:0000000000000000</string>
<key>DATABASE_URL</key>
<string>database-url</string>
</dict>
Expand Down
18 changes: 3 additions & 15 deletions FirebaseFacebookAuthUI/FIRFacebookAuthUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,35 +23,23 @@ NS_ASSUME_NONNULL_BEGIN
*/
@interface FIRFacebookAuthUI : NSObject <FIRAuthProviderUI>

/** @property appId
@brief The Facebook App ID.
*/
@property(nonatomic, readonly, copy) NSString *appID;

/** @property scopes
@brief The scopes to use with Facebook Login.
@remarks Defaults to using "email" scopes.
*/
@property(nonatomic, readonly, copy) NSArray<NSString *> *scopes;

/** @fn init
@brief Please use initWithAppId:
*/
- (instancetype)init NS_UNAVAILABLE;

/** @fn initWithAppID:
@brief Conevenience initializer. Uses a default permission of `@[ "email" ]`.
@param appID The Facebook App ID.
*/
- (instancetype)initWithAppID:(NSString *)appID;
- (instancetype)init;

/** @fn initWithAppID:permissions:
/** @fn initWithPermissions:
@brief Designated initializer.
@param appID The Facebook App ID.
@param permissions The permissions of the app. This array must be an array of specific string values
as defined in https://developers.facebook.com/docs/facebook-login/permissions/
*/
- (instancetype)initWithAppID:(NSString *)appID permissions:(NSArray *)permissions NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithPermissions:(NSArray *)permissions NS_DESIGNATED_INITIALIZER;

@end

Expand Down
56 changes: 33 additions & 23 deletions FirebaseFacebookAuthUI/FIRFacebookAuthUI.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@
#import <FBSDKLoginKit/FBSDKLoginKit.h>
#import <FirebaseAuthUI/FIRAuthUIErrorUtils.h>

/** @var kBundleFileName
@brief The name of the bundle containing Facebook auth provider assets/resources.
*/
static NSString *const kBundleFileName = @"FirebaseFacebookAuthUIBundle.bundle";

/** @var kTableName
@brief The name of the strings table to search for localized strings.
*/
Expand All @@ -37,6 +32,16 @@
*/
static NSString *const kSignInWithFacebook = @"SignInWithFacebook";

/** @var kFacebookAppId
@brief The string key used to read Facebook App Id from Info.plist.
*/
static NSString *const kFacebookAppId = @"FacebookAppID";

/** @var kFacebookDisplayName
@brief The string key used to read Facebook App Name from Info.plist.
*/
static NSString *const kFacebookDisplayName = @"FacebookDisplayName";

@implementation FIRFacebookAuthUI {
/** @var _loginManager
@brief The Facebook login manager.
Expand All @@ -49,24 +54,17 @@ @implementation FIRFacebookAuthUI {
FIRAuthProviderSignInCompletionBlock _pendingSignInCallback;
}

- (instancetype)init {
@throw [NSException exceptionWithName:@"Attempt to call unavailable initializer."
reason:@"Please call the designated initializer."
userInfo:nil];
}

- (instancetype)initWithAppID:(NSString *)appID permissions:(NSArray *)permissions {
- (instancetype)initWithPermissions:(NSArray *)permissions {
self = [super init];
if (self != nil) {
_scopes = permissions;
[FBSDKSettings setAppID:appID];
_loginManager = [[FBSDKLoginManager alloc] init];
[self configureProvider];
}
return self;
}

- (instancetype)initWithAppID:(NSString *)appID {
return [self initWithAppID:appID permissions:@[ @"email" ]];
- (instancetype)init {
return [self initWithPermissions:@[ @"email" ]];
}

/** @fn frameworkBundle
Expand All @@ -77,13 +75,7 @@ + (NSBundle *)frameworkBundle {
static NSBundle *frameworkBundle = nil;
static dispatch_once_t predicate;
dispatch_once(&predicate, ^{
NSString *mainBundlePath = [[NSBundle mainBundle] resourcePath];
NSString *frameworkBundlePath =
[mainBundlePath stringByAppendingPathComponent:kBundleFileName];
frameworkBundle = [NSBundle bundleWithPath:frameworkBundlePath];
if (!frameworkBundle) {
frameworkBundle = [NSBundle mainBundle];
}
frameworkBundle = [NSBundle bundleForClass:[self class]];
});
return frameworkBundle;
}
Expand Down Expand Up @@ -214,4 +206,22 @@ - (void)callbackWithCredential:(nullable FIRAuthCredential *)credential
}
}

/** @fn callbackWithCredential:error:
@brief Validates that Facebook SDK data was filled in Info.plist and creates Facebook login manager
*/
- (void)configureProvider {
NSBundle *bundle = [[self class] frameworkBundle];
NSString *facebookAppId = [bundle objectForInfoDictionaryKey:kFacebookAppId];
NSString *facebookDisplayName = [bundle objectForInfoDictionaryKey:kFacebookDisplayName];

if (!(facebookAppId && facebookDisplayName)) {
[NSException raise:NSInternalInconsistencyException
format:@"Please set FacebookAppID, FacebookDisplayName, and\nURL types > Url "
@"Schemes in `Supporting Files/Info.plist` according to "
@"https://developers.facebook.com/docs/ios/getting-started"];
}

_loginManager = [[FBSDKLoginManager alloc] init];
}

@end
21 changes: 21 additions & 0 deletions FirebaseFacebookAuthUITests/FIRFacebookAuthUITest.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// Copyright (c) 2016 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

#import <FirebaseFacebookAuthUI/FirebaseFacebookAuthUI.h>

@interface FIRFacebookAuthUITest : FIRFacebookAuthUI

@end
28 changes: 28 additions & 0 deletions FirebaseFacebookAuthUITests/FIRFacebookAuthUITest.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// Copyright (c) 2016 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#import "FIRFacebookAuthUITest.h"

@implementation FIRFacebookAuthUITest

+ (NSBundle *)frameworkBundle {
static NSBundle *frameworkBundle = nil;
static dispatch_once_t predicate;
dispatch_once(&predicate, ^{
frameworkBundle = [NSBundle bundleForClass:[self class]];
});
return frameworkBundle;
}
@end
4 changes: 2 additions & 2 deletions FirebaseFacebookAuthUITests/FirebaseFacebookAuthUITests.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//

@import XCTest;
@import FirebaseFacebookAuthUI;
#import "FIRFacebookAuthUITest.h"

@interface FirebaseFacebookAuthUITests : XCTestCase
@property (nonatomic, strong) FIRFacebookAuthUI *provider;
Expand All @@ -25,7 +25,7 @@ @implementation FirebaseFacebookAuthUITests

- (void)setUp {
[super setUp];
self.provider = [[FIRFacebookAuthUI alloc] initWithAppID:@"an id"];
self.provider = [[FIRFacebookAuthUITest alloc] init];
}

- (void)testItExists {
Expand Down
4 changes: 4 additions & 0 deletions FirebaseFacebookAuthUITests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,9 @@
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>FacebookAppID</key>
<string>{your-app-id}</string>
<key>FacebookDisplayName</key>
<string>{your-app-name}</string>
</dict>
</plist>
22 changes: 5 additions & 17 deletions FirebaseGoogleAuthUI/FIRGoogleAuthUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ NS_ASSUME_NONNULL_BEGIN
*/
@interface FIRGoogleAuthUI : NSObject <FIRAuthProviderUI>

/** @property clientID
@brief The Google Sign In client ID.
*/
@property(nonatomic, copy, readonly) NSString *clientID;

/** @property scopes
@brief The scopes to use with Google Sign In.
@remarks Defaults to using email and profile scopes. For a list of all scopes
Expand All @@ -36,24 +31,17 @@ NS_ASSUME_NONNULL_BEGIN
@property(nonatomic, copy, readonly) NSArray<NSString *> *scopes;

/** @fn init
@brief Please use initWithClientId:
*/
- (instancetype)init NS_UNAVAILABLE;

/** @fn initWithClientID:
@brief Convenience initializer. Calls designated init with default
scopes of "email" and "profile".
@param clientId The Google Sign In client ID.
@brief Convenience initializer. Calls designated init with default
scopes of "email" and "profile".
*/
- (instancetype)initWithClientID:(NSString *)clientID;
- (instancetype)init;

/** @fn initWithClientID:scopes:
/** @fn initWithScopes:
@brief Designated initializer.
@param clientId The Google Sign In client ID.
@param scopes The user account scopes required by the app. A list of possible scopes can be
found at https://developers.google.com/identity/protocols/googlescopes
*/
- (instancetype)initWithClientID:(NSString *)clientID scopes:(NSArray <NSString *> *)scopes NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithScopes:(NSArray <NSString *> *)scopes NS_DESIGNATED_INITIALIZER;

@end

Expand Down
26 changes: 7 additions & 19 deletions FirebaseGoogleAuthUI/FIRGoogleAuthUI.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@

#import "FIRGoogleAuthUI.h"

#import <GoogleSignIn/GoogleSignIn.h>
#import <FirebaseAnalytics/FirebaseAnalytics.h>
#import <FirebaseAuth/FIRGoogleAuthProvider.h>
#import <FirebaseAuth/FIRUserInfo.h>
#import <FirebaseAuthUI/FIRAuthUIErrorUtils.h>
#import <FirebaseAuthUI/FirebaseAuthUI.h>
#import <GoogleSignIn/GoogleSignIn.h>

/** @var kGoogleGamesScope
@brief The OAuth scope string for the "Games" scope.
Expand Down Expand Up @@ -66,20 +68,12 @@ @implementation FIRGoogleAuthUI {
}

- (instancetype)init {
@throw [NSException exceptionWithName:@"Attempt to call unavailable initializer."
reason:@"Please call the designated initializer."
userInfo:nil];
return [self initWithScopes:@[kGoogleUserInfoEmailScope, kGoogleUserInfoProfileScope]];
}

- (instancetype)initWithClientID:(NSString *)clientID {
return [self initWithClientID:clientID
scopes:@[kGoogleUserInfoEmailScope, kGoogleUserInfoProfileScope]];
}

- (instancetype)initWithClientID:(NSString *)clientID scopes:(NSArray *)scopes {
- (instancetype)initWithScopes:(NSArray *)scopes {
self = [super init];
if (self) {
_clientID = [clientID copy];
_scopes = [scopes copy];
}
return self;
Expand All @@ -93,13 +87,7 @@ + (NSBundle *)frameworkBundle {
static NSBundle *frameworkBundle = nil;
static dispatch_once_t predicate;
dispatch_once(&predicate, ^{
NSString *mainBundlePath = [[NSBundle mainBundle] resourcePath];
NSString *frameworkBundlePath =
[mainBundlePath stringByAppendingPathComponent:@"FirebaseGoogleAuthUIBundle.bundle"];
frameworkBundle = [NSBundle bundleWithPath:frameworkBundlePath];
if (!frameworkBundle) {
frameworkBundle = [NSBundle mainBundle];
}
frameworkBundle = [NSBundle bundleForClass:[self class]];
});
return frameworkBundle;
}
Expand Down Expand Up @@ -230,7 +218,7 @@ - (GIDSignIn *)configuredGoogleSignIn {
signIn.delegate = self;
signIn.uiDelegate = self;
signIn.shouldFetchBasicProfile = YES;
signIn.clientID = _clientID;
signIn.clientID = [[FIRApp defaultApp] options].clientID;
signIn.scopes = _scopes;
return signIn;
}
Expand Down
13 changes: 1 addition & 12 deletions FirebaseTwitterAuthUI/FIRTwitterAuthUI.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@
#import <TwitterKit/TwitterKit.h>
#import "FIRTwitterAuthUI.h"

/** @var kBundleFileName
@brief The name of the bundle containing Twitter auth provider assets/resources.
*/
static NSString *const kBundleFileName = @"FirebaseTwitterAuthUIBundle.bundle";

/** @var kTableName
@brief The name of the strings table to search for localized strings.
*/
Expand All @@ -44,13 +39,7 @@ + (NSBundle *)frameworkBundle {
static NSBundle *frameworkBundle = nil;
static dispatch_once_t predicate;
dispatch_once(&predicate, ^{
NSString *mainBundlePath = [[NSBundle mainBundle] resourcePath];
NSString *frameworkBundlePath =
[mainBundlePath stringByAppendingPathComponent:kBundleFileName];
frameworkBundle = [NSBundle bundleWithPath:frameworkBundlePath];
if (!frameworkBundle) {
frameworkBundle = [NSBundle mainBundle];
}
frameworkBundle = [NSBundle bundleForClass:[self class]];
});
return frameworkBundle;
}
Expand Down
Loading