Skip to content

Commit

Permalink
Add missing Framework: WebKit.framework
Browse files Browse the repository at this point in the history
Bug fixed: [iOS 13] web popped when use Twitter app login twitter-archive#122
  • Loading branch information
touren committed Oct 3, 2019
1 parent 2bc1171 commit 7aa69b2
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
4 changes: 4 additions & 0 deletions DemoApp/DemoApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
191FF0FFCC8156460546E43A /* Pods_DemoApp.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0E13E2EBAF8AC955FF850B86 /* Pods_DemoApp.framework */; };
2001BA381FA0EF0F0074EA67 /* Config.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 2001BA371FA0EF0F0074EA67 /* Config.xcconfig */; };
20ABD1D71F0188DD00DCA2E0 /* TweetCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20ABD1D61F0188DC00DCA2E0 /* TweetCollectionViewController.swift */; };
2BB65BAD234654280090B40E /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2BB65BA8234654280090B40E /* WebKit.framework */; };
377340651ECA3D080065FFE0 /* DeletedTweet.json in Resources */ = {isa = PBXBuildFile; fileRef = 377340641ECA3D080065FFE0 /* DeletedTweet.json */; };
377783891E96AF1700BC4830 /* TwitterKitResources.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 377783881E96AF1700BC4830 /* TwitterKitResources.bundle */; };
3777838B1E96AFD500BC4830 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3777838A1E96AFD500BC4830 /* Images.xcassets */; };
Expand Down Expand Up @@ -168,6 +169,7 @@
0E13E2EBAF8AC955FF850B86 /* Pods_DemoApp.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_DemoApp.framework; sourceTree = BUILT_PRODUCTS_DIR; };
2001BA371FA0EF0F0074EA67 /* Config.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Config.xcconfig; path = ../Config.xcconfig; sourceTree = "<group>"; };
20ABD1D61F0188DC00DCA2E0 /* TweetCollectionViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TweetCollectionViewController.swift; sourceTree = "<group>"; };
2BB65BA8234654280090B40E /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; };
3733E29D1EA8276800E95681 /* TwitterShareExtensionUIResources.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = TwitterShareExtensionUIResources.bundle; sourceTree = BUILT_PRODUCTS_DIR; };
377340641ECA3D080065FFE0 /* DeletedTweet.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = DeletedTweet.json; sourceTree = "<group>"; };
377783881E96AF1700BC4830 /* TwitterKitResources.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = TwitterKitResources.bundle; path = ../TwitterKit/TwitterKitResources.bundle; sourceTree = "<group>"; };
Expand Down Expand Up @@ -249,6 +251,7 @@
191FF0FFCC8156460546E43A /* Pods_DemoApp.framework in Frameworks */,
377941671E96DBCF0049A022 /* FLEX.framework in Frameworks */,
377941681E96DBCF0049A022 /* MoPub.framework in Frameworks */,
2BB65BAD234654280090B40E /* WebKit.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -361,6 +364,7 @@
A7BC0A74110949C5A64504DE /* Frameworks */ = {
isa = PBXGroup;
children = (
2BB65BA8234654280090B40E /* WebKit.framework */,
AA3E099520119D3F00792255 /* MapKit.framework */,
AAEE1AF81FACCC8300F11160 /* SafariServices.framework */,
377941601E96DBCF0049A022 /* DCIntrospect_ARC.framework */,
Expand Down
10 changes: 10 additions & 0 deletions TwitterKit/TwitterKit/Social/Identity/TWTRMobileSSO.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ typedef void (^TWTRMobileSSOCompletion)(BOOL twitterAppInstalled);
*/
- (BOOL)isWebWithSourceApplication:(NSString *)sourceApplication;

/**
* Determines if the url sent from the calling applciation is valid.
*/
- (BOOL)isSSOWithURL:(NSURL *)url;

/**
* Determines if the url sent from web is valid.
*/
- (BOOL)isWebWithURL:(NSURL *)url;

/**
* Triggers an error completion when invalid source is detected
*/
Expand Down
14 changes: 14 additions & 0 deletions TwitterKit/TwitterKit/Social/Identity/TWTRMobileSSO.m
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,20 @@ - (BOOL)isWebWithSourceApplication:(NSString *)sourceApplication
return [sourceApplication hasPrefix:@"com.apple"] || [sourceApplication isEqualToString:bundleID];
}

- (BOOL)isSSOWithURL:(NSURL *)url
{
if (url == nil) return NO;
return [url.host containsString:@"secret="] &&
[url.host containsString:@"secret="] &&
[url.host containsString:@"username="] ;
}

- (BOOL)isWebWithURL:(NSURL *)url
{
if (url == nil) return NO;
return [url.host isEqualToString:@"callback"];
}

- (void)triggerInvalidSourceError
{
dispatch_async(dispatch_get_main_queue(), ^{
Expand Down
6 changes: 4 additions & 2 deletions TwitterKit/TwitterKit/TWTRTwitter.m
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,11 @@ - (BOOL)shouldShowWebBasedLogin:(NSError *)error

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary *)options
{
// Bug fixed: https://github.com/twitter-archive/twitter-kit-ios/issues/122
// Use the code from HackingGate(github.com), https://github.com/touren/twitter-kit-ios/pull/2
NSString *sourceApplication = options[UIApplicationOpenURLOptionsSourceApplicationKey];
BOOL isSSOBundle = [self.mobileSSO isSSOWithSourceApplication:sourceApplication];
BOOL isWeb = [self.mobileSSO isWebWithSourceApplication: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];
Expand Down

0 comments on commit 7aa69b2

Please sign in to comment.