Last active
March 20, 2019 07:18
-
-
Save artemnovichkov/bd80b5023db6fc405d231ab976bf1cc9 to your computer and use it in GitHub Desktop.
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
import Foundation | |
extension URL { | |
/// Returns an url for App Store app. | |
/// | |
/// Example: [itms-apps://itunes.apple.com/app/id1434568484?action=write-review]() | |
/// | |
/// - Parameters: | |
/// - id: The id of the app. | |
/// - openReviewPage: The flag for review page opening. False by default. | |
/// - Returns: an url for App Store app. | |
public static func appStoreURL(forAppWithID id: String, openReviewPage: Bool = false) -> URL? { | |
var components = URLComponents() | |
components.scheme = "itms-apps" | |
components.host = "itunes.apple.com" | |
components.path = "/app/id" + id | |
if openReviewPage { | |
components.queryItems = [URLQueryItem(name: "action", value: "write-review")] | |
} | |
return components.url | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment