Last active
December 6, 2017 14:53
-
-
Save JazonBD/265725bb40dc016a7d9629291da39b47 to your computer and use it in GitHub Desktop.
Simple example of SKStoreReviewController use.
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
func requestUserReview() { | |
if #available(iOS 10.3, *) { | |
SKStoreReviewController.requestReview() | |
return | |
} | |
// Old approach using UIApplication. | |
let appIdString = "idXXXXXXXXX" // Your App ID ;) | |
let appStoreUrlString = "itms-apps://itunes.apple.com/app/\(appIdString)" | |
let appStoreUrl = URL(string: appStoreUrlString) | |
guard let url = appStoreUrl else { | |
return | |
} | |
if #available(iOS 10.0, *) { | |
UIApplication.shared.open(url, options: [:], completionHandler: nil) | |
} else { | |
// Instance method openURL(_:) is deprecated, use only in older iOS versions. | |
UIApplication.shared.openURL(url) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment