Skip to content

Commit b91b893

Browse files
committed
FirebaseUI Phone Auth. Add phone auth target framework.
1 parent 00a211c commit b91b893

File tree

19 files changed

+1542
-405
lines changed

19 files changed

+1542
-405
lines changed

FirebaseAuthUI/FUIStaticContentTableViewManager.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -220,20 +220,8 @@ typedef NS_ENUM(NSInteger, FUIStaticContentTableViewCellType) {
220220
@brief Convenience factory method for a new instance of @c FUIStaticContentTableViewCell.
221221
@param title The text of the @c titleLabel of the @c FUIStaticContentTableViewCell.
222222
@param value The text of the @c detailTextLabel of the @c FUIStaticContentTableViewCell.
223-
@param action A block which is executed when the cell is selected.
224223
@param type Style of displaying cell.
225-
*/
226-
+ (instancetype)cellWithTitle:(nullable NSString *)title
227-
value:(nullable NSString *)value
228-
type:(FUIStaticContentTableViewCellType) type
229-
action:(nullable FUIStaticContentTableViewCellAction)action;
230-
231-
/** @fn cellWithTitle:value:type:action:
232-
@brief Convenience factory method for a new instance of @c FUIStaticContentTableViewCell.
233-
@param title The text of the @c titleLabel of the @c FUIStaticContentTableViewCell.
234-
@param value The text of the @c detailTextLabel of the @c FUIStaticContentTableViewCell.
235224
@param action A block which is executed when the cell is selected.
236-
@param type Style of displaying cell.
237225
*/
238226
+ (instancetype)cellWithTitle:(nullable NSString *)title
239227
value:(nullable NSString *)value

FirebasePhoneAuthUI/FUIPhoneAuth.h

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+
17+
#import <FirebaseAuthUI/FUIAuth.h>
18+
19+
NS_ASSUME_NONNULL_BEGIN
20+
21+
/** @class FUIPhoneAuth
22+
@brief AuthUI components for Phone Sign In.
23+
*/
24+
@interface FUIPhoneAuth : NSObject <FUIAuthProvider>
25+
26+
@end
27+
28+
NS_ASSUME_NONNULL_END

FirebasePhoneAuthUI/FUIPhoneAuth.m

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
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 "FUIPhoneAuth.h"
18+
19+
#import <FirebaseAuth/FIRPhoneAuthProvider.h>
20+
21+
NS_ASSUME_NONNULL_BEGIN
22+
23+
/** @var kTableName
24+
@brief The name of the strings table to search for localized strings.
25+
*/
26+
static NSString *const kTableName = @"FirebasePhoneAuthUI";
27+
28+
/** @var kSignInWithTwitter
29+
@brief The string key for localized button text.
30+
*/
31+
static NSString *const kSignInWithTwitter = @"SignInWithPhone";
32+
33+
@implementation FUIPhoneAuth
34+
35+
/** @fn frameworkBundle
36+
@brief Returns the auth provider's resource bundle.
37+
@return Resource bundle for the auth provider.
38+
*/
39+
+ (NSBundle *)frameworkBundle {
40+
static NSBundle *frameworkBundle = nil;
41+
static dispatch_once_t predicate;
42+
dispatch_once(&predicate, ^{
43+
frameworkBundle = [NSBundle bundleForClass:[self class]];
44+
});
45+
return frameworkBundle;
46+
}
47+
48+
/** @fn imageNamed:
49+
@brief Returns an image from the resource bundle given a resource name.
50+
@param name The name of the image file.
51+
@return The image object for the named file.
52+
*/
53+
+ (UIImage *)imageNamed:(NSString *)name {
54+
NSString *path = [[[self class] frameworkBundle] pathForResource:name ofType:@"png"];
55+
return [UIImage imageWithContentsOfFile:path];
56+
}
57+
58+
/** @fn localizedStringForKey:
59+
@brief Returns the localized text associated with a given string key. Will default to english
60+
text if the string is not available for the current localization.
61+
@param key A string key which identifies localized text in the .strings files.
62+
@return Localized value of the string identified by the key.
63+
*/
64+
+ (NSString *)localizedStringForKey:(NSString *)key {
65+
NSBundle *frameworkBundle = [[self class] frameworkBundle];
66+
return [frameworkBundle localizedStringForKey:key value:nil table:kTableName];
67+
}
68+
69+
#pragma mark - FUIAuthProvider
70+
71+
- (NSString *)providerID {
72+
return FIRPhoneAuthProviderID;
73+
}
74+
75+
/** @fn accessToken:
76+
@brief Phone Auth token is matched by FirebaseUI User Access Token
77+
*/
78+
- (NSString *)accessToken {
79+
return nil; // TODO: implement
80+
}
81+
82+
/** @fn idToken:
83+
@brief Phone Auth Token Secret is matched by FirebaseUI User Id Token
84+
*/
85+
- (NSString *)idToken {
86+
return nil; // TODO: implement
87+
}
88+
89+
- (NSString *)shortName {
90+
return @"Phone";
91+
}
92+
93+
- (NSString *)signInLabel {
94+
return [[self class] localizedStringForKey:kSignInWithTwitter];
95+
}
96+
97+
- (UIImage *)icon {
98+
return [[self class] imageNamed:@"ic_phone"];
99+
}
100+
101+
- (UIColor *)buttonBackgroundColor {
102+
return [UIColor colorWithRed:71.0f/255.0f green:154.0f/255.0f blue:234.0f/255.0f alpha:1.0f];
103+
}
104+
105+
- (UIColor *)buttonTextColor {
106+
return [UIColor whiteColor];
107+
}
108+
109+
- (void)signInWithEmail:(nullable NSString *)email
110+
presentingViewController:(nullable UIViewController *)presentingViewController
111+
completion:(nullable FIRAuthProviderSignInCompletionBlock)completion {
112+
// TODO: implement
113+
}
114+
115+
- (void)signOut {
116+
// TODO: implement
117+
}
118+
119+
- (BOOL)handleOpenURL:(NSURL *)URL sourceApplication:(nullable NSString *)sourceApplication {
120+
return NO; // TODO: implement
121+
}
122+
123+
#pragma mark - Private methods
124+
125+
126+
NS_ASSUME_NONNULL_END
127+
128+
@end
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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 UIKit;
18+
19+
//! Project version number for FirebasePhoneAuthUI.
20+
FOUNDATION_EXPORT double FirebasePhoneAuthUIVersionNumber;
21+
22+
//! Project version string for FirebasePhoneAuthUI.
23+
FOUNDATION_EXPORT const unsigned char FirebasePhoneAuthUIVersionString[];
24+
25+
#import <FirebasePhoneAuthUI/FUIPhoneAuth.h>

FirebasePhoneAuthUI/Info.plist

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>en</string>
7+
<key>CFBundleExecutable</key>
8+
<string>$(EXECUTABLE_NAME)</string>
9+
<key>CFBundleIdentifier</key>
10+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11+
<key>CFBundleInfoDictionaryVersion</key>
12+
<string>6.0</string>
13+
<key>CFBundleName</key>
14+
<string>$(PRODUCT_NAME)</string>
15+
<key>CFBundlePackageType</key>
16+
<string>FMWK</string>
17+
<key>CFBundleShortVersionString</key>
18+
<string>1.0</string>
19+
<key>CFBundleVersion</key>
20+
<string>$(CURRENT_PROJECT_VERSION)</string>
21+
<key>NSPrincipalClass</key>
22+
<string></string>
23+
</dict>
24+
</plist>
246 Bytes
Loading
420 Bytes
Loading
597 Bytes
Loading
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// The text of the button used to sign-in with Phone.
2+
"SignInWithPhone" = "Sign in with phone";
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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 <XCTest/XCTest.h>
18+
19+
@interface FirebasePhoneAuthUITests : XCTestCase
20+
21+
@end
22+
23+
@implementation FirebasePhoneAuthUITests
24+
25+
- (void)setUp {
26+
[super setUp];
27+
// TODO: Put setup code here.
28+
}
29+
30+
- (void)tearDown {
31+
// TODO: Put teardown code here.
32+
[super tearDown];
33+
}
34+
35+
@end

0 commit comments

Comments
 (0)