-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add Community Supported tvOS #590
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
Conversation
Initial tvOS project sample.
* Core Unit Tests for tvOS * tvOS 10 and shared schemes * copyrights * style fixes
* Example using Firebase Storage. * Remove unnecessary AppDelegate methods * Fixed comment on constants
* Build and unit test Database for tvOS * delete blank line
* Build environment for tvOS Auth * Added Auth example for email and password sign in. * Fixed TARGET_OS_TV check * Cleaned up storyboard
Merge master to tvOS master
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exciting! It'll be great to get Firestore support too if possible. LGTM, will wait to see what the others think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks awesome! I have some question about the Storage and Database sample.
import UIKit | ||
import FirebaseDatabase | ||
|
||
/// A class to demonstrate the power of the Firebase Realtime Database. This will show a number read |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: would prefer if this just read "A class to demonstrate the Firebase Realtime Database API."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
// MARK: - Internal Helpers | ||
|
||
/// Update the number on the server by a particular value. Note: the number passed in should only | ||
/// be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix this comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
/// be | ||
private func changeServerValue(with type: Counter) { | ||
let ref = Database.database().reference(withPath: Constants.databasePath) | ||
// Update the current value of the number! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Remove "!"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
return TransactionResult.abort() | ||
} | ||
|
||
currentData.value = value + type.rawValue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't write much Swift, but it seems a little strange to me to use the index value of an enum in a computation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've used enums a bit like this since they're a lot more flexible and not limited to just a raw value anymore. It could be expanded in the future to have different values, it just saves the switch
statement.
I added an intValue
calculated property that returns the rawValue
internally, so it's more of an implementation detail as opposed to relying on the functionality externally. Does that make more sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it does. Thanks for cleaning this up.
|
||
// We could have the image cached already causing the completion block to run before this line. | ||
// If that's the case, we don't need to do anything else and can return. | ||
if case .downloaded = state { return } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Firebase Storage doesn't have a cache. Can you explain what is going on here? Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, interesting. There were a few situations where if you already downloaded the photo + cleared it, the completion block setting the state to downloaded
would be triggered before the code afterward setting it to downloading
. Maybe this is Apple's caching under the hood?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be using an NSURLCache by default, but even with that I would be surprised that this code would race. There might be something else going on here, but I am not quite sure what it could be.
Either way, please remove the word "cache" from the comment so that our users don't get any wrong ideas :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated, thanks!
// Start the download! | ||
let storage = Storage.storage() | ||
let ref = storage.reference(withPath: Constants.downloadPath) | ||
let task = ref.getData(maxSize: Constants.maxSize) { [unowned self] (data, error) in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we showcase how to display progress updates as well?
|
||
// We could have the image cached already causing the completion block to run before this line. | ||
// If that's the case, we don't need to do anything else and can return. | ||
if case .downloaded = state { return } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be using an NSURLCache by default, but even with that I would be surprised that this code would race. There might be something else going on here, but I am not quite sure what it could be.
Either way, please remove the word "cache" from the comment so that our users don't get any wrong ideas :)
@@ -73,7 +73,9 @@ - (void)getTokenWithCallback:(FIRAuthAPNSTokenCallback)callback { | |||
} else { | |||
#pragma clang diagnostic push | |||
#pragma clang diagnostic ignored "-Wdeprecated-declarations" | |||
#if !TARGET_OS_TV |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer using #if TARGET_OS_IOS
here as this should only be used for the iOS platform.
I also suspect that this check might not be needed as an APNS token manager should only instantiated on the Auth instance for iOS targets. Did you find this check necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed! The check is necessary since UIApplication doesn't have a registerForRemoteNotificationTypes:
method available in tvOS so this fails to compile unless it's wrapped.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha :) thanks for the background.
|
||
Auth.auth().signIn(withEmail: email, password: password) { [unowned self] (user, error) in | ||
guard let user = user else { | ||
print("Error retrieving user: \(error!)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Error signing in" seems more fitting here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, done.
return nil | ||
} | ||
|
||
guard let userPassword = password.text, userPassword.count > 2 else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Firebase Auth backend currently enforces a minimum password length of 6 characters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, thanks!
/// Validate the inputs for user email and password, returning the username and password if valid, | ||
/// otherwise nil. | ||
private func validatedInputs() -> (email: String, password: String)? { | ||
guard let userEmail = emailAddress.text, userEmail.count > 3 else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Firebase Auth backend does email validation, you may want to rely on the backend validation in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah okay, I figured this way if someone just tries to hit "Go" without typing anything in, we'd throw up an error before bothering the backend. In a real scenario I'd probably highlight this in the UI, etc but this was a quick fix. I can remove it entirely but I don't think it hurts having it here, since it's more of a pre-validation than a full validation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. We refrain from doing validation on the client because it's easier and faster to update the server if needs be. Makes total senses to save the round trip in a sample app.
|
||
Auth.auth().createUser(withEmail: email, password: password) { [unowned self] (user, error) in | ||
guard let user = user else { | ||
print("Error retrieving user: \(error!)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Error signing up" seems more fitting here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch! Done
😍 |
* Update CHANGELOG for macOS AppKit dependency. (#609) * Add Community Supported tvOS (#590) Add Community Supported tvOS for Core, Auth, Database and Storage. Add tvOS unit tests Add tvOS sample app Update README.md Add tvOS to travis testing * Adds API Test for Email Update (#613) * update Gemfile for Travis (#620) * update Travis to Xcode 9.2 (#619) * Removing an obsolete setting from plist files (#617) * Removing an obsolete setting from plist files * Fixing Unit Tests * Fixing nullability * Fully qualify protoc-generated outputs (#626) * Fully-qualify imports in the protocol compiler output * pbxproj updates from running pod update * New checked-in proto outputs * Port StringPrintf from //base (#624) * Port StringPrintf from //base. Prefer this to approaches based on variadic templates. While the variadic template mechanisms are strictly safer, they result in binary bloat we can't afford. This is essentially the same StringPrintf previously open sourced as a part of protobuf, though updated for C++11 which saves a copy and a temporary buffer on the heap. * Add abseil as a subdirectory of Firestore This saves having to redefine all the libraries that abseil defines as imported libraries. * Rename firebase_firesture_util_log_* targets Cut the log out of the name to reflect that these will get more components besides just logging. * Update tests for firebase_firestore_util renames
Add Community Supported tvOS for Core, Auth, Database and Storage. Add tvOS unit tests Add tvOS sample app Update README.md Add tvOS to travis testing
Add Community Supported tvOS for Core, Auth, Database and Storage.
Add tvOS unit tests
Add tvOS sample app
Update README.md
Add tvOS to travis testing