Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. import Foundation
  2.  
  3. extension URL {
  4.  
  5. /// Returns an url for App Store app.
  6. ///
  7. /// Example: [itms-apps://itunes.apple.com/app/id1434568484?action=write-review]()
  8. ///
  9. /// - Parameters:
  10. /// - id: The id of the app.
  11. /// - openReviewPage: The flag for review page opening. False by default.
  12. /// - Returns: an url for App Store app.
  13. public static func appStoreURL(forAppWithID id: String, openReviewPage: Bool = false) -> URL? {
  14. var components = URLComponents()
  15. components.scheme = "itms-apps"
  16. components.host = "itunes.apple.com"
  17. components.path = "/app/id" + id
  18. if openReviewPage {
  19. components.queryItems = [URLQueryItem(name: "action", value: "write-review")]
  20. }
  21. return components.url
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement