|
@@ -7,13 +7,13 @@
|
|
|
|
|
|
import StoreKit
|
|
|
|
|
|
+let appid = "6740220736"
|
|
|
class TSSetingViewModel: ObservableObject {
|
|
|
|
|
|
@Published var settingTypes: [SettingType] = SettingType.allCases
|
|
|
@Published var isViper: Bool = PurchaseManager.default.isVip
|
|
|
@Published var isHaveNewVersion: Bool = false
|
|
|
-
|
|
|
- var appid = "6740220736"
|
|
|
+
|
|
|
// todo.kailen-privacy
|
|
|
func showPrivacy(parent: UIViewController) {
|
|
|
let vc = TSBusinessWebVC(urlType: .privacy)
|
|
@@ -55,27 +55,7 @@ class TSSetingViewModel: ObservableObject {
|
|
|
}
|
|
|
|
|
|
func rateAction() {
|
|
|
- let countKey = "ProcessCompletedCountKey"
|
|
|
- // If the app doesn't store the count, this returns 0.
|
|
|
- var count = UserDefaults.standard.integer(forKey: countKey)
|
|
|
- count += 1
|
|
|
- UserDefaults.standard.set(count, forKey: countKey)
|
|
|
- /// 如果当前版本 弹过一次 那么下一次就走url
|
|
|
- /// 如果当前版本 没弹过,那就弹
|
|
|
- if count >= 4 {
|
|
|
- let openStr = "itms-apps://itunes.apple.com/app/\(appid)?action=write-review"
|
|
|
- if let url = URL(string: openStr), UIApplication.shared.canOpenURL(url) {
|
|
|
- if #available(iOS 10.0, *) {
|
|
|
- UIApplication.shared.open(url, options: [:], completionHandler: nil)
|
|
|
- } else {
|
|
|
- UIApplication.shared.canOpenURL(url)
|
|
|
- }
|
|
|
- } else {
|
|
|
- print("链接出错")
|
|
|
- }
|
|
|
- } else {
|
|
|
- SKStoreReviewController.requestReview()
|
|
|
- }
|
|
|
+ kRateAction()
|
|
|
}
|
|
|
|
|
|
// todo.kailen-logo
|
|
@@ -134,3 +114,39 @@ extension UIImage {
|
|
|
return self
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+//首次点击保存弹出系统评分弹窗
|
|
|
+func kFirstSaveRateAction(){
|
|
|
+ if UserDefaults.standard.string(forKey: "iskFirstSaveRateAction") == nil {
|
|
|
+ kDelayOnMainThread(0.5) {
|
|
|
+ kRateAction()
|
|
|
+ }
|
|
|
+ UserDefaults.standard.set("1", forKey: "iskFirstSaveRateAction")
|
|
|
+ UserDefaults.standard.synchronize()
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+//评价 App
|
|
|
+func kRateAction() {
|
|
|
+ let countKey = "ProcessCompletedCountKey"
|
|
|
+ // If the app doesn't store the count, this returns 0.
|
|
|
+ var count = UserDefaults.standard.integer(forKey: countKey)
|
|
|
+ count += 1
|
|
|
+ UserDefaults.standard.set(count, forKey: countKey)
|
|
|
+ /// 如果当前版本 弹过一次 那么下一次就走url
|
|
|
+ /// 如果当前版本 没弹过,那就弹
|
|
|
+ if count >= 4 {
|
|
|
+ let openStr = "itms-apps://itunes.apple.com/app/\(appid)?action=write-review"
|
|
|
+ if let url = URL(string: openStr), UIApplication.shared.canOpenURL(url) {
|
|
|
+ if #available(iOS 10.0, *) {
|
|
|
+ UIApplication.shared.open(url, options: [:], completionHandler: nil)
|
|
|
+ } else {
|
|
|
+ UIApplication.shared.canOpenURL(url)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ print("链接出错")
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ SKStoreReviewController.requestReview()
|
|
|
+ }
|
|
|
+}
|