-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from AKORA-Studios/AskForAppstoreReview
AskForAppstoreReview
- Loading branch information
Showing
7 changed files
with
86 additions
and
30 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
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,36 @@ | ||
// | ||
// TabViewVM.swift | ||
// Calq | ||
// | ||
// Created by Kiara on 24.06.23. | ||
// | ||
|
||
import SwiftUI | ||
|
||
class TabVM: ObservableObject { | ||
@Published var showOverlay = false | ||
@Published var firstLaunch = false | ||
@Published var lastVersion = false | ||
|
||
func checkForSheets() { | ||
firstLaunch = !UserDefaults.standard.bool(forKey: UD_firstLaunchKey) | ||
lastVersion = Util.checkIfNewVersion() | ||
showOverlay = firstLaunch || lastVersion | ||
|
||
if lastVersion { | ||
UserDefaults.standard.set(appVersion, forKey: UD_lastVersion) | ||
} | ||
} | ||
|
||
func showedFirstlaunch() { | ||
showOverlay = false | ||
firstLaunch = false | ||
UserDefaults.standard.set(true, forKey: UD_firstLaunchKey) | ||
} | ||
|
||
func showedNewVersion() { | ||
showOverlay = false | ||
lastVersion = false | ||
UserDefaults.standard.set(appVersion, forKey: UD_lastVersion) | ||
} | ||
} |
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,35 @@ | ||
// | ||
// AppStoreRating.swift | ||
// Calq | ||
// | ||
// Created by Kiara on 24.06.23. | ||
// | ||
|
||
import StoreKit | ||
|
||
func shouldAskForReview() -> Bool { | ||
if Util.getAllSubjects().count < 8 { return false } | ||
|
||
let nowTimestamp = Int(Date().timeIntervalSince1970) | ||
let lastTimestamp = Int(UserDefaults.standard.string(forKey: UD_lastAskedForeReview) ?? String(nowTimestamp)) ?? 0 | ||
let timeIntervall = 60 * 60 * 24 * 7 * 4 * 3 // around 3 months | ||
|
||
if lastTimestamp + timeIntervall < nowTimestamp { | ||
UserDefaults.standard.set(nowTimestamp, forKey: UD_lastAskedForeReview) | ||
return true | ||
} | ||
|
||
return false | ||
} | ||
|
||
func askForReview() { | ||
guard let scene = UIApplication.shared.foregroundActiveScene else { return } | ||
SKStoreReviewController.requestReview(in: scene) | ||
} | ||
|
||
extension UIApplication { | ||
var foregroundActiveScene: UIWindowScene? { | ||
connectedScenes | ||
.first(where: { $0.activationState == .foregroundActive }) as? UIWindowScene | ||
} | ||
} |
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