diff --git a/CHANGELOG.md b/CHANGELOG.md index 092d18b2ea..483f0659e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Deprecated +- `FBSDKLoginBehaviorNative` - `FBSDKLoginBehaviorSystemAccount` - `FBSDKLoginBehaviorWeb` - `[FBSDKLoginManager renewSystemCredentials]` diff --git a/FBSDKCoreKit/FBSDKCoreKit/FBSDKGraphErrorRecoveryProcessor.h b/FBSDKCoreKit/FBSDKCoreKit/FBSDKGraphErrorRecoveryProcessor.h index 09446f9431..465c6abb45 100644 --- a/FBSDKCoreKit/FBSDKCoreKit/FBSDKGraphErrorRecoveryProcessor.h +++ b/FBSDKCoreKit/FBSDKCoreKit/FBSDKGraphErrorRecoveryProcessor.h @@ -79,7 +79,7 @@ NS_ASSUME_NONNULL_BEGIN Note that Facebook recovery attempters can present UI or even cause app switches (such as to login). Any such work is dispatched to the main thread (therefore your request handlers may then run on the main thread). - Login recovery requires FBSDKLoginKit. Login will use FBSDKLoginBehaviorNative and will prompt the user + Login recovery requires FBSDKLoginKit. Login will prompt the user for all permissions last granted. If any are declined on the new request, the recovery is not successful but the `[FBSDKAccessToken currentAccessToken]` might still have been updated. . diff --git a/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginManager.h b/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginManager.h index c69584374c..8bd107cc48 100644 --- a/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginManager.h +++ b/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginManager.h @@ -86,14 +86,11 @@ typedef NS_ENUM(NSUInteger, FBSDKDefaultAudience) typedef NS_ENUM(NSUInteger, FBSDKLoginBehavior) { /** - This is the default behavior, and indicates logging in through the native - Facebook app may be used. The SDK may still use Safari instead. + This is the default behavior, and indicates logging in via ASWebAuthenticationSession (iOS 12+) or SFAuthenticationSession (iOS 11), + which present specialized SafariViewControllers. Falls back to plain SFSafariViewController (iOS 9 and 10) or Safari (iOS 8). */ - FBSDKLoginBehaviorNative = 0, - /** - Attempts log in through the Safari or SFSafariViewController, if available. - */ - FBSDKLoginBehaviorBrowser, + FBSDKLoginBehaviorBrowser = 0, + FBSDKLoginBehaviorNative __deprecated_enum_msg("Use FBSDKLoginBehaviorBrowser.") = FBSDKLoginBehaviorBrowser, FBSDKLoginBehaviorSystemAccount __deprecated_enum_msg("Use FBSDKLoginBehaviorBrowser.") = FBSDKLoginBehaviorBrowser, FBSDKLoginBehaviorWeb __deprecated_enum_msg("Use FBSDKLoginBehaviorBrowser.") = FBSDKLoginBehaviorBrowser, } NS_SWIFT_NAME(LoginBehavior); diff --git a/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginManager.m b/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginManager.m index 74d6436aa5..12a7fb95bb 100644 --- a/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginManager.m +++ b/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginManager.m @@ -412,38 +412,11 @@ - (void)logInWithBehavior:(FBSDKLoginBehavior)loginBehavior } }; - switch (loginBehavior) { - case FBSDKLoginBehaviorNative: { - if ([FBSDKInternalUtility isFacebookAppInstalled]) { - BOOL useNativeDialog = [serverConfiguration useNativeDialogForDialogName:FBSDKDialogConfigurationNameLogin]; - if (useNativeDialog) { - [self performNativeLogInWithParameters:loginParams handler:^(BOOL openedURL, NSError *openedURLError) { - if (openedURLError) { - [FBSDKLogger singleShotLogEntry:FBSDKLoggingBehaviorDeveloperErrors - formatString:@"FBSDKLoginBehaviorNative failed : %@\nTrying FBSDKLoginBehaviorBrowser", openedURLError]; - } - if (openedURL) { - completion(YES, FBSDKLoginManagerLoggerAuthMethod_Native, openedURLError); - } else { - [self logInWithBehavior:FBSDKLoginBehaviorBrowser]; - } - }]; - } else { - [self logInWithBehavior:FBSDKLoginBehaviorBrowser]; - } - break; - } - // Intentional fall through. Switching to browser login instead. - } - case FBSDKLoginBehaviorBrowser: { - [self performBrowserLogInWithParameters:loginParams handler:^(BOOL openedURL, - NSString *authMethod, - NSError *openedURLError) { - completion(openedURL, authMethod, openedURLError); - }]; - break; - } - } + [self performBrowserLogInWithParameters:loginParams handler:^(BOOL openedURL, + NSString *authMethod, + NSError *openedURLError) { + completion(openedURL, authMethod, openedURLError); + }]; } - (void)storeExpectedChallenge:(NSString *)challengeExpected @@ -494,32 +467,6 @@ - (void)setRequestedPermissions:(NSSet *)requestedPermissions _requestedPermissions = [requestedPermissions copy]; } -@end - -#pragma mark - - -@implementation FBSDKLoginManager (Native) - -- (void)performNativeLogInWithParameters:(NSDictionary *)loginParams handler:(void(^)(BOOL, NSError*))handler -{ - [_logger willAttemptAppSwitchingBehavior]; - loginParams = [_logger parametersWithTimeStampAndClientState:loginParams forAuthMethod:FBSDKLoginManagerLoggerAuthMethod_Native]; - - NSString *scheme = ([FBSDKSettings appURLSchemeSuffix] ? @"fbauth2" : @"fbauth"); - NSMutableDictionary *mutableParams = [NSMutableDictionary dictionaryWithDictionary:loginParams]; - mutableParams[@"legacy_override"] = FBSDK_TARGET_PLATFORM_VERSION; - NSError *error; - NSURL *authURL = [FBSDKInternalUtility URLWithScheme:scheme host:@"authorize" path:@"" queryParameters:mutableParams error:&error]; - - NSDate *start = [NSDate date]; - [[FBSDKBridgeAPI sharedInstance] openURL:authURL sender:self handler:^(BOOL openedURL, NSError *anError) { - [self->_logger logNativeAppDialogResult:openedURL dialogDuration:-start.timeIntervalSinceNow]; - if (handler) { - handler(openedURL, anError); - } - }]; -} - // change bool to auth method string. - (void)performBrowserLogInWithParameters:(NSDictionary *)loginParams handler:(FBSDKBrowserLoginSuccessBlock)handler @@ -570,6 +517,7 @@ - (void)performBrowserLogInWithParameters:(NSDictionary *)loginParams } } +#pragma mark - FBSDKURLOpening - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { BOOL isFacebookURL = [self canOpenURL:url forApplication:application sourceApplication:sourceApplication annotation:annotation]; diff --git a/FBSDKLoginKit/FBSDKLoginKit/Internal/FBSDKLoginCompletion.m b/FBSDKLoginKit/FBSDKLoginKit/Internal/FBSDKLoginCompletion.m index 50d96e1651..f18f2f7f55 100644 --- a/FBSDKLoginKit/FBSDKLoginKit/Internal/FBSDKLoginCompletion.m +++ b/FBSDKLoginKit/FBSDKLoginKit/Internal/FBSDKLoginCompletion.m @@ -127,24 +127,6 @@ - (instancetype)initWithURLParameters:(NSDictionary *)parameters appID:(NSString - (void)completeLogIn:(FBSDKLoginManager *)loginManager withHandler:(FBSDKLoginCompletionParametersBlock)handler { - if (_performExplicitFallback && loginManager.loginBehavior == FBSDKLoginBehaviorNative) { - // UIKit and iOS don't like an application opening a URL during a URL open callback, so - // we need to wait until *at least* the next turn of the run loop to open the URL to - // perform the browser log in behavior. However we also need to wait for the application - // to become active so FBSDKApplicationDelegate doesn't erroneously call back the URL - // opener before the URL has been opened. - if ([FBSDKBridgeAPI sharedInstance].isActive) { - // The application is active so there's no need to wait. - [loginManager logInWithBehavior:FBSDKLoginBehaviorBrowser]; - } else { - // use the block version to guarantee there's a strong reference to self - _observer = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^ (NSNotification *notification) { - [self attemptBrowserLogIn:loginManager]; - }]; - } - return; - } - if (_parameters.accessTokenString && !_parameters.userID) { void(^handlerCopy)(FBSDKLoginCompletionParameters *) = [handler copy]; FBSDKLoginRequestMeAndPermissions(_parameters, ^{ diff --git a/FBSDKLoginKit/FBSDKLoginKit/Internal/FBSDKLoginManager+Internal.h b/FBSDKLoginKit/FBSDKLoginKit/Internal/FBSDKLoginManager+Internal.h index 2df68867f0..933c517a4f 100644 --- a/FBSDKLoginKit/FBSDKLoginKit/Internal/FBSDKLoginManager+Internal.h +++ b/FBSDKLoginKit/FBSDKLoginKit/Internal/FBSDKLoginManager+Internal.h @@ -31,7 +31,7 @@ typedef void (^FBSDKBrowserLoginSuccessBlock)(BOOL didOpen, NSString *authMethod, NSError *error) NS_SWIFT_NAME(BrowserLoginSuccessBlock); -@interface FBSDKLoginManager () +@interface FBSDKLoginManager () @property (nonatomic, weak) UIViewController *fromViewController; @property (nonatomic, readonly) NSSet *requestedPermissions; @@ -53,13 +53,7 @@ NS_SWIFT_NAME(BrowserLoginSuccessBlock); - (void)setHandler:(FBSDKLoginManagerLoginResultBlock)handler; // for testing only - (void)setRequestedPermissions:(NSSet *)requestedPermissions; - -@end - -// the category is made available for testing only -@interface FBSDKLoginManager (Native) - -- (void)performNativeLogInWithParameters:(NSDictionary *)loginParams handler:(FBSDKSuccessBlock)handler; +// for testing only - (void)performBrowserLogInWithParameters:(NSDictionary *)loginParams handler:(FBSDKBrowserLoginSuccessBlock)handler; @end diff --git a/FBSDKLoginKit/FBSDKLoginKit/Internal/FBSDKLoginManagerLogger.m b/FBSDKLoginKit/FBSDKLoginKit/Internal/FBSDKLoginManagerLogger.m index 31b3f38c23..bb3ac46e22 100644 --- a/FBSDKLoginKit/FBSDKLoginKit/Internal/FBSDKLoginManagerLogger.m +++ b/FBSDKLoginKit/FBSDKLoginKit/Internal/FBSDKLoginManagerLogger.m @@ -97,11 +97,6 @@ - (void)startSessionForLoginManager:(FBSDKLoginManager *)loginManager NSString *behaviorString = nil; switch (loginManager.loginBehavior) { - case FBSDKLoginBehaviorNative: - willTryNative = YES; - willTryBrowser = YES; - behaviorString = @"FBSDKLoginBehaviorNative"; - break; case FBSDKLoginBehaviorBrowser: willTryBrowser = YES; behaviorString = @"FBSDKLoginBehaviorBrowser"; diff --git a/FBSDKLoginKit/FBSDKLoginKitTests/FBSDKLoginManagerTests.m b/FBSDKLoginKit/FBSDKLoginKitTests/FBSDKLoginManagerTests.m index e94962b316..748cccb73d 100644 --- a/FBSDKLoginKit/FBSDKLoginKitTests/FBSDKLoginManagerTests.m +++ b/FBSDKLoginKit/FBSDKLoginKitTests/FBSDKLoginManagerTests.m @@ -328,7 +328,7 @@ - (void)testCallingLoginWhileAnotherLoginHasNotFinishedNoOps FBSDKLoginManager *manager = [OCMockObject partialMockForObject:[FBSDKLoginManager new]]; [[[(id)manager stub] andDo:^(NSInvocation *invocation) { loginCount++; - }] logInWithBehavior:FBSDKLoginBehaviorNative]; + }] logInWithBehavior:FBSDKLoginBehaviorBrowser]; [manager logInWithReadPermissions:@[@"public_profile"] fromViewController:nil handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) { // This will never be called XCTFail(@"Should not be called");