Skip to content

Instantly share code, notes, and snippets.

@username0x0a
Last active November 22, 2020 18:13
Show Gist options
  • Save username0x0a/ed96f5e7382ac3fbca6ab430d02bf05b to your computer and use it in GitHub Desktop.
Save username0x0a/ed96f5e7382ac3fbca6ab430d02bf05b to your computer and use it in GitHub Desktop.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wundeclared-selector"
+ (void)initialize
{
[super initialize];
#if __IPHONE_13_0
// IOS-13-TODO: Work-around for Facebook SDK to force-use Safari auth session
// instead of AuthServices session as this requires specific
// presentation context in iOS 13
if (isIOS13)
[self swizzleSelector:@selector(swiz_fbsdkbridgeapi_opURLWAuthSess:) ofClass:self
withSelector:@selector(_openURLWithAuthenticationSession:) ofClass:NSClassFromString(@"FBSDKBridgeAPI")];
#endif
}
- (void)swiz_fbsdkbridgeapi_opURLWAuthSess:(NSURL *)url
{
id val = [self valueForKey:@"_authenticationSession"];
if (val) [val cancel];
NSString *urlScheme = [NSClassFromString(@"FBSDKInternalUtility") performSelector:@selector(appURLScheme)];
SFAuthenticationSession *_authenticationSession = [[SFAuthenticationSession alloc] initWithURL:url
callbackURLScheme:urlScheme
completionHandler:[self valueForKey:@"_authenticationSessionCompletionHandler"]];
[self setValue:@YES forKey:@"_isRequestingSFAuthenticationSession"];
[self setValue:_authenticationSession forKey:@"_authenticationSession"];
[_authenticationSession start];
}
#pragma clang diagnostic pop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment