Skip to content

Commit

Permalink
Fixes: Login window will not dismiss in iOS13 #10
Browse files Browse the repository at this point in the history
  • Loading branch information
touren committed Feb 7, 2020
1 parent 492c510 commit aa17aff
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 3 deletions.
4 changes: 2 additions & 2 deletions TwitterKit/TwitterKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3575,7 +3575,7 @@
BITCODE_GENERATION_MODE = bitcode;
CODE_SIGN_IDENTITY = "";
ENABLE_BITCODE = YES;
MARKETING_VERSION = 5.0.3;
MARKETING_VERSION = 5.1.0;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand All @@ -3593,7 +3593,7 @@
BITCODE_GENERATION_MODE = bitcode;
CODE_SIGN_IDENTITY = "";
ENABLE_BITCODE = YES;
MARKETING_VERSION = 5.0.3;
MARKETING_VERSION = 5.1.0;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down
13 changes: 13 additions & 0 deletions TwitterKit/TwitterKit/TWTRTwitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,19 @@ NS_ASSUME_NONNULL_BEGIN
*/
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary *)options;

/**
* Finish the `SFSafariViewController` authentication loop. This method should
* be called from scene:openURLContexts inside the scene delegate.
*
* This method will verify an authentication token sent by the Twitter API to
* finish the web-based authentication flow.
*
* @param scene The scene that UIKit asks to open the URL.
* @param URLContexts One or more UIOpenURLContext objects. Each object contains one URL to open and any additional information needed to open that URL.
*
*/
- (void)scene:(UIScene *)scene openURLContexts:(nonnull NSSet<UIOpenURLContext *> *)URLContexts API_AVAILABLE(ios(13.0));

@end

NS_ASSUME_NONNULL_END
23 changes: 23 additions & 0 deletions TwitterKit/TwitterKit/TWTRTwitter.m
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,29 @@ - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(N
return NO;
}

- (void)scene:(UIScene *)scene openURLContexts:(nonnull NSSet<UIOpenURLContext *> *)URLContexts API_AVAILABLE(ios(13.0)) {
for (UIOpenURLContext *context in URLContexts) {
NSURL *url = context.URL;
NSString *sourceApplication = context.options.sourceApplication;
BOOL isSSOBundle = sourceApplication == nil ? [self.mobileSSO isSSOWithURL:url] : [self.mobileSSO isSSOWithSourceApplication:sourceApplication];
BOOL isWeb = sourceApplication == nil ? [self.mobileSSO isWebWithURL:url] : [self.mobileSSO isWebWithSourceApplication:sourceApplication];

if (isSSOBundle) {
[self.mobileSSO processRedirectURL:url];
return;
} else if (isWeb) {
BOOL isTokenValid = [self.mobileSSO verifyOauthTokenResponsefromURL:url];
if (isTokenValid) {
// If it wasn't a Mobile SSO redirect, try to handle as
// SFSafariViewController redirect
[self.webAuthenticationFlow resumeAuthenticationWithRedirectURL:url];
return;
}
}
}
[self.mobileSSO triggerInvalidSourceError];
}

#pragma mark - TwitterCore

- (NSURL *)applicationDocumentsDirectory
Expand Down
2 changes: 1 addition & 1 deletion TwitterKit5.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "TwitterKit5"
s.version = "5.0.3"
s.version = "5.1.0"
s.summary = "Increase user engagement and app growth."
s.homepage = "https://github.com/touren/twitter-kit-ios"
s.documentation_url = "https://github.com/touren/twitter-kit-ios/wiki"
Expand Down
2 changes: 2 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -e

## Build TwitterKit.framework - x86_64
xcodebuild \
-project TwitterKit/TwitterKit.xcodeproj \
Expand Down

0 comments on commit aa17aff

Please sign in to comment.