Skip to content

Instantly share code, notes, and snippets.

@iannase
Last active June 20, 2017 16:47
Show Gist options
  • Save iannase/91f9163e1d79e1acf26b586bd6006bf1 to your computer and use it in GitHub Desktop.
Save iannase/91f9163e1d79e1acf26b586bd6006bf1 to your computer and use it in GitHub Desktop.
iOS - Launch review if it's the first time opening and ad if it's not
let when = DispatchTime.now() + 1 // change 1 to desired number of seconds
let launchedBefore = UserDefaults.standard.bool(forKey: "launchedBefore")
DispatchQueue.main.asyncAfter(deadline: when) {
if #available(iOS 10.3, *){
if !launchedBefore {
SKStoreReviewController.requestReview()
UserDefaults.standard.set(true, forKey: "launchedBefore")
} else {
self.interstitialAd = self.createAndLoadInterstitial()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment