Skip to content

Commit 70d8753

Browse files
authored
Merge pull request #156 from firebase/v0.5.6
Merge v0.5.6 into master
2 parents 38f026d + 279ba82 commit 70d8753

27 files changed

+3557
-7061
lines changed

FirebaseAuthUI/FIRAuthUIUtils.m

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,7 @@ + (NSBundle *)frameworkBundle {
2222
static NSBundle *frameworkBundle = nil;
2323
static dispatch_once_t predicate;
2424
dispatch_once(&predicate, ^{
25-
NSString *mainBundlePath = [[NSBundle mainBundle] resourcePath];
26-
NSString *frameworkBundlePath =
27-
[mainBundlePath stringByAppendingPathComponent:@"FirebaseAuthUIBundle.bundle"];
28-
frameworkBundle = [NSBundle bundleWithPath:frameworkBundlePath];
29-
if (!frameworkBundle) {
30-
frameworkBundle = [NSBundle mainBundle];
31-
}
25+
frameworkBundle = [NSBundle bundleForClass:[self class]];
3226
});
3327
return frameworkBundle;
3428
}

FirebaseAuthUITests/FIRAuthUITest.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ @implementation FUILoginProvider
3333
- (NSString *)providerID { return @"provider id"; }
3434
- (NSString *)shortName { return @"login provider"; }
3535
- (NSString *)signInLabel { return @"sign in label"; }
36+
- (NSString *)accessToken { return @"accessToken"; }
37+
- (NSString *)idToken { return @"idToken"; }
3638

