Skip to content

Instantly share code, notes, and snippets.

@artemnovichkov
Last active March 20, 2019 07:18
Show Gist options
  • Save artemnovichkov/bd80b5023db6fc405d231ab976bf1cc9 to your computer and use it in GitHub Desktop.
Save artemnovichkov/bd80b5023db6fc405d231ab976bf1cc9 to your computer and use it in GitHub Desktop.
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