Skip to content
This repository was archived by the owner on Dec 11, 2023. It is now read-only.

Commit da850cf

Browse files
committed
Add review view with open count
1 parent eb646cf commit da850cf

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

NowPlaying.xcodeproj/xcshareddata/xcschemes/NowPlaying.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
<EnvironmentVariable
7474
key = "OS_ACTIVITY_MODE"
7575
value = "disable"
76-
isEnabled = "NO">
76+
isEnabled = "YES">
7777
</EnvironmentVariable>
7878
</EnvironmentVariables>
7979
<AdditionalOptions>

NowPlaying/Scripts/Common/Common.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import Foundation
1010

1111
enum UserDefaultsKey: String {
12+
case appOpenCount = "app_open_count"
1213
case isWithImage = "is_with_image"
1314
case isAutoTweet = "is_auto_tweet"
1415
case isShowAutoTweetAlert = "is_show_auto_tweet_alert"

NowPlaying/Scripts/ViewController/Play/PlayViewController.swift

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import TwitterKit
1212
import SVProgressHUD
1313
import Floaty
1414
import FirebaseAnalytics
15+
import StoreKit
1516

1617
class PlayViewController: UIViewController {
1718

@@ -51,22 +52,25 @@ class PlayViewController: UIViewController {
5152

5253
override func viewDidLoad() {
5354
super.viewDidLoad()
54-
setupNavigation()
5555
setupView()
5656
layoutFAB()
57+
5758
}
5859

5960
override func viewDidAppear(_ animated: Bool) {
6061
super.viewDidAppear(animated)
6162
Analytics.setScreenName("再生画面", screenClass: "PlayViewController")
6263
Analytics.logEvent("screen_open", parameters: nil)
64+
countUpOpenCount()
6365
}
6466

6567
override func didReceiveMemoryWarning() {
6668
super.didReceiveMemoryWarning()
6769
}
6870

69-
func layoutFAB() {
71+
// MARK: - Private method
72+
73+
fileprivate func layoutFAB() {
7074
let item = FloatyItem()
7175
item.hasShadow = false
7276
item.buttonColor = UIColor.blue
@@ -89,14 +93,6 @@ class PlayViewController: UIViewController {
8993
floaty.paddingX = view.frame.width / 2 - floaty.frame.width / 2
9094
}
9195

92-
// MARK: - Private method
93-
94-
fileprivate func setupNavigation() {
95-
guard navigationController != nil else {
96-
return
97-
}
98-
}
99-
10096
fileprivate func setupView() {
10197
songNameLabel.text = nil
10298
isPlay = MPMusicPlayerController.systemMusicPlayer.playbackState == .playing
@@ -233,6 +229,16 @@ class PlayViewController: UIViewController {
233229
present(navi, animated: true, completion: nil)
234230
}
235231

232+
fileprivate func countUpOpenCount() {
233+
var count = UserDefaults.standard.integer(forKey: UserDefaultsKey.appOpenCount.rawValue)
234+
count += 1
235+
UserDefaults.standard.set(count, forKey: UserDefaultsKey.appOpenCount.rawValue)
236+
UserDefaults.standard.synchronize()
237+
if #available(iOS 10.3, *), count == 15 {
238+
SKStoreReviewController.requestReview()
239+
}
240+
}
241+
236242
// MARK: - IBAction
237243

238244
@IBAction func onTapPreviousButton(_ sender: Any) {

0 commit comments

Comments
 (0)