forked from facebook/facebook-ios-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Converted AppLinkResolverRequestBuilder to Swift
Reviewed By: samodom Differential Revision: D40146097 fbshipit-source-id: 59f19687c711947e992081e66c902a298b0135af
- Loading branch information
1 parent
65fb722
commit 43cfd8b
Showing
7 changed files
with
70 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
FBSDKCoreKit/FBSDKCoreKit/AppLink/Resolver/AppLinkResolverRequestBuilder.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#if !os(tvOS) | ||
|
||
/** | ||
Class responsible for generating the appropriate GraphRequest for a given set of urls | ||
*/ | ||
final class AppLinkResolverRequestBuilder: NSObject, _AppLinkResolverRequestBuilding { | ||
|
||
private enum IdiomField: String { | ||
case ios | ||
case iphone | ||
case ipad | ||
case appLinks = "app_links" | ||
} | ||
|
||
private let userInterfaceIdiom: UIUserInterfaceIdiom | ||
private var uiSpecificFields: [String] { | ||
var fields = [IdiomField.ios.rawValue] | ||
|
||
if let idiomSpecificField = getIdiomSpecificField() { | ||
fields.append(idiomSpecificField) | ||
} | ||
|
||
return fields | ||
} | ||
|
||
init(userInterfaceIdiom: UIUserInterfaceIdiom = UIDevice.current.userInterfaceIdiom) { | ||
self.userInterfaceIdiom = userInterfaceIdiom | ||
} | ||
|
||
func request(for urls: [URL]) -> GraphRequestProtocol { | ||
let fields = uiSpecificFields.joined(separator: ",") | ||
let encodedURLs = getEncodedURLs(urls).joined(separator: ",") | ||
|
||
let path = "?fields=\(IdiomField.appLinks.rawValue).fields(\(fields))&ids=\(encodedURLs)" | ||
return GraphRequest( | ||
graphPath: path, | ||
parameters: nil, | ||
flags: [.doNotInvalidateTokenOnError, .disableErrorRecovery] | ||
) | ||
} | ||
|
||
func getIdiomSpecificField() -> String? { | ||
switch userInterfaceIdiom { | ||
case .pad: return IdiomField.ipad.rawValue | ||
case .phone: return IdiomField.iphone.rawValue | ||
default: return nil | ||
} | ||
} | ||
|
||
private func getEncodedURLs(_ urls: [URL]) -> [String] { | ||
urls.compactMap { | ||
$0.absoluteString.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) | ||
} | ||
} | ||
} | ||
|
||
#endif |
119 changes: 0 additions & 119 deletions
119
FBSDKCoreKit/FBSDKCoreKit/AppLink/Resolver/FBSDKAppLinkResolverRequestBuilder.m
This file was deleted.
Oops, something went wrong.
31 changes: 0 additions & 31 deletions
31
FBSDKCoreKit/FBSDKCoreKit/include/FBSDKAppLinkResolverRequestBuilder.h
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters