Skip to content

Commit aa17aff

Browse files
committed
Fixes: Login window will not dismiss in iOS13 #10
1 parent 492c510 commit aa17aff

File tree

5 files changed

+41
-3
lines changed

5 files changed

+41
-3
lines changed

TwitterKit/TwitterKit.xcodeproj/project.pbxproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -3575,7 +3575,7 @@
35753575
BITCODE_GENERATION_MODE = bitcode;
35763576
CODE_SIGN_IDENTITY = "";
35773577
ENABLE_BITCODE = YES;
3578-
MARKETING_VERSION = 5.0.3;
3578+
MARKETING_VERSION = 5.1.0;
35793579
OTHER_LDFLAGS = (
35803580
"$(inherited)",
35813581
"-ObjC",
@@ -3593,7 +3593,7 @@
35933593
BITCODE_GENERATION_MODE = bitcode;
35943594
CODE_SIGN_IDENTITY = "";
35953595
ENABLE_BITCODE = YES;
3596-
MARKETING_VERSION = 5.0.3;
3596+
MARKETING_VERSION = 5.1.0;
35973597
OTHER_LDFLAGS = (
35983598
"$(inherited)",
35993599
"-ObjC",

TwitterKit/TwitterKit/TWTRTwitter.h

+13
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,19 @@ NS_ASSUME_NONNULL_BEGIN
121121
*/
122122
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary *)options;
123123

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

126139
NS_ASSUME_NONNULL_END

TwitterKit/TwitterKit/TWTRTwitter.m

+23
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,29 @@ - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(N
401401
return NO;
402402
}
403403

404+
- (void)scene:(UIScene *)scene openURLContexts:(nonnull NSSet<UIOpenURLContext *> *)URLContexts API_AVAILABLE(ios(13.0)) {
405+
for (UIOpenURLContext *context in URLContexts) {
406+
NSURL *url = context.URL;
407+
NSString *sourceApplication = context.options.sourceApplication;
408+
BOOL isSSOBundle = sourceApplication == nil ? [self.mobileSSO isSSOWithURL:url] : [self.mobileSSO isSSOWithSourceApplication:sourceApplication];
409+
BOOL isWeb = sourceApplication == nil ? [self.mobileSSO isWebWithURL:url] : [self.mobileSSO isWebWithSourceApplication:sourceApplication];
410+
411+
if (isSSOBundle) {
412+
[self.mobileSSO processRedirectURL:url];
413+
return;
414+
} else if (isWeb) {
415+
BOOL isTokenValid = [self.mobileSSO verifyOauthTokenResponsefromURL:url];
416+
if (isTokenValid) {
417+
// If it wasn't a Mobile SSO redirect, try to handle as
418+
// SFSafariViewController redirect
419+
[self.webAuthenticationFlow resumeAuthenticationWithRedirectURL:url];
420+
return;
421+
}
422+
}
423+
}
424+
[self.mobileSSO triggerInvalidSourceError];
425+
}
426+
404427
#pragma mark - TwitterCore
405428

406429
- (NSURL *)applicationDocumentsDirectory

TwitterKit5.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "TwitterKit5"
3-
s.version = "5.0.3"
3+
s.version = "5.1.0"
44
s.summary = "Increase user engagement and app growth."
55
s.homepage = "https://github.com/touren/twitter-kit-ios"
66
s.documentation_url = "https://github.com/touren/twitter-kit-ios/wiki"

build.sh

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
set -e
4+
35
## Build TwitterKit.framework - x86_64
46
xcodebuild \
57
-project TwitterKit/TwitterKit.xcodeproj \

0 commit comments

Comments
 (0)