3739
- (UIImage *)icon {
3840
return [[UIImage alloc] init];

FirebaseAuthUITests/GoogleService-Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<key>IS_SIGNIN_ENABLED</key>
3434
<true/>
3535
<key>GOOGLE_APP_ID</key>
36-
<string>google-app-id</string>
36+
<string>0:000000000000:ios:0000000000000000</string>
3737
<key>DATABASE_URL</key>
3838
<string>database-url</string>
3939
</dict>

FirebaseFacebookAuthUI/FIRFacebookAuthUI.h

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,35 +23,23 @@ NS_ASSUME_NONNULL_BEGIN
2323
*/
2424
@interface FIRFacebookAuthUI : NSObject <FIRAuthProviderUI>
2525

26-
/** @property appId
27-
@brief The Facebook App ID.
28-
*/
29-
@property(nonatomic, readonly, copy) NSString *appID;
30-
3126
/** @property scopes
3227
@brief The scopes to use with Facebook Login.
3328
@remarks Defaults to using "email" scopes.
3429
*/
3530
@property(nonatomic, readonly, copy) NSArray<NSString *> *scopes;
3631

3732
/** @fn init
38-
@brief Please use initWithAppId:
39-
*/
40-
- (instancetype)init NS_UNAVAILABLE;
41-
42-
/** @fn initWithAppID:
4333
@brief Conevenience initializer. Uses a default permission of `@[ "email" ]`.
44-
@param appID The Facebook App ID.
4534
*/
46-
- (instancetype)initWithAppID:(NSString *)appID;
35+
- (instancetype)init;
4736

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

5644
@end
5745

FirebaseFacebookAuthUI/FIRFacebookAuthUI.m

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@
2222
#import <FBSDKLoginKit/FBSDKLoginKit.h>
2323
#import <FirebaseAuthUI/FIRAuthUIErrorUtils.h>
2424

25-
/** @var kBundleFileName
26-
@brief The name of the bundle containing Facebook auth provider assets/resources.
27-
*/
28-
static NSString *const kBundleFileName = @"FirebaseFacebookAuthUIBundle.bundle";
29-
3025
/** @var kTableName
3126
@brief The name of the strings table to search for localized strings.
3227
*/
@@ -37,6 +32,16 @@
3732
*/
3833
static NSString *const kSignInWithFacebook = @"SignInWithFacebook";
3934

35+
/** @var kFacebookAppId
36+
@brief The string key used to read Facebook App Id from Info.plist.
37+
*/
38+
static NSString *const kFacebookAppId = @"FacebookAppID";
39+
40+
/** @var kFacebookDisplayName
41+
@brief The string key used to read Facebook App Name from Info.plist.
42+
*/
43+
static NSString *const kFacebookDisplayName = @"FacebookDisplayName";
44+
4045
@implementation FIRFacebookAuthUI {
4146
/** @var _loginManager
4247
@brief The Facebook login manager.
@@ -49,24 +54,17 @@ @implementation FIRFacebookAuthUI {
4954
FIRAuthProviderSignInCompletionBlock _pendingSignInCallback;
5055
}
5156

52-
- (instancetype)init {
53-
@throw [NSException exceptionWithName:@"Attempt to call unavailable initializer."
54-
reason:@"Please call the designated initializer."
55-
userInfo:nil];
56-
}
57-
58-
- (instancetype)initWithAppID:(NSString *)appID permissions:(NSArray *)permissions {
57+
- (instancetype)initWithPermissions:(NSArray *)permissions {
5958
self = [super init];
6059
if (self != nil) {
6160
_scopes = permissions;
62-
[FBSDKSettings setAppID:appID];
63-
_loginManager = [[FBSDKLoginManager alloc] init];
61+
[self configureProvider];
6462
}
6563
return self;
6664
}
6765

68-
- (instancetype)initWithAppID:(NSString *)appID {
69-
return [self initWithAppID:appID permissions:@[ @"email" ]];
66+
- (instancetype)init {
67+
return [self initWithPermissions:@[ @"email" ]];
7068
}
7169

7270
/** @fn frameworkBundle
@@ -77,13 +75,7 @@ + (NSBundle *)frameworkBundle {
7775
static NSBundle *frameworkBundle = nil;
7876
static dispatch_once_t predicate;
7977
dispatch_once(&predicate, ^{
80-
NSString *mainBundlePath = [[NSBundle mainBundle] resourcePath];
81-
NSString *frameworkBundlePath =
82-
[mainBundlePath stringByAppendingPathComponent:kBundleFileName];
83-
frameworkBundle = [NSBundle bundleWithPath:frameworkBundlePath];
84-
if (!frameworkBundle) {
85-
frameworkBundle = [NSBundle mainBundle];
86-
}
78+
frameworkBundle = [NSBundle bundleForClass:[self class]];
8779
});
8880
return frameworkBundle;
8981
}
@@ -214,4 +206,22 @@ - (void)callbackWithCredential:(nullable FIRAuthCredential *)credential
214206
}
215207
}
216208

209+
/** @fn callbackWithCredential:error:
210+
@brief Validates that Facebook SDK data was filled in Info.plist and creates Facebook login manager
211+
*/
212+
- (void)configureProvider {
213+
NSBundle *bundle = [[self class] frameworkBundle];
214+
NSString *facebookAppId = [bundle objectForInfoDictionaryKey:kFacebookAppId];
215+
NSString *facebookDisplayName = [bundle objectForInfoDictionaryKey:kFacebookDisplayName];
216+
217+
if (!(facebookAppId && facebookDisplayName)) {
218+
[NSException raise:NSInternalInconsistencyException
219+
format:@"Please set FacebookAppID, FacebookDisplayName, and\nURL types > Url "
220+
@"Schemes in `Supporting Files/Info.plist` according to "
221+
@"https://developers.facebook.com/docs/ios/getting-started"];
222+
}
223+
224+
_loginManager = [[FBSDKLoginManager alloc] init];
225+
}
226+
217227
@end
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//
2+
// Copyright (c) 2016 Google Inc.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
17+
#import <FirebaseFacebookAuthUI/FirebaseFacebookAuthUI.h>
18+
19+
@interface FIRFacebookAuthUITest : FIRFacebookAuthUI
20+
21+
@end
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//
2+
// Copyright (c) 2016 Google Inc.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
#import "FIRFacebookAuthUITest.h"
17+
18+
@implementation FIRFacebookAuthUITest
19+
20+
+ (NSBundle *)frameworkBundle {
21+
static NSBundle *frameworkBundle = nil;
22+
static dispatch_once_t predicate;
23+
dispatch_once(&predicate, ^{
24+
frameworkBundle = [NSBundle bundleForClass:[self class]];
25+
});
26+
return frameworkBundle;
27+
}
28+
@end

FirebaseFacebookAuthUITests/FirebaseFacebookAuthUITests.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
//
1616

1717
@import XCTest;
18-
@import FirebaseFacebookAuthUI;
18+
#import "FIRFacebookAuthUITest.h"
1919

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

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

3131
- (void)testItExists {

FirebaseFacebookAuthUITests/Info.plist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,9 @@
1818
<string>????</string>
1919
<key>CFBundleVersion</key>
2020
<string>1</string>
21+
<key>FacebookAppID</key>
22+
<string>{your-app-id}</string>
23+
<key>FacebookDisplayName</key>
24+
<string>{your-app-name}</string>
2125
</dict>
2226
</plist>

FirebaseGoogleAuthUI/FIRGoogleAuthUI.h

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ NS_ASSUME_NONNULL_BEGIN
2323
*/
2424
@interface FIRGoogleAuthUI : NSObject <FIRAuthProviderUI>
2525

26-
/** @property clientID
27-
@brief The Google Sign In client ID.
28-
*/
29-
@property(nonatomic, copy, readonly) NSString *clientID;
30-
3126
/** @property scopes
3227
@brief The scopes to use with Google Sign In.
3328
@remarks Defaults to using email and profile scopes. For a list of all scopes
@@ -36,24 +31,17 @@ NS_ASSUME_NONNULL_BEGIN
3631
@property(nonatomic, copy, readonly) NSArray<NSString *> *scopes;
3732

3833
/** @fn init
39-
@brief Please use initWithClientId:
40-
*/
41-
- (instancetype)init NS_UNAVAILABLE;
42-
43-
/** @fn initWithClientID:
44-
@brief Convenience initializer. Calls designated init with default
45-
scopes of "email" and "profile".
46-
@param clientId The Google Sign In client ID.
34+
@brief Convenience initializer. Calls designated init with default
35+
scopes of "email" and "profile".
4736
*/
48-
- (instancetype)initWithClientID:(NSString *)clientID;
37+
- (instancetype)init;
4938

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

5846
@end
5947

FirebaseGoogleAuthUI/FIRGoogleAuthUI.m

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@
1616

1717
#import "FIRGoogleAuthUI.h"
1818

19-
#import <GoogleSignIn/GoogleSignIn.h>
19+
#import <FirebaseAnalytics/FirebaseAnalytics.h>
2020
#import <FirebaseAuth/FIRGoogleAuthProvider.h>
2121
#import <FirebaseAuth/FIRUserInfo.h>
2222
#import <FirebaseAuthUI/FIRAuthUIErrorUtils.h>
23+
#import <FirebaseAuthUI/FirebaseAuthUI.h>
24+
#import <GoogleSignIn/GoogleSignIn.h>
2325

2426
/** @var kGoogleGamesScope
2527
@brief The OAuth scope string for the "Games" scope.
@@ -66,20 +68,12 @@ @implementation FIRGoogleAuthUI {
6668
}
6769

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

74-
- (instancetype)initWithClientID:(NSString *)clientID {
75-
return [self initWithClientID:clientID
76-
scopes:@[kGoogleUserInfoEmailScope, kGoogleUserInfoProfileScope]];
77-
}
78-
79-
- (instancetype)initWithClientID:(NSString *)clientID scopes:(NSArray *)scopes {
74+
- (instancetype)initWithScopes:(NSArray *)scopes {
8075
self = [super init];
8176
if (self) {
82-
_clientID = [clientID copy];
8377
_scopes = [scopes copy];
8478
}
8579
return self;
@@ -93,13 +87,7 @@ + (NSBundle *)frameworkBundle {
9387
static NSBundle *frameworkBundle = nil;
9488
static dispatch_once_t predicate;
9589
dispatch_once(&predicate, ^{
96-
NSString *mainBundlePath = [[NSBundle mainBundle] resourcePath];
97-
NSString *frameworkBundlePath =
98-
[mainBundlePath stringByAppendingPathComponent:@"FirebaseGoogleAuthUIBundle.bundle"];
99-
frameworkBundle = [NSBundle bundleWithPath:frameworkBundlePath];
100-
if (!frameworkBundle) {
101-
frameworkBundle = [NSBundle mainBundle];
102-
}
90+
frameworkBundle = [NSBundle bundleForClass:[self class]];
10391
});
10492
return frameworkBundle;
10593
}
@@ -230,7 +218,7 @@ - (GIDSignIn *)configuredGoogleSignIn {
230218
signIn.delegate = self;
231219
signIn.uiDelegate = self;
232220
signIn.shouldFetchBasicProfile = YES;
233-
signIn.clientID = _clientID;
221+
signIn.clientID = [[FIRApp defaultApp] options].clientID;
234222
signIn.scopes = _scopes;
235223
return signIn;
236224
}

FirebaseTwitterAuthUI/FIRTwitterAuthUI.m

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@
1919
#import <TwitterKit/TwitterKit.h>
2020
#import "FIRTwitterAuthUI.h"
2121

22-
/** @var kBundleFileName
23-
@brief The name of the bundle containing Twitter auth provider assets/resources.
24-
*/
25-
static NSString *const kBundleFileName = @"FirebaseTwitterAuthUIBundle.bundle";
26-
2722
/** @var kTableName
2823
@brief The name of the strings table to search for localized strings.
2924
*/
@@ -44,13 +39,7 @@ + (NSBundle *)frameworkBundle {
4439
static NSBundle *frameworkBundle = nil;
4540
static dispatch_once_t predicate;
4641
dispatch_once(&predicate, ^{
47-
NSString *mainBundlePath = [[NSBundle mainBundle] resourcePath];
48-
NSString *frameworkBundlePath =
49-
[mainBundlePath stringByAppendingPathComponent:kBundleFileName];
50-
frameworkBundle = [NSBundle bundleWithPath:frameworkBundlePath];
51-
if (!frameworkBundle) {
52-
frameworkBundle = [NSBundle mainBundle];
53-
}
42+
frameworkBundle = [NSBundle bundleForClass:[self class]];
5443
});
5544
return frameworkBundle;
5645
}

0 commit comments

Comments
 (0)