diff options
author | Paul Beusterien <paulbeusterien@google.com> | 2018-05-01 07:23:58 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-01 07:23:58 -0700 |
commit | d7e1ba36acd55305927c677cd90acc150045395c (patch) | |
tree | ade20e8866f52044b63e903ad662c0d8a8f4455e | |
parent | 7b99c5be3e0e36592fac640ec433ea2e0ab412ec (diff) | |
parent | a0e10d1add6b7cf7213b8fd73aaf78d9d0ecd2eb (diff) |
Merge pull request #1203 from firebase/pb-cherry-pick4
Two Auth and two Core cherry-picks for 5.0.0
-rw-r--r-- | Example/Auth/Sample/MainViewController.m | 40 | ||||
-rw-r--r-- | Example/Auth/Tests/FIRPhoneAuthProviderTests.m | 115 | ||||
-rw-r--r-- | Example/Core/Tests/FIRLoggerTest.m | 27 | ||||
-rw-r--r-- | Firebase/Auth/Source/AuthProviders/Phone/FIRPhoneAuthProvider.m | 14 | ||||
-rw-r--r-- | Firebase/Auth/Source/Public/FIRAuth.h | 29 | ||||
-rw-r--r-- | Firebase/Auth/Source/Public/FIRPhoneAuthProvider.h | 26 | ||||
-rw-r--r-- | Firebase/Auth/Source/Public/FIRUser.h | 25 | ||||
-rw-r--r-- | Firebase/Core/FIRLogger.m | 37 | ||||
-rw-r--r-- | Firebase/Core/Private/FIRLogger.h | 15 |
9 files changed, 132 insertions, 196 deletions
diff --git a/Example/Auth/Sample/MainViewController.m b/Example/Auth/Sample/MainViewController.m index 0da28c8..8667da5 100644 --- a/Example/Auth/Sample/MainViewController.m +++ b/Example/Auth/Sample/MainViewController.m @@ -574,14 +574,9 @@ NSString *const kCreateUserAccessibilityID = @"CreateUserAccessibilityID"; static NSString *const kPhoneAuthSectionTitle = @"Phone Auth"; /** @var kPhoneNumberSignInTitle - @brief The title for button to sign in with phone number. - */ -static NSString *const kPhoneNumberSignInTitle = @"Sign in With Phone Number"; - -/** @var kPhoneNumberSignInTitle @brief The title for button to sign in with phone number using reCAPTCHA. */ -static NSString *const kPhoneNumberSignInReCaptchaTitle = @"Sign in With Phone Number (reCAPTCHA)"; +static NSString *const kPhoneNumberSignInReCaptchaTitle = @"Sign in With Phone Number"; /** @var kIsNewUserToggleTitle @brief The title for button to enable new or existing user toggle. @@ -738,8 +733,6 @@ typedef enum { [StaticContentTableViewSection sectionWithTitle:kPhoneAuthSectionTitle cells:@[ [StaticContentTableViewCell cellWithTitle:kPhoneNumberSignInReCaptchaTitle action:^{ [weakSelf signInWithPhoneNumberWithPrompt]; }], - [StaticContentTableViewCell cellWithTitle:kPhoneNumberSignInTitle - action:^{ [weakSelf signInWithPhoneNumber]; }], [StaticContentTableViewCell cellWithTitle:kUpdatePhoneNumber action:^{ [weakSelf updatePhoneNumberWithPrompt]; }], [StaticContentTableViewCell cellWithTitle:kLinkPhoneNumber @@ -2858,37 +2851,6 @@ static NSDictionary<NSString *, NSString *> *parseURL(NSString *urlString) { } /** @fn signInWithPhoneNumber - @brief Allows sign in with phone number. - */ -- (void)signInWithPhoneNumber { - [self commonPhoneNumberInputWithTitle:@"Phone #" Completion:^(NSString *_Nullable phone) { - [self showSpinner:^{ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - [[AppManager phoneAuthProvider] verifyPhoneNumber:phone - completion:^(NSString *_Nullable verificationID, - NSError *_Nullable error) { -#pragma clang diagnostic pop - [self hideSpinner:^{ - if (error) { - [self logFailure:@"failed to send verification code" error:error]; - [self showMessagePrompt:error.localizedDescription]; - return; - } - [self logSuccess:@"Code sent"]; - - [self commonPhoneNumberInputWithTitle:@"Code" - Completion:^(NSString *_Nullable verificationCode) { - [self commontPhoneVerificationWithVerificationID:verificationID - verificationCode:verificationCode]; - }]; - }]; - }]; - }]; - }]; -} - -/** @fn signInWithPhoneNumber @brief Allows sign in with phone number using reCAPTCHA. @param phoneNumber Number pass in string. @completion A completion block to be executed after successful phone number sign in. diff --git a/Example/Auth/Tests/FIRPhoneAuthProviderTests.m b/Example/Auth/Tests/FIRPhoneAuthProviderTests.m index 96432c7..1bb42b1 100644 --- a/Example/Auth/Tests/FIRPhoneAuthProviderTests.m +++ b/Example/Auth/Tests/FIRPhoneAuthProviderTests.m @@ -283,9 +283,16 @@ static const NSTimeInterval kExpectationTimeout = 2; number was provided. */ - (void)testVerifyEmptyPhoneNumber { + id mockBundle = OCMClassMock([NSBundle class]); + OCMStub(ClassMethod([mockBundle mainBundle])).andReturn(mockBundle); + OCMStub([mockBundle objectForInfoDictionaryKey:@"CFBundleURLTypes"]) + .andReturn(@[ @{ @"CFBundleURLSchemes" : @[ kFakeReverseClientID ] } ]); + OCMStub([mockBundle bundleIdentifier]).andReturn(kFakeBundleID); + // Empty phone number is checked on the client side so no backend RPC is mocked. XCTestExpectation *expectation = [self expectationWithDescription:@"callback"]; [_provider verifyPhoneNumber:@"" + UIDelegate:nil completion:^(NSString *_Nullable verificationID, NSError *_Nullable error) { XCTAssertNotNil(error); XCTAssertEqual(error.code, FIRAuthErrorCodeMissingPhoneNumber); @@ -299,6 +306,12 @@ static const NSTimeInterval kExpectationTimeout = 2; number was provided. */ - (void)testVerifyInvalidPhoneNumber { + id mockBundle = OCMClassMock([NSBundle class]); + OCMStub(ClassMethod([mockBundle mainBundle])).andReturn(mockBundle); + OCMStub([mockBundle objectForInfoDictionaryKey:@"CFBundleURLTypes"]) + .andReturn(@[ @{ @"CFBundleURLSchemes" : @[ kFakeReverseClientID ] } ]); + OCMStub([mockBundle bundleIdentifier]).andReturn(kFakeBundleID); + OCMExpect([_mockNotificationManager checkNotificationForwardingWithCallback:OCMOCK_ANY]) .andCallBlock1(^(FIRAuthNotificationForwardingCallback callback) { callback(YES); }); OCMStub([_mockAppCredentialManager credential]) @@ -316,6 +329,7 @@ static const NSTimeInterval kExpectationTimeout = 2; XCTestExpectation *expectation = [self expectationWithDescription:@"callback"]; [_provider verifyPhoneNumber:kTestPhoneNumber + UIDelegate:nil completion:^(NSString *_Nullable verificationID, NSError *_Nullable error) { XCTAssertTrue([NSThread isMainThread]); XCTAssertNil(verificationID); @@ -332,6 +346,12 @@ static const NSTimeInterval kExpectationTimeout = 2; @brief Tests a successful invocation of @c verifyPhoneNumber:completion:. */ - (void)testVerifyPhoneNumber { + id mockBundle = OCMClassMock([NSBundle class]); + OCMStub(ClassMethod([mockBundle mainBundle])).andReturn(mockBundle); + OCMStub([mockBundle objectForInfoDictionaryKey:@"CFBundleURLTypes"]) + .andReturn(@[ @{ @"CFBundleURLSchemes" : @[ kFakeReverseClientID ] } ]); + OCMStub([mockBundle bundleIdentifier]).andReturn(kFakeBundleID); + OCMExpect([_mockNotificationManager checkNotificationForwardingWithCallback:OCMOCK_ANY]) .andCallBlock1(^(FIRAuthNotificationForwardingCallback callback) { callback(YES); }); OCMStub([_mockAppCredentialManager credential]) @@ -351,6 +371,7 @@ static const NSTimeInterval kExpectationTimeout = 2; XCTestExpectation *expectation = [self expectationWithDescription:@"callback"]; [_provider verifyPhoneNumber:kTestPhoneNumber + UIDelegate:nil completion:^(NSString *_Nullable verificationID, NSError *_Nullable error) { XCTAssertTrue([NSThread isMainThread]); XCTAssertNil(error); @@ -368,6 +389,12 @@ static const NSTimeInterval kExpectationTimeout = 2; is disabled. */ - (void)testVerifyPhoneNumberInTestMode { + id mockBundle = OCMClassMock([NSBundle class]); + OCMStub(ClassMethod([mockBundle mainBundle])).andReturn(mockBundle); + OCMStub([mockBundle objectForInfoDictionaryKey:@"CFBundleURLTypes"]) + .andReturn(@[ @{ @"CFBundleURLSchemes" : @[ kFakeReverseClientID ] } ]); + OCMStub([mockBundle bundleIdentifier]).andReturn(kFakeBundleID); + // Disable app verification. FIRAuthSettings *settings = [[FIRAuthSettings alloc] init]; settings.appVerificationDisabledForTesting = YES; @@ -389,6 +416,7 @@ static const NSTimeInterval kExpectationTimeout = 2; XCTestExpectation *expectation = [self expectationWithDescription:@"callback"]; [_provider verifyPhoneNumber:kTestPhoneNumber + UIDelegate:nil completion:^(NSString *_Nullable verificationID, NSError *_Nullable error) { XCTAssertTrue([NSThread isMainThread]); XCTAssertNil(error); @@ -406,6 +434,12 @@ static const NSTimeInterval kExpectationTimeout = 2; is disabled. */ - (void)testVerifyPhoneNumberInTestModeFailure { + id mockBundle = OCMClassMock([NSBundle class]); + OCMStub(ClassMethod([mockBundle mainBundle])).andReturn(mockBundle); + OCMStub([mockBundle objectForInfoDictionaryKey:@"CFBundleURLTypes"]) + .andReturn(@[ @{ @"CFBundleURLSchemes" : @[ kFakeReverseClientID ] } ]); + OCMStub([mockBundle bundleIdentifier]).andReturn(kFakeBundleID); + // Disable app verification. FIRAuthSettings *settings = [[FIRAuthSettings alloc] init]; settings.appVerificationDisabledForTesting = YES; @@ -425,6 +459,7 @@ static const NSTimeInterval kExpectationTimeout = 2; XCTestExpectation *expectation = [self expectationWithDescription:@"callback"]; [_provider verifyPhoneNumber:kTestPhoneNumber + UIDelegate:nil completion:^(NSString *_Nullable verificationID, NSError *_Nullable error) { XCTAssertTrue([NSThread isMainThread]); XCTAssertNil(verificationID); @@ -901,10 +936,17 @@ static const NSTimeInterval kExpectationTimeout = 2; @brief Tests returning an error for the app failing to forward notification. */ - (void)testNotForwardingNotification { + id mockBundle = OCMClassMock([NSBundle class]); + OCMStub(ClassMethod([mockBundle mainBundle])).andReturn(mockBundle); + OCMStub([mockBundle objectForInfoDictionaryKey:@"CFBundleURLTypes"]) + .andReturn(@[ @{ @"CFBundleURLSchemes" : @[ kFakeReverseClientID ] } ]); + OCMStub([mockBundle bundleIdentifier]).andReturn(kFakeBundleID); + OCMExpect([_mockNotificationManager checkNotificationForwardingWithCallback:OCMOCK_ANY]) .andCallBlock1(^(FIRAuthNotificationForwardingCallback callback) { callback(NO); }); XCTestExpectation *expectation = [self expectationWithDescription:@"callback"]; [_provider verifyPhoneNumber:kTestPhoneNumber + UIDelegate:nil completion:^(NSString *_Nullable verificationID, NSError *_Nullable error) { XCTAssertTrue([NSThread isMainThread]); XCTAssertNil(verificationID); @@ -919,19 +961,48 @@ static const NSTimeInterval kExpectationTimeout = 2; @brief Tests returning an error for the app failing to provide an APNS device token. */ - (void)testMissingAPNSToken { + id mockBundle = OCMClassMock([NSBundle class]); + OCMStub(ClassMethod([mockBundle mainBundle])).andReturn(mockBundle); + OCMStub([mockBundle objectForInfoDictionaryKey:@"CFBundleURLTypes"]) + .andReturn(@[ @{ @"CFBundleURLSchemes" : @[ kFakeReverseClientID ] } ]); + OCMStub([mockBundle bundleIdentifier]).andReturn(kFakeBundleID); + + // Simulate missing app token error. OCMExpect([_mockNotificationManager checkNotificationForwardingWithCallback:OCMOCK_ANY]) .andCallBlock1(^(FIRAuthNotificationForwardingCallback callback) { callback(YES); }); OCMExpect([_mockAppCredentialManager credential]).andReturn(nil); OCMExpect([_mockAPNSTokenManager getTokenWithCallback:OCMOCK_ANY]) - .andCallBlock1(^(FIRAuthAPNSTokenCallback callback) { callback(nil, nil); }); - // Expect verify client request to the backend wth empty token. - OCMExpect([_mockBackend verifyClient:[OCMArg any] callback:[OCMArg any]]) - .andCallBlock2(^(FIRVerifyClientRequest *request, - FIRVerifyClientResponseCallback callback) { - XCTAssertNil(request.appToken); + .andCallBlock1(^(FIRAuthAPNSTokenCallback callback) { + NSError *error = [NSError errorWithDomain:FIRAuthErrorDomain + code:FIRAuthErrorCodeMissingAppToken + userInfo:nil]; + callback(nil, error); + }); + OCMExpect([_mockBackend getProjectConfig:[OCMArg any] callback:[OCMArg any]]) + .andCallBlock2(^(FIRGetProjectConfigRequest *request, + FIRGetProjectConfigResponseCallback callback) { + XCTAssertNotNil(request); + dispatch_async(FIRAuthGlobalWorkQueue(), ^() { + id mockGetProjectConfigResponse = OCMClassMock([FIRGetProjectConfigResponse class]); + OCMStub([mockGetProjectConfigResponse authorizedDomains]). + andReturn(@[ kFakeAuthorizedDomain]); + callback(mockGetProjectConfigResponse, nil); + }); + }); + id mockUIDelegate = OCMProtocolMock(@protocol(FIRAuthUIDelegate)); + + // Expect view controller presentation by UIDelegate. + OCMExpect([_mockURLPresenter presentURL:OCMOCK_ANY + UIDelegate:mockUIDelegate + callbackMatcher:OCMOCK_ANY + completion:OCMOCK_ANY]).andDo(^(NSInvocation *invocation) { + __unsafe_unretained id unretainedArgument; + // Indices 0 and 1 indicate the hidden arguments self and _cmd. + // `completion` is at index 5 + [invocation getArgument:&unretainedArgument atIndex:5]; + FIRAuthURLPresentationCompletion completion = unretainedArgument; dispatch_async(FIRAuthGlobalWorkQueue(), ^() { - // The backend is supposed to return an error. - callback(nil, [NSError errorWithDomain:FIRAuthErrorDomain + completion(nil, [NSError errorWithDomain:FIRAuthErrorDomain code:FIRAuthErrorCodeMissingAppToken userInfo:nil]); }); @@ -939,23 +1010,28 @@ static const NSTimeInterval kExpectationTimeout = 2; XCTestExpectation *expectation = [self expectationWithDescription:@"callback"]; [_provider verifyPhoneNumber:kTestPhoneNumber + UIDelegate:mockUIDelegate completion:^(NSString *_Nullable verificationID, NSError *_Nullable error) { XCTAssertTrue([NSThread isMainThread]); - XCTAssertNil(verificationID); - XCTAssertEqualObjects(error.domain, FIRAuthErrorDomain); XCTAssertEqual(error.code, FIRAuthErrorCodeMissingAppToken); + XCTAssertNil(verificationID); [expectation fulfill]; }]; [self waitForExpectationsWithTimeout:kExpectationTimeout handler:nil]; + OCMVerifyAll(_mockBackend); OCMVerifyAll(_mockNotificationManager); - OCMVerifyAll(_mockAppCredentialManager); - OCMVerifyAll(_mockAPNSTokenManager); } /** @fn testVerifyClient @brief Tests verifying client before sending verification code. */ - (void)testVerifyClient { + id mockBundle = OCMClassMock([NSBundle class]); + OCMStub(ClassMethod([mockBundle mainBundle])).andReturn(mockBundle); + OCMStub([mockBundle objectForInfoDictionaryKey:@"CFBundleURLTypes"]) + .andReturn(@[ @{ @"CFBundleURLSchemes" : @[ kFakeReverseClientID ] } ]); + OCMStub([mockBundle bundleIdentifier]).andReturn(kFakeBundleID); + OCMExpect([_mockNotificationManager checkNotificationForwardingWithCallback:OCMOCK_ANY]) .andCallBlock1(^(FIRAuthNotificationForwardingCallback callback) { callback(YES); }); OCMExpect([_mockAppCredentialManager credential]).andReturn(nil); @@ -1007,6 +1083,7 @@ static const NSTimeInterval kExpectationTimeout = 2; XCTestExpectation *expectation = [self expectationWithDescription:@"callback"]; [_provider verifyPhoneNumber:kTestPhoneNumber + UIDelegate:nil completion:^(NSString *_Nullable verificationID, NSError *_Nullable error) { XCTAssertTrue([NSThread isMainThread]); XCTAssertNil(error); @@ -1024,6 +1101,12 @@ static const NSTimeInterval kExpectationTimeout = 2; @brief Tests failed retry after failing to send verification code. */ - (void)testSendVerificationCodeFailedRetry { + id mockBundle = OCMClassMock([NSBundle class]); + OCMStub(ClassMethod([mockBundle mainBundle])).andReturn(mockBundle); + OCMStub([mockBundle objectForInfoDictionaryKey:@"CFBundleURLTypes"]) + .andReturn(@[ @{ @"CFBundleURLSchemes" : @[ kFakeReverseClientID ] } ]); + OCMStub([mockBundle bundleIdentifier]).andReturn(kFakeBundleID); + OCMExpect([_mockNotificationManager checkNotificationForwardingWithCallback:OCMOCK_ANY]) .andCallBlock1(^(FIRAuthNotificationForwardingCallback callback) { callback(YES); }); @@ -1097,6 +1180,7 @@ static const NSTimeInterval kExpectationTimeout = 2; XCTestExpectation *expectation = [self expectationWithDescription:@"callback"]; [_provider verifyPhoneNumber:kTestPhoneNumber + UIDelegate:nil completion:^(NSString *_Nullable verificationID, NSError *_Nullable error) { XCTAssertTrue([NSThread isMainThread]); XCTAssertNil(verificationID); @@ -1114,6 +1198,12 @@ static const NSTimeInterval kExpectationTimeout = 2; @brief Tests successful retry after failing to send verification code. */ - (void)testSendVerificationCodeSuccessFulRetry { + id mockBundle = OCMClassMock([NSBundle class]); + OCMStub(ClassMethod([mockBundle mainBundle])).andReturn(mockBundle); + OCMStub([mockBundle objectForInfoDictionaryKey:@"CFBundleURLTypes"]) + .andReturn(@[ @{ @"CFBundleURLSchemes" : @[ kFakeReverseClientID ] } ]); + OCMStub([mockBundle bundleIdentifier]).andReturn(kFakeBundleID); + OCMExpect([_mockNotificationManager checkNotificationForwardingWithCallback:OCMOCK_ANY]) .andCallBlock1(^(FIRAuthNotificationForwardingCallback callback) { callback(YES); }); @@ -1189,6 +1279,7 @@ static const NSTimeInterval kExpectationTimeout = 2; XCTestExpectation *expectation = [self expectationWithDescription:@"callback"]; [_provider verifyPhoneNumber:kTestPhoneNumber + UIDelegate:nil completion:^(NSString *_Nullable verificationID, NSError *_Nullable error) { XCTAssertNil(error); XCTAssertEqualObjects(verificationID, kTestVerificationID); diff --git a/Example/Core/Tests/FIRLoggerTest.m b/Example/Core/Tests/FIRLoggerTest.m index dfc7cc8..7da62db 100644 --- a/Example/Core/Tests/FIRLoggerTest.m +++ b/Example/Core/Tests/FIRLoggerTest.m @@ -239,33 +239,6 @@ static NSString *const kMessageCode = @"I-COR000001"; XCTAssertEqual(FIRLoggerLevelDebug, ASL_LEVEL_DEBUG); } -- (void)testErrorNumberIncrement { - OCMStub([self.userDefaultsMock integerForKey:kFIRLoggerErrorCountKey]).andReturn(10); - OCMExpect([self.userDefaultsMock setInteger:11 forKey:kFIRLoggerErrorCountKey]); - FIRLogError(kFIRLoggerCore, kMessageCode, @"Error."); - - // Use a delay since the logging is async. - OCMVerifyAllWithDelay(self.userDefaultsMock, 1); -} - -- (void)testWarningNumberIncrement { - OCMStub([self.userDefaultsMock integerForKey:kFIRLoggerWarningCountKey]).andReturn(1); - OCMExpect([self.userDefaultsMock setInteger:2 forKey:kFIRLoggerWarningCountKey]); - FIRLogWarning(kFIRLoggerCore, kMessageCode, @"Warning."); - - // Use a delay since the logging is async. - OCMVerifyAllWithDelay(self.userDefaultsMock, 1); -} - -- (void)testResetIssuesCount { - OCMExpect([self.userDefaultsMock setInteger:0 forKey:kFIRLoggerErrorCountKey]); - OCMExpect([self.userDefaultsMock setInteger:0 forKey:kFIRLoggerWarningCountKey]); - FIRResetNumberOfIssuesLogged(); - - // Use a delay since the logging is async. - OCMVerifyAllWithDelay(self.userDefaultsMock, 1); -} - // Helper functions. - (BOOL)logExists { [self drainFIRClientQueue]; diff --git a/Firebase/Auth/Source/AuthProviders/Phone/FIRPhoneAuthProvider.m b/Firebase/Auth/Source/AuthProviders/Phone/FIRPhoneAuthProvider.m index 2d06a15..3532861 100644 --- a/Firebase/Auth/Source/AuthProviders/Phone/FIRPhoneAuthProvider.m +++ b/Firebase/Auth/Source/AuthProviders/Phone/FIRPhoneAuthProvider.m @@ -109,20 +109,6 @@ NSString *const kReCAPTCHAURLStringFormat = @"https://%@/__/auth/handler?"; } - (void)verifyPhoneNumber:(NSString *)phoneNumber - completion:(nullable FIRVerificationResultCallback)completion { - dispatch_async(FIRAuthGlobalWorkQueue(), ^{ - [self internalVerifyPhoneNumber:phoneNumber completion:^(NSString *_Nullable verificationID, - NSError *_Nullable error) { - if (completion) { - dispatch_async(dispatch_get_main_queue(), ^{ - completion(verificationID, error); - }); - } - }]; - }); -} - -- (void)verifyPhoneNumber:(NSString *)phoneNumber UIDelegate:(nullable id<FIRAuthUIDelegate>)UIDelegate completion:(nullable FIRVerificationResultCallback)completion { if (![self isCallbackSchemeRegistered]) { diff --git a/Firebase/Auth/Source/Public/FIRAuth.h b/Firebase/Auth/Source/Public/FIRAuth.h index 2901fca..a3ed960 100644 --- a/Firebase/Auth/Source/Public/FIRAuth.h +++ b/Firebase/Auth/Source/Public/FIRAuth.h @@ -429,10 +429,9 @@ NS_SWIFT_NAME(Auth) password:(NSString *)password completion:(nullable FIRAuthDataResultCallback)completion DEPRECATED_MSG_ATTRIBUTE( - "signInAndRetrieveDataWithEmail:password:completion: is " - "deprecated. Please use" - " signInWithEmail:password:completion: for Objective-C or" - " signIn(withEmail:password:completion:) for Swift instead."); + "Please use signInWithEmail:password:completion: for" + " Objective-C or signIn(withEmail:password:completion:) for" + " Swift instead."); /** @fn signInWithCredential:completion: @brief Please use `signInAndRetrieveDataWithCredential:completion:` for Objective-C or @@ -475,11 +474,9 @@ NS_SWIFT_NAME(Auth) */ - (void)signInWithCredential:(FIRAuthCredential *)credential completion:(nullable FIRAuthResultCallback)completion DEPRECATED_MSG_ATTRIBUTE( - "signInWithCredential:completion: is" - " deprecated. Please use" - " signInAndRetrieveDataWithCredential:completion: for" - " Objective-C or signInAndRetrieveData(with:completion:) for" - " Swift instead."); + "Please use signInAndRetrieveDataWithCredential:completion:" + " for Objective-C or signInAndRetrieveData(with:completion:)" + " for Swift instead."); /** @fn signInAndRetrieveDataWithCredential:completion: @brief Asynchronously signs in to Firebase with the given 3rd-party credentials (e.g. a Facebook @@ -564,8 +561,7 @@ NS_SWIFT_NAME(Auth) */ - (void)signInAnonymouslyAndRetrieveDataWithCompletion: (nullable FIRAuthDataResultCallback)completion - DEPRECATED_MSG_ATTRIBUTE("signInAnonymouslyAndRetrieveDataWithCompletion: is deprecated." - " Please use signInAnonymouslyWithCompletion: for Objective-C or" + DEPRECATED_MSG_ATTRIBUTE("Please use signInAnonymouslyWithCompletion: for Objective-C or" " signInAnonymously(Completion:) for swift instead."); /** @fn signInWithCustomToken:completion: @@ -616,8 +612,7 @@ NS_SWIFT_NAME(Auth) - (void)signInAndRetrieveDataWithCustomToken:(NSString *)token completion:(nullable FIRAuthDataResultCallback)completion DEPRECATED_MSG_ATTRIBUTE( - "signInAndRetrieveDataWithCustomToken:completion: is" - " deprecated. Please use signInWithCustomToken:completion:" + "Please use signInWithCustomToken:completion:" "for Objective-C or signIn(withCustomToken:completion:) for" " Swift instead."); @@ -678,11 +673,9 @@ NS_SWIFT_NAME(Auth) password:(NSString *)password completion:(nullable FIRAuthDataResultCallback)completion DEPRECATED_MSG_ATTRIBUTE( - "createUserAndRetrieveDataWithEmail:password:completion: is" - " deprecated. Please use" - " createUserWithEmail:password:completion: for Objective-C or" - " createUser(withEmail:password:completion:) for Swift" - " instead."); + "Please use createUserWithEmail:password:completion: for" + " Objective-C or createUser(withEmail:password:completion:)" + " for Swift instead."); /** @fn confirmPasswordResetWithCode:newPassword:completion: @brief Resets the password given a code sent to the user outside of the app and a new password diff --git a/Firebase/Auth/Source/Public/FIRPhoneAuthProvider.h b/Firebase/Auth/Source/Public/FIRPhoneAuthProvider.h index bd68e84..28757f5 100644 --- a/Firebase/Auth/Source/Public/FIRPhoneAuthProvider.h +++ b/Firebase/Auth/Source/Public/FIRPhoneAuthProvider.h @@ -61,32 +61,6 @@ NS_SWIFT_NAME(PhoneAuthProvider) */ + (instancetype)providerWithAuth:(FIRAuth *)auth NS_SWIFT_NAME(provider(auth:)); -/** @fn verifyPhoneNumber:completion: - @brief Please use `verifyPhoneNumber:UIDelegate:completion:` instead. - - @param phoneNumber The phone number to be verified. - @param completion The callback to be invoked when the verification flow is finished. - - @remarks Possible error codes: - - + `FIRAuthErrorCodeAppNotVerified` - Indicates that Firebase could not retrieve the - silent push notification and therefore could not verify your app. - + `FIRAuthErrorCodeInvalidAppCredential` - Indicates that The APNs device token provided - is either incorrect or does not match the private certificate uploaded to the Firebase - Console. - + `FIRAuthErrorCodeQuotaExceeded` - Indicates that the phone verification quota for this - project has been exceeded. - + `FIRAuthErrorCodeInvalidPhoneNumber` - Indicates that the phone number provided is - invalid. - + `FIRAuthErrorCodeMissingPhoneNumber` - Indicates that a phone number was not provided. - + `FIRAuthErrorCodeMissingAppToken` - Indicates that the APNs device token could not be - obtained. The app may not have set up remote notification correctly, or may fail to - forward the APNs device token to FIRAuth if app delegate swizzling is disabled. - */ -- (void)verifyPhoneNumber:(NSString *)phoneNumber - completion:(nullable FIRVerificationResultCallback)completion - __attribute__((deprecated)); - /** @fn verifyPhoneNumber:UIDelegate:completion: @brief Starts the phone number authentication flow by sending a verifcation code to the specified phone number. diff --git a/Firebase/Auth/Source/Public/FIRUser.h b/Firebase/Auth/Source/Public/FIRUser.h index 1c7af7a..cc5d0a0 100644 --- a/Firebase/Auth/Source/Public/FIRUser.h +++ b/Firebase/Auth/Source/Public/FIRUser.h @@ -221,13 +221,18 @@ NS_SWIFT_NAME(User) - (void)reloadWithCompletion:(nullable FIRUserProfileChangeCallback)completion; /** @fn reauthenticateWithCredential:completion: - @brief Convenience method for `reauthenticateAndRetrieveDataWithCredential:completion:` This - method doesn't return additional identity provider data. + @brief Please use reauthenticateAndRetrieveDataWithCredential:completion: for Objective-C or + reauthenticateAndRetrieveData(WithCredential:completion:) for Swift instead. */ - (void)reauthenticateWithCredential:(FIRAuthCredential *)credential - completion:(nullable FIRUserProfileChangeCallback)completion; - -/** @fn reauthenticateWithCredential:completion: + completion:(nullable FIRUserProfileChangeCallback)completion + DEPRECATED_MSG_ATTRIBUTE( "Please use" + " reauthenticateAndRetrieveDataWithCredential:completion: for" + " Objective-C or" + " reauthenticateAndRetrieveData(WithCredential:completion:)" + " for Swift instead."); + +/** @fn reauthenticateAndRetrieveDataWithCredential:completion: @brief Renews the user's authentication tokens by validating a fresh set of credentials supplied by the user and returns additional identity provider data. @@ -322,11 +327,15 @@ NS_SWIFT_NAME(User) completion:(nullable FIRAuthTokenCallback)completion; /** @fn linkWithCredential:completion: - @brief Convenience method for `linkAndRetrieveDataWithCredential:completion:` This method - doesn't return additional identity provider data. + @brief Please use linkAndRetrieveDataWithCredential:completion: for Objective-C or + linkAndRetrieveData(WithCredential:completion:) for Swift instead. */ - (void)linkWithCredential:(FIRAuthCredential *)credential - completion:(nullable FIRAuthResultCallback)completion; + completion:(nullable FIRAuthResultCallback)completion DEPRECATED_MSG_ATTRIBUTE( + "Please use linkAndRetrieveDataWithCredential:completion: for" + " Objective-C or" + " linkAndRetrieveData(WithCredential:completion:) for" + " Swift instead."); /** @fn linkAndRetrieveDataWithCredential:completion: @brief Associates a user account from a third-party identity provider with this user and diff --git a/Firebase/Core/FIRLogger.m b/Firebase/Core/FIRLogger.m index d4de2a0..739664d 100644 --- a/Firebase/Core/FIRLogger.m +++ b/Firebase/Core/FIRLogger.m @@ -133,16 +133,6 @@ void FIRLoggerInitializeASL() { sFIRLoggerDebugMode = NO; } -#if TARGET_OS_SIMULATOR - // Need to call asl_add_output_file so that the logs can appear in Xcode's console view when - // running iOS 7. Set the ASL filter mask for this output file up to debug level so that all - // messages are viewable in the console. - if (majorOSVersion == 7) { - asl_add_output_file(sFIRLoggerClient, STDERR_FILENO, kFIRLoggerCustomASLMessageFormat, - ASL_TIME_FMT_LCL, ASL_FILTER_MASK_UPTO(ASL_LEVEL_DEBUG), ASL_ENCODE_SAFE); - } -#endif // TARGET_OS_SIMULATOR - sFIRClientQueue = dispatch_queue_create("FIRLoggingClientQueue", DISPATCH_QUEUE_SERIAL); dispatch_set_target_queue(sFIRClientQueue, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0)); @@ -196,7 +186,6 @@ BOOL FIRIsLoggableLevel(FIRLoggerLevel loggerLevel, BOOL analyticsComponent) { #ifdef DEBUG void FIRResetLogger() { sFIRLoggerOnceToken = 0; - FIRResetNumberOfIssuesLogged(); [[NSUserDefaults standardUserDefaults] removeObjectForKey:kFIRPersistedDebugModeKey]; } @@ -243,17 +232,6 @@ void FIRLogBasic(FIRLoggerLevel level, dispatch_async(sFIRClientQueue, ^{ asl_log(sFIRLoggerClient, NULL, level, "%s", logMsg.UTF8String); }); - - // Keep count of how many errors and warnings are triggered. - if (level == FIRLoggerLevelError) { - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - NSInteger errorCount = [defaults integerForKey:kFIRLoggerErrorCountKey]; - [defaults setInteger:errorCount + 1 forKey:kFIRLoggerErrorCountKey]; - } else if (level == FIRLoggerLevelWarning) { - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - NSInteger warningCount = [defaults integerForKey:kFIRLoggerWarningCountKey]; - [defaults setInteger:warningCount + 1 forKey:kFIRLoggerWarningCountKey]; - } } #pragma clang diagnostic pop @@ -281,21 +259,6 @@ FIR_LOGGING_FUNCTION(Debug) #undef FIR_MAKE_LOGGER -#pragma mark - Number of errors and warnings - -NSInteger FIRNumberOfErrorsLogged(void) { - return [[NSUserDefaults standardUserDefaults] integerForKey:kFIRLoggerErrorCountKey]; -} - -NSInteger FIRNumberOfWarningsLogged(void) { - return [[NSUserDefaults standardUserDefaults] integerForKey:kFIRLoggerWarningCountKey]; -} - -void FIRResetNumberOfIssuesLogged(void) { - [[NSUserDefaults standardUserDefaults] setInteger:0 forKey:kFIRLoggerErrorCountKey]; - [[NSUserDefaults standardUserDefaults] setInteger:0 forKey:kFIRLoggerWarningCountKey]; -} - #pragma mark - FIRLoggerWrapper @implementation FIRLoggerWrapper diff --git a/Firebase/Core/Private/FIRLogger.h b/Firebase/Core/Private/FIRLogger.h index e095e4e..cbb62e2 100644 --- a/Firebase/Core/Private/FIRLogger.h +++ b/Firebase/Core/Private/FIRLogger.h @@ -72,21 +72,6 @@ void FIRSetAnalyticsDebugMode(BOOL analyticsDebugMode); void FIRSetLoggerLevel(FIRLoggerLevel loggerLevel); /** - * Retrieve the number of errors that have been logged since the stat was last reset. - */ -NSInteger FIRNumberOfErrorsLogged(void); - -/** - * Retrieve the number of warnings that have been logged since the stat was last reset. - */ -NSInteger FIRNumberOfWarningsLogged(void); - -/** - * Reset number of errors and warnings that have been logged to 0. - */ -void FIRResetNumberOfIssuesLogged(void); - -/** * Checks if the specified logger level is loggable given the current settings. * (required) log level (one of the FIRLoggerLevel enum values). * (required) whether or not this function is called from the Analytics component. |