-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[iOS] [12800] Request App Store review (#108)
We should request app store reviews in the app. We will prompt the user to review the app in the App Store after certain events occur (e.g. event rated, video finished playing, about screen loaded) and if the following requirements are met: Running iOS 10.3 or above App has been running for at least 5 minutes It's been a week since we last prompted the user for a review.
- Loading branch information
1 parent
1412d53
commit 1a13b0e
Showing
7 changed files
with
104 additions
and
6 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// | ||
// AppReview.swift | ||
// OpenStack Summit | ||
// | ||
// Created by Alsey Coleman Miller on 5/19/17. | ||
// Copyright © 2017 OpenStack. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import UIKit | ||
import StoreKit | ||
|
||
extension UIViewController { | ||
|
||
/// Attempts to prompt the user to review the app in the App Store. | ||
/// | ||
/// This method is called after certain events occur | ||
/// (e.g. event rated, video finished playing, about screen loaded) | ||
/// and can only show if the following requirements are met: | ||
/// - Running iOS 10.3 or above | ||
/// - App has been running for at least 5 minutes | ||
/// - It's been a week since we last prompted the user for a review. | ||
func requestAppReview() { | ||
|
||
guard canReviewApp | ||
else { return } | ||
|
||
// store new value | ||
Preference.lastAppReview = Date() | ||
|
||
// show UI | ||
if #available(iOS 10.3, *) { | ||
SKStoreReviewController.requestReview() | ||
} | ||
} | ||
|
||
private var canReviewApp: Bool { | ||
|
||
let lastReview = Preference.lastAppReview | ||
|
||
// first prompt or interval after last prompt | ||
if let lastReview = lastReview { | ||
|
||
let interval: Double = 60 * 24 * 7 // 1 week | ||
|
||
return Date() >= lastReview.addingTimeInterval(interval) | ||
|
||
} else { | ||
|
||
let interval: Double = 60 * 5 // 5 min | ||
|
||
return Date() >= AppDelegate.shared.appLaunch.addingTimeInterval(interval) | ||
} | ||
} | ||
} |
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
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
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